...PATH << File.expand_path('../../lib', __FILE__) require 'my_cli' MyCli.run! However, if you create a symlink to this file, this will no longer work. __FILE__ will resolve to the path of...
...the symlink, not to its target. One solution is to use File.realpath(__FILE__). In Ruby 2+ you can also use this: $LOAD_PATH << File.expand_path('../lib', __dir__) __dir__ is simply...
By activating strict_loading you force developers to address n+1 queries by preloading all associations used in the index view. Using an association that is not preloaded will raise...
...an ActiveRecord::StrictLoadingViolationError. I think it's a good default to activate strict_loading in your controllers' #index actions. This way, when a change introduces an n+1 query, your...
Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of three things can happen: The browser shows a "Save as...
...dialog. Since it is a modal dialog, we can no longer communicate with the browser through Selenium. The browser automatically downloads the file without prompting the user. For the test...
The functions below pack your current work (diffs, full repos, or specific commits) into XML/Diff files, which are then load into your clipboard as File Uploads. My...
nvm exec 22 npx repomix@latest \ --ignore "$dyn_ignores" \ --output "$out_dir/$base_name.xml" \ --split-output "2mb" \ --quiet local files=() if compgen -G "$out_dir/$base_name*.xml" > /dev/null...
...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...
RubyMine has a collaboration feature called "Code With Me". Using it, you can invite someone into your local editor to work together. This is nicer to the eyes and much...
...more powerful than sharing code through some video chat. How to Getting started is really simple: Click the "add person" icon in the top-right editor corner (or hit Ctrl...
...Request, visit /__better_errors on your app's root path (e.g. http://localhost:3000/__better_errors). It shows the error page for the last exception that occurred, even when it has been triggered...
...much faster than the configured up.form.config.observeDelay. Therefore, it may happen that you already entered something into the next field before unpoly updates that field with a server response, discarding your...
The steps I wait for active ajax requests to complete (if configured) and capybara-lockstep can catch some of these cases, but not all. Both of these only wait...
...on a Rails record is converted to UTC using to_s(:db) to be stored, and converted back into the correct time zone when the record is loaded from the...
...This is now UTC Problem That will blow up in your face when you send times to attributes that expect dates, just because those times will also be converted using...
...ZIP archive, you basically have two options: Write a ZIP file to disk and send it as a download to the user. Generate a ZIP archive on the fly while...
...streaming it in chunks to the user. This card is about option 2, and it is actually fairly easy to set up. We are using this to generate ZIP archives...
...index do |person, index| person.award_trophy(index + 1) end Ruby's map with index Similarly, you may need an index when using other methods, like map, flat_map, detect (when...
...you need the index for detection), or similar. Here is an example for map: people.map.with_index do |person, index| person.at_rank(index + 1)
We use foreman to start all necessary processes for an application, which are declared in a Procfile. This is very convenient, but the outputs of all processes get merged together...
...Especially while debugging you might not want other processes to flood your screen with their log messages. The following setup allows you to start Terminator in a split view with...
...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...
Ask the admins to turn on SSL (they will set an HSTS header for SSL-only sites) Make cookies secure and http_only Never hard-code the http protocol...
...into URLs that point to your application, which makes you vulnerable to SSL-stripping. When linking to internal resources, just use the path without protocol or URL When linking to...
If you need a sample video with certain properties for a test you can create one using ffmpeg. You might want a very low bitrate file to speed up processing...
...ffmpeg -t 21 -s 10x10 -r 1 -f rawvideo -pix_fmt rgb24 -i /dev/zero sample_21_seconds.mp4 Option Explanation -t 21 set the length to 21s -s 10x10
...this.boundStopLock = this.stopLock.bind(this) // Stream rendering document.addEventListener("turbo:before-stream-render", this.boundLockTurboStreamRendering) // Form submission document.addEventListener("turbo:submit-start", this.boundStartLock) document.addEventListener("turbo:submit-end", this.boundStopLock) // Network activity document.addEventListener("turbo:before-fetch-request...
...render", this.boundStopLock) } disconnect() { // Stream rendering document.removeEventListener("turbo:before-stream-render", this.boundLockTurboStreamRendering) // Form submission document.removeEventListener("turbo:submit-start", this.boundStartLock) document.removeEventListener("turbo:submit-end", this.boundStopLock) // Network activity document.removeEventListener("turbo:before-fetch-request...
When you have a Cucumber step like Then I should see "Did you see those \"quotation marks\" over there?" you'll run into trouble. Cucumber won't take your...
...escaped quotation marks. Workarounds One workaround is to write the step as regex (since there is a step taking a regex): Then I should see /Did you see those "quotation...
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...
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.
geordi cucumber path/to/features -r2 Background and how to rerun manually Cucumber will save a file tmp/parallel_cucumber_failures.log containing the filenames and line number of the failed scenarios after a...
...full test run. Normally you can say cucumber -p rerun (rerun is a profile defined by default in config/cucumber.yml) to rerun all failed scenarios. Here are a few alternative ways...
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...
When your site is on HTTPS and you are linking or redirecting to a HTTP site, the browser will not send a referrer. This means the target site will see...
Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.
Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done in a migration because it takes a long time.
...s say you do something like this: Project.all.each(&:recalculate_statistics!) Even though you may have been successful with this on your development machine or the staging server, keep in mind...
...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...