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...
How to install npm packages globally without sudo on Linux
All quoted.
-
Set up a package root in your homedir to hold the Node "global" packages:
$ NPM_PACKAGES="$HOME/.npm-packages" $ mkdir -p "$NPM_PACKAGES"
-
Set NPM to use this directory for its global package installs:
$ echo "prefix = $NPM_PACKAGES" >> ~/.npmrc
-
Configure your PATH and MANPATH to see commands in your $NPM_PACKAGES prefix by adding the following to your .bashrc:
# NPM packages in homedir NPM_PACKAGES="$HOME/.npm-packages" # Tell our environment about user-ins...
CSS: How to find out the rendered font in chrome
The rendered font often depends on the local font your system provides, therefore you often find a rule like below in the computed style for an element:
font-family: Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif
This means if your system has a font named Menlo
, it will render the text with this font. Otherwise it will try Monaco
and so on. For the last two fallback options the system is free to use any monospace
font or if not present any serif
font. At lea...
How to fix: Corrupt special characters in ZIPs on Linux
When you receive a ZIP file from a Windows user, umlauts and other non-latin1 characters in filenames may look corrupt, and probably will be corrupt when extracting the ZIP file.
The reason is encoding: Such archives are probably using Codepage 850. I am serious, 1987 is calling.
Fortunately, the unzip
command can handle such files like so:
unzip -O CP850 file.zip
Interestingly enough, Rubyzip also compresses files that way. Probably so files look alright to Windows users.
How to resize your boot partition when there is an encrypted partition after it
Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due to a full /boot
partition, consider risizing it.
If you can't do the steps described below, ask someone experienced to help you out.
This has worked 100% so far. 1 out of 1 tries. ;)
Scenario A: There is unassigned space on your physical drive
When there is some unpartitioned space on your drive, increasing the size of /boot
is actually very easy (even though the list below is rather long). It only takes a...
Making httpclient use the operating system's SSL cert store
The httpclient gem comes with a custom SSL cert store.
While an customizable, application-level cert store is great when you need to deal with broken or self-signed certificates, you usually want to use the cert store from the underlying Linux. The Linux cert store is updated periodically while httpclient's cert store goes out of date and will eventually not be able to verify certs.
To use the cert store from the underlying operating system:
client = HTTPClient.new
client.ssl_config.cert_store...
PostgreSQL: Upgrading your user to a superuser
Your default postgres user is named like your linux user. That default user has limited access privileges, which can cause issues such as:
- DatabaseCleaner needs to disable foreign key constraints before it can wipe the database.
- Importing a remote dump with geordi
- Asking Postgres to show the storage path of a database
Doing these things without a superuser will show a Postgres error or (in Ruby) raise PG::InsufficientPrivilege
.
To do so, the application's PostgreSQL user must be a superuser. ...
Chrome: Making high-resolution website screenshots without add-ons
If you want to make a screenshot of a website that works well in print or on a high-DPI screen (like Apple Retina displays), here is how you can capture a high-resolution screenshot.
You can do this without an addon:
- Open the website
- If you have multiple monitoros:
- Resize the Chrome window so it covers multiple monitors (in Linux you can hold ALT and resize by dragging with the right mouse button)
- Zoom into the page using
CTRL +
andCTRL -
so it covers most of the window area. Leave a little padding on the left and right so...
How to move all files in a folder to a new subfolder
Let's say you have a folder images
and want to to move all files in there to a new subfolder public
.
cd images
mkdir public
mv !(public) public
The !(public)
excludes the new subfolder itself from being moved.
How to view Image Metadata on the Linux Command Line with ImageMagick
ImageMagick has a command line tool called identify
which can read image metadata:
>identify -verbose DSC00136.JPG
Image: DSC00136.JPG
Format: JPEG (Joint Photographic 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:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 11...
Linux: Running a single unique instance of command + arguments
run-one
is a wrapper script that won't run the given command while another instance of it is running. Is brings several utility commands that offer similar behavior.
NAME
run-one - run just one instance at a time of some command and unique set of arguments (useful for cronjobs, eg)
SYNOPSIS
run-one COMMAND [ARGS]
run-this-one COMMAND [ARGS]
run-one-constantly COMMAND [ARGS]
keep-one-running COMMAND [ARGS]
run-one-until-success COMMAND [ARGS]
run-one-until-failure COMMAND [ARGS]
...
Thinkpad: Disable Bluetooth on start-up
Add the following to /etc/rc.local:
(sleep 3 && echo disable > /proc/acpi/ibm/bluetooth)&
Bluetooth icon will be active for a few seconds, then turn gray.
Linux: Quickly create large files for testing
To create a 10 GB file:
fallocate -l 10G huge_file.dat
Linux: Using grep with a regular expression
You can use three different versions of the regular expression syntax in grep
:
- basic:
-G
- extended:
-E
(POSIX) - perl:
-P
(PCRE)
Difference between basic and extended:
In basic regular expressions the meta-characters '?', '+', '{', '|', '(', and ')' loose their special meaning; instead use the backslashed versions '?', '+', '{', '|', '(', and ')'.
Difference between extended (POSIX) and perl (PCRE): E.g. \d
is not supported in POSIX.
This g...
Howto: Free disk space when /boot is full
Easy mode
This method will remove automatically installed packages that no other packages depend on any more. This, of course, includes obsolete kernel versions, with the explicit exception of the currently running kernel, the kernel version that was installed on the system before that and, of course, the latest updated version of the kernel. However, it will also remove any and all other packages that have been marked as installed automatically but have no other packages depending on them. This could lead to unexpected removal of packag...
Fix external Displays switching not on when plugging notebook in docking station
If your external displays not switching on or showing a weird behavior (for e.g. all displays getting the same configuration all the time) you can fix it by switching off all external displays and re-enabling only one in the first step. Afterwards you can apply your whole configuration via xrandr
. This behavior could be a bug in the kernel and may be fixed in linux 4.8.
Example display configuration
Screen 0: minimum 8 x 8, current 5760 x 1200, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis...
Giving a presentation with a dual screen layout on linux
When giving a presentation with a projector it is sometimes better to use a dual screen layout instead of a cloned display. If you still want a preview of the projector screen on your primary screen, you can do this:
-
Install
x11vnc
and a vnc viewer (e.g.xtightvncviewer
). -
Connect the projector.
-
In your system display settings, move the projector to the left or your primary screen (not strictly necessary, but I had weird clipping issues otherwise).
-
Start a vnc server for your second display with
x11vnc -clip xinera...
Heads up: "localhost" may be IPv6 on new linuxes
I've encountered a Ubuntu 16.04 today, where localhost
resolved to ::1
instead of 127.0.0.1
.
This will not usually make a difference, but could be relevant for firewall policies.
How to disable material design in Google Chrome
A few releases back, Chrome started using a Material Design UI on desktop. If you don't like it (on some window managers or GTK themes it's ugly), you can disable it.
- Visit chrome://flags/
- Search (
Ctrl
+F
) for "Material Design" - Switch to "Non-Material"
- Restart Chrome
Chrome's default theme should now be pretty again.
How to type brackets, braces, pipe, backslash, or at sign on OSX
On OSX (real or inside Browserstack), you need different keystrokes for your favorite special characters than you'd use on Linux or Windows.
Character | OSX Keystroke |
---|---|
[ |
Alt+5 |
] |
Alt+6 |
{ |
Alt+8 |
} |
Alt+9 |
` | ` (Pipe) |
\ (Backslash) |
Alt+Shift+7 |
@ |
Alt+L |