$number = $length / 1px // => 13 Converting a unit the result of an addition or subtraction between two numbers of different units is expressed in the first member’s unit
...the desired unit: $duration: .21s $duration-in-milliseconds: 0ms + $duration // => 210ms An example is storing a transition duration as CSS custom property to read it from Javascript. By converting the...
...you prepare your changelist properly, it directs your reviewer’s attention to areas that support your growth rather than boring style violations. When you demonstrate an appreciation for constructive criticism...
...your reviewer provides better feedback . Make others better: Your code review techniques set an example for your colleagues. Effective author practices rub off on your teammates, which makes your job...
...with information from an associated table, you can JOIN the associated table into the statement. Example Let's say you have a database schema where an Employee belongs_to :department...
Now you need to backfill existing Employee records with the new department_name. Since the department's name lives in another table, you need to JOIN both tables during...
Sometimes it's nice to have some coloring in your logs for better readability. You can output your logs via tail and pipe this through sed to add ANSI color...
...containing "FATAL" in red and all lines with "INFO" in green: tail -f /path/to/log | sed --unbuffered -e 's/\(.*INFO.*\)/\o033[32m\1\o033[39m/' -e 's/\(.*FATAL.*\)/\o033[31m...
...default order" of rows in database tables. For instance, when you paginate a result set: When using LIMIT, it is important to use an ORDER BY clause that constrains the...
...result rows into a unique order. Otherwise you will get an unpredictable subset of the query's rows. You might be asking for the tenth through twentieth rows, but tenth...
The benefit of the Rails asset pipeline is that it compiles your stylesheets and javascripts to a single file, respectively. However, the consequences are startling if you don't understand...
...all your asset libraries in the same folder, which quickly becomes confusing as your set of assets grows. To overcome this, we have two different solutions. Custom solution
...is a checklist I use to work on issues. For this purpose I extracted several cards related to the makandra process and ported them into a check list and refined...
...main/master branch Branch off the master with geordi branch or manually Name your branch like sort-users-by-name-73624, i.e. start with the issue id, then a shortened description...
In long diffs, it can become impossible to spot small changes in larger blocks of moved code. This may be either a method that was moved from the top to...
...the bottom of a file, or a long test file that was split in many. Fortunately, Git offers a special highlighting mode that directs the reader's attention to relevant...
Splitting up commits makes the process of reviewing often easier, since you can create several merge requests or review every commit one by one. So when you find out that...
...refactoring along the current changes, you can use one of the following processes to split up the changes into several commits in a logical order: #1 Splitting up the last...
...use heredoc to avoid endlessly long lines of code that nobody can read. Heredoc strings preserve linebreaks and can be used like this: def long_message puts(<<-EOT)
...a very long message... Sincerely, foobear EOT end <<-EOT will be somewhat of a placeholder: anything you write in the line after you used it will be its value until...
...old to match the format created by pg_dump. The version of the PostgreSQL server doesn't matter here. For example, the official Ubuntu 20.04 sources include only PostgreSQL...
...amd64] after deb so that it reads deb [arch=amd64] https://... or deb [arch=amd64 signed-by=.... Workaround Step 2: Connect with host option The latest PostgresQL client will only...
...HTML's accepts a single file. You can allow multiple files via . But sometimes, selecting multiple files is not enough and can be cumbersome for the user. Enter webkitdirectory:
...webkitdirectory switches the browser's file picker to select a directory. All files inside that directory, and inside any nested subdirectories, will be selected for the file input.
This is a short overview of things that are required to upgrade a project from the Asset Pipeline to Webpacker. Expect this upgrade to take a few days even the...
Cleanup Remove all gems you used for assets and the Asset Pipeline itself, e.g. sass-rails, uglifier, autoprefixer-rails, sprockets-rails, jquery-rails, bootstrap-sass and many more.
Normally, Rails handles encryption and signing of cookies, and you don't have to deal with the matter. Should you need to decrypt a session cookie manually: here is how...
...Obviously, you can only decrypt a session cookie from within the corresponding Rails application. Only the Rails application that encrypted a cookie has the secrets to decrypt it.
...with a nice way to grep through your project's files: The finder (ctrl + shift + f). Don't be discouraged about the notice 100+ matches in n+ files if your...
...searched keyword is too general or widely used in your project. RubyMine comes with a few ways to narrow down the resulting list, don't hesitate to apply those filters...
...s possible you get this "error" message: *** [err :: example.com] There are no Phusion Passenger-served applications running whose paths begin with '/var/www/example.com'. *** [err :: example.com] This is just because there were...
...no running passenger process for this application on the server which could be restarted. It's not a real error. The application process will start if the first request for...
Option 0: Download from the official page (preferred) Open https://googlechromelabs.github.io/chrome-for-testing/ In Section "Stable" > chromedriver / linux64 > Download ZIP from URL Take the chromedriver binary from the ZIP file and...
...your path like this: echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile Option 2: Use apt source Warning Wo no longer recommend this option. After a chrome update, the chromedriver package sometimes...
This RailsCast demonstrated a very convenient method to activate VCR for a spec by simply tagging it with :vcr. For RSpec3 the code looks almost the same with a few...
...minor changes. If you have the vcr and webmock gems installed, simply include: # spec/support/vcr.rb VCR.configure do |c| c.cassette_library_dir = Rails.root.join("spec", "vcr") c.hook_into :webmock end RSpec.configure do |c...
This note shows how to merge an ugly feature branch with multiple dirty WIP commits back into the master as one pretty commit. Squashing commits with git rebase
...here will destroy commit history and can go wrong. For this reason, do the squashing on a separate branch: git checkout -b squashed_feature This way, if you screw up...
...driver_opts directly. However, this is deprecated and will be removed in version 4 of selenium-webdriver. Version 5.x will drop support for passing the service options as hash...
...Option 2: Connect tests to a manually started chromedriver Warning This does not work with selenium-webdriver > 4 anymore. You can pass in a specific port as attribute of the...
...text right next to the code: notes for other developers, and for your future self. You can imagine comments as post-its (or sometimes multi-sheet letters ...) on real-world...
...objects like cupboards, light switches etc. As always, with power comes responsibility. Code comments can go wrong in many ways: they may become outdated, silently move away from the code...
We're always striving towards keeping our website's JavaScript as small as possible. If you're using webpack(er), you can use the webpack-bundle-analyzer plugin to get...
...a good overview, which of your JavaScript modules take up how much space, and where you can optimize. To use it, add it via npm or yarn yarn add webpack...
Ever wondered how you can create a simple table output in bash? You can use the tool column for creating a simple table output. Column gives you the possibility to...
...same level. Pipe output to column -t (maybe configure the delimeter with -s) and see the magic happening. detailed example I needed to separate a list of databases and their...
If you want to play music or sounds from a browser, your choice is to use either Flash or the new tag in HTML5. Each method has issues, but depending...
Can play MP3s or Wave files. Cannot play OGG Vorbis audio. Cannot reliably seek to a given position when playing VBR-encoded MP3s. HTML5 audio Is the future, but...