...Ruby 2.7 introduced a method for this exact purpose: filter_map. So instead of >> [1, 2, 3, 4, 5, 6].map { |i| i * 2 if i.even? }.compact

>> [1, 2, 3, 4, 5, 6].select(&:even?).map { |i| i * 2 } => [4, 8, 12] you can just do >> [1, 2, 3, 4, 5, 6].filter_map { |i| i...

uri = URI.parse(path) if allow_fuzzy_expiry expires_at = expires_at.end_of_hour + 1 end timestamp = expires_at.localtime.strftime('%Y%m%d%H%M%S') # this is similar to an hmac...

stackoverflow.com

...Explicit conversion Explicit conversion happens when requesting it, e.g. with the splat operator: args = [1,2,3] some_method(*args) # Ruby calls args.to_a here Implicit conversion Implicit conversion happens...

manpages.ubuntu.com

...run-this-one is exactly like run-one, except that it will use pgrep(1) and kill(1) to find and kill any running processes owned by the user

makandra dev

...log --oneline | fzf --prompt 'Select the first commit you want to move' | awk '{print $1}') branch=$(git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ | fzf --prompt 'Select the...

...branch to rebase onto' | awk '{print $1}') test_command="git rebase -i --onto $branch $commit~" read -p "Execute command '$test_command' (Y/n)? " choice case "$choice" in n|N ) echo "aborted...

...a dependency of cucumber-rails), which will break all your tests. The fix Bundler >= 1.14 has a --conservative flag. Using the conservative flag allows bundle update GEM to update the...

The options below might be relevant if you're stuck with Bundler < 1.14: Option 1 This will work if all dependencies for the update are already satisfied.

...provides strong results at a lower cost. However, due to its significantly higher cost—$186.5 compared to $18.16 for o3-mini—o1 is best suited for highly analytical and complex...

...node-sass with esbuild. See here - you have to downgrade esbuild-sass-plugin to 1.x for that, because 2.x does not support node-sass anymore.). add libraries, that...

:file => "CarrierWave::Storage::File", :fog => "CarrierWave::Storage::Fog" } config.storage = :file config.cache_storage = nil # (1) config.fog_attributes = {} config.fog_credentials = {} config.fog_public = true config.fog_authenticated_url_expiration = 600 config.fog_use_ssl...

makandra dev

...functionality with a lot of code: https://github.com/jquery/jquery/blob/master/src/event.js Overhead of adding and removing 1000 event listeners Method duration Element#addEventListener() 11.3 ms native code $.fn.on() 60.3 ms

...of userland code up.on() 15.9 ms ~ 130 lines of userland code Overhead of adding 200 elements to an Array vs. adding to a jQuery collection Method duration Array.prototype.push()

...with HTTP code 422 Unprocessable Entity instead of the default 200 OK. This is (1) to be a good HTTP citizen and (2) to allow frontend code like detect a...

...xargs grep -cE "^inotify" | column -t -s: You will get a list like: /proc/3753/fdinfo/7 1 /proc/3774/fdinfo/7 1 /proc/4034/fdinfo/12 14 /proc/4839/fdinfo/11 7 /proc/4871/fdinfo/12 98 /proc/50565/fdinfo/10 3 /proc/50565/fdinfo/14 266 /proc/50565/fdinfo/25 186 /proc/50620/fdinfo/19...

/proc/5192/fdinfo/3 47697 /proc/5225/fdinfo/63 4 /proc/5274/fdinfo/23 3 /proc/6121/fdinfo/7 38 (...) The number between /proc/ and /fdinfo/ is the PID of the process and the last number is the number of inotify...

Cookies without an expiration timestamp are called "session cookies". [1] They should only be kept until the end of the browsing session. However, when Chrome or Firefox are configured to...

...for quite a while now and it seems they won't change their mind. [1] We are not talking about the the Rails session cookie here, though it often is...

developer.mozilla.org

...seems to be Baseline for all browsers since 2022). const fadeIn = [{ opacity: 0 }, { opacity: 1 }] // this is a keyframe example const container = document.querySelector('.animate-me') const animation = container.animate(fadeIn...

makandra dev
gist.github.com

...blocks or methods n times. If you accidentally stepped, you can return with finish 1. next [n] -- Runs n lines of code within the same frame Stacktrace frame [n] -- Moves...

...SSLCertificateNotVerified errors, or when using plain Net::HTTP: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Here is how to...

...certificate can not be verified. >> RestClient.get('https://self-signed.badssl.com/') RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Self-signed certificates are...

makandra dev
github.com

...Rails App with a core model (class FatModel) that has many (30) attributes and 100k records (totaling 500MB of data) in the corresponding PostgreSQL table An API endpoint /fat_models/index.json renders...

...to be very slow Measurements (N=20) showed that it takes an average of 10 seconds to render The log output already suggests an optimizable SQL query, view rendering time...

...certificate for localhost, you can use the following command. openssl req \ -x509 \ -nodes \ -days 10000 \ -newkey rsa:2048 \ -keyout development.key \ -out development.crt \ -subj "/CN=localhost" This generates a development.crt certificate...

...file and development.key key file. Note that the certificate will be valid for 10000 days, just because we don't want to do this again in a month or a...

...new style 'Delete %{count} users?' -- When using VIM you can use this command: :%s/{{\([^\}]*\)}}/%{\1}/cg Fix deprecation warnings with :overwrite_params Run tests Deploy See the commit log for...

...Fixes several serious vulnerabilities. Step-by-step upgrade instructions: Upgrade json gem to atleast 1.7.7, 1.6.8, or 1.5.5 Upgrade rails gem Change your environment.rb so it says RAILS_GEM_VERSION...

...your database, you might run into an error like pg_restore: error: unsupported version (1.15) in file header This is because your local pg_restore version is too old to...

...doesn't matter here. For example, the official Ubuntu 20.04 sources include only PostgreSQL 12, so your pg_restore version will also be v12. Ubuntu 22.04 includes version 14 in...

...Experts Group JFIF format) Class: DirectClass Geometry: 5472x3648+0+0 Resolution: 350x350 Print size: 15.6343x10.4229 Units: PixelsPerInch Type: TrueColor Endianess: Undefined Colorspace: sRGB Depth: 8-bit Channel depth:

blue: 8-bit Channel statistics: Red: min: 0 (0) max: 255 (1) mean: 110.006 (0.431397) standard deviation: 56.3503 (0.220982) kurtosis: -0.715336 skewness: 0.213533 Green:

makandra dev

...on hover, the following SASS is used (shorthand syntax): .element color: red transition: color .1s &:hover color: green This tells the browser "whenever the color of an .element changes, let...

...it take 1/10th of a second" and next "whenever an .element is hovered, make its text green". Multiple animated properties are comma-separated: .element color: red opacity: .9 transition: color...

makandra dev

...family: 'My variable font', Verdana, 'Helvetica Neue', Helvetica, sans-serif font-feature-settings: "kern" 1 ,"liga" 1, "calt" 1, "locl" 1 strong font-variation-settings: "wght" 700 font-weight: normal...

...you to reset font-weight on elements like , or :. strong font-variation-settings: "wdth" 100, "wght" 700 font-weight: normal // Ensure that the text is not fattened twice

...allowing you to keep your integration tests as DRY as your application code. Option 1: Call other step definitions This is Cucumbers default way of sharing short setup steps or...