Device sizing and network throttling are coming to Chrome DevTools

See screenshot here.

This is great news because network throttling is very painful in Linux.

The features are already in Chrome Canary, so expect them to come to your Chrome sources soon.

rbenv: How to update list of available Ruby versions on Linux

When you tell rbenv to install a Ruby it does not know about, you will get an error message.

$ rbenv install 2.1.2
ruby-build: definition not found: 2.1.2

You can list all available versions with `rbenv install --list'.

If the version you're looking for is not present, first try upgrading
ruby-build. If it's still missing, open a request on the ruby-build
issue tracker: https://github.com/sstephenson/ruby-build/issues

(Fun fact: Recent versions of ruby-build will give you a more helpful error message which...

Linux: How to print PDF files from the command line

Sometimes you may want to print files from the command line, especially when you have lots of them.
You can use lp for that.

To print a single example.pdf file on your default printer, simply say:

lp example.pdf

lp accepts multiple filenames, so to print all PDF files in the current directory:

lp *.pdf

You can specify a printer via the -d switch:

lp -d YOUR_PRINTER_NAME *.pdf

Your printer's name is then one you defined on your system. You can check with your CUPS configuration by visiting `http://localhost:631/...

How to simulate limited bandwidth in Google Chrome and Firefox

Your development machine is usually on a very good network connection.
To test how your application behaves on a slow network (e.g. mobile), you can simulate limited bandwidth.

Chrome

  • Open the dev tools (Ctrl+Shift+I or F12) and switch to the "Network" tab
  • In the row below the dev tool tabs, there's a throttling dropdown which reads "Online" by default.
  • Inside the dropdown, you will find a few presets and an option to add your own download/upload/latency settings.

Firefox

  • Open the dev tools (Ctrl+Shift+I or F12) and switc...

Linux: Disable Bluetooth on startup

In /etc/rc.local add:

service bluetooth stop

Choosing the Right Size and Format for Icons

Icons Sizes for Windows, MacOS X, iOS, Android and Linux. It's a mess!

Skype screen sharing: Select which monitor to share

If you have multiple monitors and want to share a given screen with your call partner, drag the caller window to the desired monitor, then start sharing.

This is for Skype 4.2+ on Linux.

Legacy docs for Font Awesome 3.2.1

Font Awesome 4 has renamed all icons. What the fuck.

Check the attached link for an icon list for the old Font Awesome 3.2.1.

Note

The following icons are listed on the linked page but may not exist in your vendored font:

icon-adn
icon-align
icon-ambulance
icon-anchor
icon-android
icon-angle
icon-apple
icon-archive
icon-arrow
icon-ban
icon-bar
icon-beer
icon-bitbucket
icon-btc
icon-bug
icon-building
icon-bullseye
icon-caret
icon-chevron
icon-circle
icon-cny
icon-code
icon-coffee
icon-col...

Installation of therubyracer fails with "undefined method `include_path'"

Today I ran into trouble installing therubyracer on Ruby 1.8. The installation failed with

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
   ...

Installing multiple MySQL versions on the same Linux with mysql-sandbox

Ubuntu has a package mysql-sandbox that lets you install multiple MySQL versions into your user home:

  1. Install mysql-sandbox
sudo apt install mysql-sandbox
  1. Download the version of MySQL you want to use from mysql.com:
    https://dev.mysql.com/downloads/file/?id=480427
    Make sure to choose "Generic Linux" instead of "Ubuntu" so you get a .tar.gz instead of .deb

  2. cd into the directory the mysql binaries will be extracted to

mkdir -p ~/bin/sandbox_dist
cd ~/bin/sandbox_dist
  1. Build the sandbox
make_sandbo...

redshift

For all late night coders:

The program "redshift" changes your monitors' white balance according to your position on the planet and your local time. This is supposed to put less strain on your eyeballs than staring at a "daylight white" screen all day and night.
The program is in the Ubuntu repositories, so a simple "sudo apt-get install gtk-redshift" transfers it onto your hard drive.

I find the effect rather pleasing and so I have set the following alias on my computer:

alias rdshft='gtk-redshift -l 48.3714407:10.8982552 -t 6500:4200 &'...

Git & Mac: Working with Unicode filenames

I had some problems with Git and the file spec/fixtures/ČeskýÁČĎÉĚÍŇÓŘŠŤÚŮÝŽáčďéěíňóřšťúůýž. After pulling the latest commits, it would show that file as untracked, but adding and committing it would throw error: pathspec 'check in unicode fixture file once again' did not match any file(s) known to git.

Solution

Install Git version > 1.8.2 using homebrew and set

git config --global core.precomposeunicode true

Done.

Reason

According to the linked Stackoverflow post ...

... the cause is the different im...

Bash: How to generate a random number within given boundaries

$RANDOM on bash returns a random integer between 0 and 32767.

echo $RANDOM
9816
echo $RANDOM
30922

If you want to limit that to a certain maximum, you can just compare against the modulus of that maximum + 1. \
For example, the following will yield results between 0 and 9:

echo $(($RANDOM % 10))
5
echo $(($RANDOM % 10))
9

Note that this skews random numbers to the lower regions of your boundaries in most cases.

Ubuntu: Restart sound services

Sometimes sound breaks for me and speaker output is completely broken. This helped:

pulseaudio -k && sudo alsa force-reload

How to remap keys in Ubuntu

Good article that tells you how to change behavior of certain keys via xmodmap (with the help of exv if you need to find out the keycode).

Howto: Create a self-signed certificate

Option 1: Creating a self-signed certificate with the openssl binary

As igalic commented on this gist.

openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout server.key -out server.crt

Explanation

req -new

Create a new request ...

-newkey

... using a new key ...

rsa:2048

... of type RSA, 2048 bits long.

-sha1

Make sure to use SHA1 as this certificate's hashing algorithm,

-nodes

don't encrypt the key and

-x509

...

How to rotate log files explicitly

Usually, the logrotate service takes care of renaming log files each night or so to avoid logs becoming huge. That will rename your.log to your.log.1, the next time to your.log.2.gz, etc. Here is how to make that happen out of band (you should rarely need to do that).

Logrotate won't touch all your logs automagically. There is a config file for each service which you can tell logrotate to use.

So if you need logs to be rotated right now, do this (as root):

logrotate --force PATH_TO_CONFIG_FILE

For example, to rotate all y...

How to fix: Microphone recording levels are too quiet (or get lowered automatically)

If others on a call (Skype, SIP, ...) can not hear you loud enough, your volume levels are probably too low. Also, Skype may be changing your mixer levels.

Set a proper recording volume

  1. Open your mixer software (run pavucontrol).
  2. Switch to input devices.
  3. If you have more than one recording device, find the correct one.
  4. Make a test call to a colleague that can tell you if it's too loud or too quiet.
  5. Drag the volume slider for your input device to an adequate level -- for me, 75% (-7.46dB) work fine. 100% is usually way to...

Zeus promises to make rails development faster

I am talking about development speed. When your application starts growing and you start adding gems, it starts to take really long to start up, be it the server, console or just running a single spec.

Zeus is smart, you don’t have to put it in your Gemfile or run it with Bundler, all you need to do is create a JSON config file via zeus init and then start the server zeus start.

After that, you’re ready to go, all you need to do is prefix every command with zeus. That means rails server becomes zeus server, `rails console...

How to not leave trailing whitespace (using your editor or Git)

There is no reason to leave trailing whitespace characters in your project's files, so don't add any.

A git diff --check will tell you if there are any and you should not commit when you see them. So go ahead and switch your editor/IDE to automatically remove them for you.
Below are a few instructions on how to get them removed by your favorite IDE or editor.

Note that except for RubyMine, the following changes will remove trailing white-space on all lines, not only those that you changed.
While this should not be a problem if your proje...

Reset mysql root password

This article describes how to reset MySQL's or MariaDB's root password on your workstation. It's meant for local development purposes only, don't do this in production. This article will also help you if you have a fairly recent MariaDB version that uses authentication based on linux users instead of passwords for the root user and you prefer using a password for root.

Solution

Step 1 is getting a root mysql shell that allows us to change user credentials. We need to stop the mysql daemon first and re-start it without authorization c...

Be careful when using Unicode symbols for graphical elements

There are many fun Unicode characters like ▲ or ☯. You might be tempted to use them for graphical elements in lieu for an image. After all they are so much easier to style and scale than a raster image!

Unfortunately you will discover that these symbols render very differently on Linux, Windows and MacOS. The reason for this is that the font you are using will probably not contain any characters outside the standard Latin-1 set. When browsers encounter a character not included in the current font, they use a fallback font for this one cha...

Disable the Java plugin in browsers to avoid drive-by attacks

Every now and then, Java is subject to security issues where code can break out of Java's sandbox and obtain more privileges than it should.
In almost all cases, such issues are actively being used for drive-by attacks via the Java browser plug-in, for example by malicious ad banners.

Since removing Java completely is not an option for us, make sure the Java plug-in is always disabled in every browser, even when you have updated Java on your machine.
Please re...

Update Skype 4.x to at least 4.0.0.8

There was a bug in Skype that could cause messages to be sent to incorrect recipients (anyone, not only people from your contact list).

If you were using Skype 4 on Linux (or Skype on any other platform), upgrade immediately.

I don't know if Skype 2 on Linux is affected.