Chromedriver issue #4550 breaks the user agent for device emulation via device name
Newest versions of Chromedriver breaks the user agent for device emulation via device name. In previous versions the user agent of the emulated device was set. In the newest versions the user agent differs from the emulated device.
- Version Chrome: 116.0.5845.110
- Version Chromedriver: 116.0.5845.96
- Bug: https://bugs.chromium.org/p/chromedriver/issues/detail?id=4550&q=userAgent&can=2
- Setting: https://chromedriver.chromium.org/capabilities
In Capybara an affected config looks like following:
Capybara.register_driver :mobi...
Postgres in Alpine docker container: sorting order might differ
In CI test runs I noticed that string sorting order changed after switching from a debian-based PostgreSQL docker image to one that is based on Alpine Linux.
Debian image sorting: bar Bar foo Foo
Alpine image sorting: Bar Foo bar foo
Explanation
Alpine Linux is a very slim linux distribution that results in small docker image sizes (roughly 100MB instead of 150MB), so it's a popular choice. However, it does not have all comman locales installed and does not use all locales that a user installs by default.
Postgres orders string co...
How to open files from better_errors with RubyMine on Linux
I recently noticed that better_errors
allows you to to open files from within your favorite editor. However it was not so easy to get rubymine://
links to work on Gnome/Linux. Here is how it finally worked for me:
Step 1: Add a Desktop launcher
Add this file to ~/.local/share/applications/rubymine.desktop
:
[Desktop Entry]
Version=1.0
T...
ASDF: A Version Manager To Rule Them All
tl;dr
asdf
allows you to manage multiple runtime versions with a single CLI tool and is backwards compatible by supporting existing config files, like e.g..nvmrc
or.ruby-version
.
Getting Started
- Disable rbenv
1.1 Delete or comment outsource /home/$user/.rbenvrc
in~/.profile
1.2 Delete or comment oureval "$(rbenv init -)" in
~/.bashrcor
~/.zshrc`
1.3 To take effect you may have to restart your shell or log out and log in again from your current linux session - Install asdf by following the official [...
Converting SVG to other vector formats without Inkscape
If you need to convert an SVG source to PS or EPS, the most common suggestion on the interwebs is to use Inkscape from the commandline.
Inkscape is a fairly resource-heavy tool with lots of dependencies. A great alternative for converting is CairoSVG.
CairoSVG is available on most Linux distros through their package management systems, e.g. apt install cairosvg
on Ubuntu.
It has few dependencies (most importantly Python 3 and some related packages, but really not much)...
Local development with SSL and Puma
Sometimes the need arises for SSL in local development. We have guides for different webservers, this one is for puma.
-
make sure mkcert is installed
-
create an SSL certificate for localhost with mkcert:
$ mkcert-v1.4.4-linux-amd64 localhost
Created a new local CA 💥
...
- use the certificate in the Puma config
config/puma.rb
:
localhost_key = "#{File.join('localhos...
Fix for mysql2 error "Incorrect MySQL client library version! This gem was compiled for x.x.x but the client library is y.y.y."
This should be fixed in the latest LTS-branches of our mysql2 fork, 0.2.x-lts and 0.3.x-lts.
Use
gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.2.x-lts' # for Rails 2.x
gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.3.x-lts' # for Rails 3.x
in your Gemfile, and do a
bundle update mysql2
Background
mysql2 used to check that the client library used at runtime actually matches the one it was compiled against. However, at least on Ubunt...
Working on the Linux command line: How to use bookmarks for directories
Bookmarks for directories will be most helpful if you are forced to work in deeply nested projects. Then it's really helpful!
This makes use of the CDPATH
variable. Similar to the PATH
variable, which holds the list of directories which are searched for executables, CDPATH
contains the list of directories that are available for cd
. Besides the current directory (.
), you can add others to that.
The trick is to add a directory for bookmarks to CDPATH
.
First, create the directory with: mkdir ~/.bookmarks
.
Then add the followin...
Working on the Linux command line: How to efficiently navigate up
With cd ..
you can navigate one directory up from the one you are at now. If you use that a lot, consider some handy aliases.
Add the following lines to your ~/.bashrc
:
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
you can add even more aliases, but I usually loose track after too many levels and just jump to the directly directly, e.g. using its absolute path or its bookmark (see [this card](https://makandracards.com/makandra/504947-working-on-the-li...
Working on the Linux command line: Use the `tree` command instead of repeated `cd` and `ls`
The tree
command will show you the contents of a directory and all it's sub directories as a tree:
>tree
.
├── a
│ ├── file_1.txt
│ └── file_2.txt
└── b
├── c
│ └── even_more.txt
└── more.txt
3 directories, 4 files
If you have deeply nested directories, the output will be quite long though. To avoid that, you can limit the depth, e.g. tree -L 2
will only go 2 directories deep.
If you use that regularly, consider adding aliases for that to your ~/.bashrc
:
alias tree2='tree -L 2'
alias tree3='tree -L 3'...
Working on the Linux command line: How to bash `cd` with autocorrect
There is an option you can set so that when using the cd
command, small typos are automatically corrected. Add the following to your ~/.bashrc
:
# cd: autocorrect small typos and use best guess
shopt -s cdspell
Example:
cd Porjects
# Projects
pwd
# /home/judith/Projects
Also, I recommend adding aliases for your most common typos of commands you regularly use to your ~/bashrc
. Which ones that are is highly personal, for me it's e.g. tig:
alias tog='tig'
alias tug='tig'
Using multiple MySQL versions on the same linux machine using docker
We had a card that described how to install multiple mysql versions using mysql-sandbox
. Nowadays with the wide adoption of docker it might be easier to use a MySQL docker image for this purpose.
Create a new mysql instance
docker run --name projectname_db -e MYSQL_ROOT_PASSWORD=secret -p "33008:3306" -d --restart unless-stopped mysql:5.7
The port 33008 is a freely chosen free port on the host machine that will be used to establish a con...
Geordi 6.0.0 released
6.0.0 2021-06-02
Compatible changes
-
geordi commit
will continue even if one of the given projects is inaccessible. It will only fail if no stories could be found at all.
Breaking changes
- Removed VNC test browser support for integration tests – Headless Chrome has
matured and is almost a drop-in replacement. Also, key binding issues have
increased with VNC and recent Linux.- Please use a headless Chrome setup https://makandracards.com/makandra/492109-capybara-running-tests-with-headless-chrome.
- You might also ...
Making ZSH the default shell on Ubuntu 20.04
ZSH is an alternative command line shell that includes some features like spelling correction, cd automation, better theme, and plugin support. You can replace Bash with ZSH like following:
sudo apt-get install zsh
Setting ZSH as default login shell
sudo usermod -s /usr/bin/zsh $(whoami)
Opening a new terminal window will show you a dialog where you can configure your initial ZSH config (Option 2 recommended).
Afterwards you can install the plugin manager Oh-My-ZSH and select a prop...
Too many parallel test processes may amplify flaky tests
By default parallel_tests will spawn as many test processes as you have CPUs. If you have issues with flaky tests, reducing the number of parallel processes may help.
Important
Flaky test suites can and should be fixed. This card is only relevant if you need to run a flaky test suite that you cannot fix for some reason. If you have no issues...
Linux: How to make a terminal window title reflect the current path
By default, your terminal emulator (Gnome Terminal, Terminator, etc.) sets some kind of window title to reflect the shell type you are running (e.g. /bin/bash
).
This is most often not too helpful, but you can change that from your shell.
To set a specific title, print an escape sequence like this:
echo -en "\033]0;Hello\a"
You can easily include the current path:
echo -en "\033]0;$(pwd)\a"
Or, to replace your home directory's part with a tilde:
echo -en "\033]0;$(pwd | sed -e "s;^$HOME;~;")\a"
Or,...
Manage Linux services on the command line (Ubuntu)
Ubuntu 18.04 uses systemd
to manage services.
There are basically two commands for listing all services and manipulating the state of a certain service: service
and systemctl
:
-
service
manages System V init scripts -
systemctl
controls the state of the systemd system and service manager. It is backwards compatible to System V and includes the System V services
Therefore I prefer to use systemctl
.
See which services are there
>systemctl list-units -a --type=service
UNIT LOAD ...
RubyMine: Restore main menu in Ubuntu
After a recent Ubuntu update I didn't see the main menu bar of the RubyMine IDE (File | Edit | View | ...
) anymore.
This could be solved by changing a RubyMine registry entry:
- Search "registry" within the "Actions" search
- press
ctrl + alt + n
> click onActions
> typeregistry
> click onRegistry...
- press
- Scroll down to
linux.native.menu
and disable the checkbox
After rebooting RubyMine, you'll have gotten the menu bar back.
Colorful output for several linux command line tools: grc
Because colors improve readability so much.
On Ubuntu 18.04 you can install it with sudo apt install grc
From github:
For the impatient - try following commands:
grc netstat
grc ping hostname
grc tail /var/log/syslog
grc ps aux
How to capture a screen-cast on Linux
Recording
SimpleScreenRecorder
I recommend simplescreenrecorder, it produces an adequate output with only a few clicks. The audio recording contained some static noises, but that might be caused by my microphone.
Recording only a single screen or fixed rectangle is supported. The video quality seems quite grained when using the default settings - I found that using the MKV container, H.264 codec, "0" constant rate factor and "veryslow" preset results in the best video quality.
###...
Linux, Arial and Helvetica: Different font rendering in Firefox and Chrome
When text renders differently in Firefox and Chrome, it may be caused by a font alias that both browsers handle differently.
Situation
A machine running Linux, and a website with the Bootstrap 3 default font-family: "Helvetica Neue", Helvetica, Arial, sans-serif
.
Issue
Anti-aliasing and kerning of text looks bad in Firefox. Worse, it is rendered 1px lower than in Chrome (shifted down).
Reason
Firefox resolves "Helvetica" to an installed ["TeX Gyre Heros", which is its Ghostscript clone](https://www.fontsquirrel.com/fonts/...
How to enable Chromedriver logging
When using Chrome for Selenium tests, the chromedriver
binary will be used to control Chrome. To debug problems that stem from Selenium's Chrome and/or Chromedriver, you might want to enable logging for the chromedriver itself. Here is how.
Option 1: Use Selenium::WebDriver::Service
In your test setup, you may already have something like Capybara::Selenium::Driver.new(@app, browser: :chrome, options: ...)
, especially when passing options like device emulation.
Similar to options
, simply add an extra key service
and pass an inst...
Joining PDFs with Linux command line
There are several ways to merge two (or more) PDF files to a single file using the Linux command line.
If you're looking for graphical tools to edit or annotate a PDF, we have a separate card for that.
PDFtk (recommended)
PDFtk is a great toolkit for manipulating PDF documents. You may need to install it first (sudo apt install pdftk
).
Merging multiple files works like this:
pdftk one.pdf two.pdf cat output out.pdf
Unlike pdfjam, PDFtk should not mess with page sizes but simply joins pages as they are.
...
Yarn: How to recognize that you are using a different node version than your colleagues
The issue in this card can occur if the node_modules
directory is checked into your Git repository. We usually recommend to exclude node_modules
from version control.
In any case you should document which version of node to use in your project in a .nvmrc
file.
I saw a strange behaviour after we introduced webpack in one of our projects and finally found out the reason: The person who committed the files used a node version that is older than mine.
Every time I wanted to run my rai...