Linux Commands

URI Encoding an image

I've known for some time that it's possible to embed an image into CSS (useful for greasemonkey scripts), using a format like so:

url(data:[mimetype];base64,[data])

...where [mimetype] is the mime type of your data (eg, image/png).

It's eluded me until now how exactly to get at the [data] bit of this equation. This is simply the base64 encoded string of the actual bytes of the file, which you can get like so:

cat foo.png | base64

This will spit a bunch of garbage to your screen, which you copy and paste into the [data] placeholder.

Alternatives

Choosing an alternative

% sudo update-alternatives --config <name>

...where <name> is the name of a symlink in /etc/alternatives. Some of the ones I've used:

editor
x-www-browser
java

You are then prompted to select among the various alternatives available. If the desired alternative is not listed, it will have to be installed.

Installing a new editor

wtf is vim.tiny??

sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vi 1

#
Syndicate content