Essential Linux Dev Stuff

I’ve recently started developing more in Linux, here is a collection of tools, tips and tricks to get the most out of the box. I’ll expand this list from time to time.

Appearance

Terminal & Editor font: Hack

Here is a test pattern I am using to evaluate fonts:

This is how the pattern looks like with Hack, my favourite programming font:

testpattern

All characters are very distinguishable, e.g. 0 and O, 1 and l. Subpixel hinting is also excellent.

colormake

Simple wrapper around make to colorize its output.

redshift

Install redshift-gtk, which is similar to f.lux but is more robust on my graphics card. I use this config for redshift (geoloc provider has problems).

In file ~/.config/redshift.conf:

Tools

Terminator

Multi-window terminal with lots of features.

ripgrep

Extremely fast grep tool, similar to ack but much faster, even faster than silver searcher. It searches through my 48GB subversion folder in 1 second. Also available for Windows! See here for installation instructions.

I’ve also added some aliases in ~/.bash_aliases:

geany

Replacement for gedit, for basic editing tasks. It’s not excellent but usually does the job. I’m not a vim/emacs guy.

Visual Studio Code

Nice and highly configurable editor, also great in Linux. Just open a directory and you are ready to go. Get it here. Essential extensions are:

There are many others, but these are the bare minimum I use.

glances

Glances gives a fantastic overview of what’s going on in the system. Using you can see at a glance if e.g. your memory, disk space, swap is running out. The version you’ll get with apt is unfortunately quite outdate, so I am installing it with pip (see the homepage).

glances

Useful Time Savers

Clear Terminal buffer

In ~/.bash_aliases, put this:

While Ctrl+L just clears the screen, cls will now clear the whole buffer. Convenient for a large build job and you want to scroll up to find something without scrolling too far.

Sleep Until

I use this ruby script to sleep until a given time. It’s in ruby so I can also easily use it in Windows:

I use this to schedule builds, so that when I arrive at the office everything is already built with the latest version so I can start working right away.

bash prompt with runtime and errorcode

See my Linux Bash Prompt post. It’s awesome.

screenshot_2016-11-07_06-24-23

Optimizations

ccache

Use ccache, and use it on an SSD disk. Here are my settings from ~/.ccache/ccache.conf:

I’m using this for a huge C++ project where I build debug, release both in 32bit and 64bit, so a large ccache helps. Using compression_level is only a very minor slowdown, but practically increases cache size by a factor of 3-5 or so.

Use tmpfs for /tmp

Much faster compilation. Add this to /etc/fstab:

Compressed RAM

Especially in virtual machines or low-end machines where memory is constrained, zram provides memory compression.

Reboot your machine, and everything is well configured. For more information, see

Disk Cleanup

Remove libreoffice

Remove old Kernels

Source: How to Easily Remove Old Kernels in Ubuntu 16.04

Virtualbox

Dynamic Disk Size

Don’t do it. It’s much slower. If you have to, be aware of this:

I’m using Linux in a Windows Host, my .vdi image is on an SSD. When using dynamic disk size, this unfortunately grows the space continuously when compiling a lot, because deleted files won’t shrink the .vdi image. But it is possible to do this with e.g. zerofree (a hazzle), or better with TRIM:

  • In the Windows host, enable SSD and TRIM support for the image (see here):

  • In Linux guest, perform TRIM, you’ll see the .vdi disk shrinking while this runs:

  • Add a nightly task to crontab with sudo crontab -e, there add this line:

I also tried to mount the image with the discard option (see here), but it caused my Linux to hang so I disabled it again

Mount shared folder

Add the user to the vboxsf group:

Edit /etc/fstab e.g. like this:

GNOME keyring Without Password Prompt

It’s unfortunate when a scheduled svn up asks for password because it has not been entered for a while. To disable the password question, do this:

  1. sudo apt install seahorse
  2. Follow this guide.

Linux Bash Prompt

Here is my bash prompt, with the following features:

  • Red ✘ if the previous command has failed, otherwise a green ✔.
  • Shows running time of the previous command
  • Separate line for path and command

Example

screenshot_2016-11-07_06-24-23

Installation

Add this to your .bashrc:

Updates

  • 2017-04-28: Now prints days, hours, minutes, seconds. Much better readable for long running tasks.
  • 2016-11-04: Initial version

Sources

How To: Download Any Flash Video with flashrip in Ubuntu

Downloading flash videos in Linux was already not too difficult, but thanks to flashrip, it has gotten very easy. Here is a little demo how it works:



Once installed, you basically use one click to get a video preview and then a prompt with the filename to save the file. The script works by looking into the newest flash files in your /tmp folder, and creates a hardlink to the save destination. When the video has fully loaded, you can close the browser window. The temp file will get deleted, and the linked copy will remain.

Installing flashrip

Open a terminal like gnome-terminal or konsole, and run these commands:

Now all thats left to do is to create a link in your gnome panel for ease of use: Right click the gnome panel, “Add to panel…”, choose “Custom Application Launcher…”. Choose a proper name, and a command like this:

For the command, replace the second parameter with the default location where you want to save the ripped videos (you have to use the full path here!)

I have tested this in Ubuntu, but it should work on any linux where gnome is installed.

Have fun!

Online Password Encrypter for Apache

Apache uses (among other hashes) SHA-1 keys for encryption in the .htpasswd. I administer a subversion server, and from time to time I have to add new external users to the system. This is usually rather cumbersome because there is no easy way to get to their encrypted password.

Thats why I have created The Online Password Encrypter. Here users can enter their desired username and password, and the encrypted key is automatically generated online, without transmitting anything to any server.

Here is an iframe of the file. Click here for full screen.

The Online Password Encrypter is just one single HTML page, it does not depend on any other files. So it is easy to download it, modify and send it around. Feel free do whatever you want with it.

Have fun,
Martin

Beautiful Font Hinting in Ubuntu 8.10 and 9.04

Even though I have an LCD monitor, I always have the subpixel hinting switched off because it is just painfully ugly to my eyes. Even when hinting is switched to maximum, the fonts are quite blurry (if you don’t believe me, type xmag and take a screenshot of your font. You can see red and blue linese everywhere). My eyes hurt when I see this.

Thanks to Johan Kivinemi I have just found out how to bring back the excellent legacy subpixel hinting engine. This has a much more crisp hinting, and uses subpixels only where it really is an improvement:

Just open these files in your home directory, and copy the content into them:

~/.fonts.conf

~/.Xresources

This should work in Ubuntu 8.04, 8.10, and 9.04 too, and makes all fonts much more crisp. Of course, your mileage may vary.

UPDATE: Comparison Screenshots

As promised on reddit, I got back from an awesome snowboard trip so I am able to put up extensive comparison screenshots of the two subpixel hinting engines. Move your mouse over the following images to see the differences. Watch especially out for letters like “m” where the spacing between the lines is very small. You might have to wait a bit for the image to load.

I have used all of the most important fonts that I usually use, and just for fun I have added “Dijkstra”, which just looks cool.

Sans Fonts

Mouse to see the same fonts with the legacy hinter.

 

Mono Fonts

Mouse to see the same fonts with the legacy hinter.

 

Zoomed Comparison Screenhots

Here is an excerpt with 400% magnifications. Mouse over the pictures to see the legacy hinter.

Zoomed Sans

 

Zoomed Mono