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...

developer.mozilla.org

...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.

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...

makandra dev

...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...

...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...

...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...

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...

makandra dev

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...

...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...

...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...

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...

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.

...on a very good network connection. To test how your application behaves on a slow network (e.g. mobile), you can simulate limited bandwidth. Chrome Open the dev tools (Ctrl+Shift...

...I or F12) and switch to the "Network" tab In the row below the dev tool tabs, there's a throttling dropdown which reads "Online" by default. Inside the dropdown...

The recommended way is to define a method on your module's singleton class: module SomeTrait as_trait do define_singleton_method :foo do # ... end end end

...def (has caveats!) Alternatively, you can def the method on self: module SomeTrait as_trait do def self.foo # ... end end end This is quite concise and results in faster methods...

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...

caniuse.com

All major browsers (IE8+, FF3.5+, Safari 4+, any Chrome) support sessionStorage, a JavaScript storage object that survives page reloads and browser restores, but is different per new tab/window (in contrast...

...to localStorage which is shared across all tabs). MDN says: The sessionStorage object is most useful for hanging on to temporary data that should be saved and restored if the...

...not necessary to add a version constraint next to your packages in the package.json. Since all versions are saved in a lockfile, everyone running yarn install will get exactly the...

...within the yarn install command: Before: unpoly@^2.7.2: version "2.7.2" resolved "https://registry.yarnpkg.com/unpoly/-/unpoly-2.7.2.tgz#55044c08bce0984c000f7cd32450af39271727de" integrity sha512-jfBbBRBQMCZZcNS6fckKpFunfdiTDBXW8yxRKqLs09jSrYYUDPd+YuyDoXjABXOro0aDUIMcmyTc7moc1/Z5Tw== After: unpoly@x: version "2.7.2" resolved "https://registry.yarnpkg.com/unpoly/-/unpoly-2.7.2.tgz#55044c08bce0984c000f7cd32450af39271727de" integrity sha512-jfBbBRBQMCZZcNS6fckKpFunfdiTDBXW8yxRKqLs09jSrYYUDPd...

makandra dev

...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...

...Chrome to check if the problem disappears. Keep in mind though that running outdated software, especially web browsers, is in most cases not a good idea. Please verify periodically if...

...you still need to run the old version or if an even more recently updated version fixes the problems introduced in your version. Here's how to get old versions...

makandra dev

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...

...loading associations. By preloading associations you can prevent the n+1 query problem that slows down a many index view. You might have noticed that using :include randomly seems to...

...involved table with a condition like...

...WHERE id IN (123, 125, 170). Execute a single query for a huge table joined from all involved tables. ActiveRecord prefers option 1, probably...

...hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts The Rails default is using rake tasks for your application tasks. These live in lib/tasks...

...case you want to avoid rake for your tasks and just use plain ruby scripts, consider lib/scripts/* as folder. Keeping tasks slim For readability and testing it's easier to...

TL;DR: Rails ships two methods to convert strings to constants, constantize and safe_constantize. Neither is safe for untrusted user input. Before you call either method you must validate...

...the input string against an allowlist. The only difference between the two methods is that unresolvable constants raise an error with constantize, but return nil with safe_constantize. If you...