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

...only tidies up your own code, but also makes it easier to write future specs. However, not all situations are well-suited for that. Sometimes the effort isn't worth...

...would need too many parameters to be reusable. In those cases, you can also simply extract a private method: describe `/search` do it "doesn't lose the infinite scroll's...

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

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

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

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

...are using the routing-filter gem in your Rails 7.1 app for managing URL segments for locales or suffixes, you will notice that the filters do no longer apply, routes...

...your controller action. This way you receive a locale parameter from a matching URL segment. Before Rails 7.1, this method returned all associated routes (as enumerable) and the using methods...

Tested on Ubunut 22.04 1. Opener script Create a file ~/.local/bin/coverage_zip_opener with: #!/bin/bash tmp_folder="/tmp/coverage-report-opener" if [ -z "$1" ] then echo "Usage: coverage_zip_opener [filename]" exit -1 fi

index_filename=$(find /tmp/coverage-report-opener -name "index.html" | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- | head -1) if [ -z "$index_filename" ] then echo "No index file...

makandra dev

We structure our CSS using the BEM pattern. Our naming convention for blocks, elements and modifiers has evolved over the years. This card shows our current style and various alternative...

...styles that you might encounter in older projects. The difference between the various styles are mostly a matter of taste and optics. I do recommend to not mix styles and...

...from the app/models folder to the lib/ folder. The approach is applicable to arbitrary scenarios and not limited to API clients. Example Let's say we have a Rails application...

...that synchronizes its users with the Github API: . └── app └── models ├── user │   ├── github_client.rb │   └── sychronizer.rb └── user.rb In this example the app folder contains domain dependent code (user.rb and sychronizer.rb) and domain independent...

github.com

...investigate by running that example again using rspec . However, this does not work with shared examples, since Rspec doesn't know in which context the shared example should be run...

...But there is a different way: You can run the shared example using the -e, --example option. It takes a string value and runs all scenarios containing that substring in...

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

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

If you're using a Redis cache in Rails (e.g. :redis_cache_store), it's possible to configure additional parameters for your Redis connection. Example config for Rails 7.2

...store = :redis_cache_store, { pool: { timeout: 0.5 }, read_timeout: 0.2, # default 1 second write_timeout: 0.2, # default 1 second # Attempt two reconnects with some wait time in between reconnect_attempts...

Option 1: Creating a self-signed certificate with the openssl binary As igalic commented on this gist. openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout server.key...

make it an X.509 certificate, not a Certificate Signing Request. Option 2: Creating a self-signed certificate with the mkcert binary The linked tool mkcert helps you to setup...

...offset, e.g. Thu, 28 Mar 2019 16:00:00 CET +01:00. Ruby's stdlib TZInfo also has time zones, but with different identifiers. Unfortunately, not all timezone codes can...

...time zone has a pretty abbreviation. In such cases, you'll end up with a semi-broken offset identifier that humans won't understand. What to do?

makandra dev

...to add some custom functionality. This card contains some tips how to achieve this. Setup Basically, follow the guide in the Rails documentation. The automated script may not work with...

...it should be easy to fix. If you don't want the default css shipped with Action Text, you can copy the stylesheet from basecamp's github into your project...

...the test, as if the callback function is not executed in the test. However, since the test does not fail, the method :my_method must have been called during the...

...where the method :my_method should be called This will execute the original implementation (see here...

Modern CSS offers the field-sizing property to allow elements to automatically adjust size (width and/or height) to fit their contents. The most common use case are textareas which start...

...fairly small (e.g. 2 or 3 rows tall) but grow when users enter longer text. Usage textarea { field-sizing: content; } That's it! At least in modern Chromium-based browsers...

...universe multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu yakkety-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu yakkety-security...

10 http://de.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 Packages 10 http://security.ubuntu.com/ubuntu yakkety-security/main amd64 Packages 2:7.4.1829-1ubuntu2 10 10 http://de.archive.ubuntu.com/ubuntu yakkety/main...

When you need to add a event listener to hundreds of elements, this might slow down the browser. An alternative is to register an event listener at the root of...

...for events to bubble up and check whether the triggering element (event.target) matches the selector before you run your callback. This technique is called event delegation. Performance considerations

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

...or every even-numbered item. However, :nth-child can do more. In modern CSS specifications (Level 4), there’s an additional feature that lets you use :nth-child in combination...

...with a list of css selectors. This way, you can target the nth-child within a subset of siblings matching a selector. For example: .container .foo %span.my-selector .bar

...set the Sass options. Webpacker const sassLoaderConfig = environment.loaders.get('sass') const sassLoaderIndex = sassLoaderConfig.use.findIndex(config => { return config.loader === 'sass-loader' }) // Disable deprecation warnings inside dependencies sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.quietDeps = true sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.silenceDeprecations = ['import...

module.exports = { module: { rules: [ { test: /\.s[ac]ss$/i, use: [ "style-loader", "css-loader", { loader: "sass-loader", options: { sassOptions: { quietDeps: true, silenceDeprecations: ['import'], }, }, }, ], }, ], }, }; ESBuild esbuild.build({ // ... plugins: [ sassPlugin({ quietDeps: true, silenceDeprecations...