obda.net

Convert px to rem with Sass

Add a comment

The following Sass function converts pixels to rem:

@function px-rem($size, $base: 16px) {
    @if (unitless($size)) {
        $size: $size * 1px;
    }
    @if (unitless($base)) {
        $base: $base * 1px;
    }
    @return 1rem * ($size / $base);
}

The $size argument can be provided either with or without a px unit, for example:

font-size: px-rem(18px);   /* 1.125rem */
line-height: px-rem(24);   /* 1.5rem */

You can provide a second argument to px-rem() if your base font size is not 16 pixels.

Upgrade PostgreSQL from 9.4 to 9.5

Add a comment

Articles tagged with gentoo may not totally apply to your preferred flavor of Linux.

After installing PostgreSQL 9.5, first setup the initial database environment:

emerge --config dev-db/postgresql:9.5

Next, compare and update the configuration files:

If needed, run /etc/init.d/postgresql-9.4 stop to stop the old database server before proceeding with the upgrade.

Now, switch to the postgres user, and execute pg_upgrade, which does the hard work. Run it with the --check option first to perform only the necessary checks without changing any data:

# su - postgres
$ /usr/lib/postgresql-9.5/bin/pg_upgrade \
      --old-bindir=/usr/lib/postgresql-9.4/bin/ \
      --new-bindir=/usr/lib/postgresql-9.5/bin/ \
      --old-datadir=/var/lib/postgresql/9.4/data/ \
      --new-datadir=/var/lib/postgresql/9.5/data/ \
      --check

(This uses the default paths for the data directories; adjust the command accordingly if your setup is different.)

If the command runs without errors, execute it again without the --check flag to perform the actual upgrade. Once it is finished, you can start the new database server via /etc/init.d/postgresql-9.5 start, do some cleanup tasks that pg_upgrade might have you prompted for, and verify that everything works as before. Finally, uninstall the old PostgreSQL version, and don’t forget to add/delete services from runlevels if necessary.

Tweaking Gentoo’s Greeting Message

Add a comment

Articles tagged with gentoo may not totally apply to your preferred flavor of Linux.

Gentoo’s standard greeting message on the console looks like this:

This is <my_hostname>.<my_domain> (Linux x86_64 4.3.3-gentoo) 12:00:00

While informative, it isn’t really pretty. Modifying it turns out to be quite easy, though: just edit /etc/issue! By default, it contains:

This is \n.\O (\s \m \r) \t

Simply adjust this to your needs, and you are done. Especially removing .\O might be of interest, as this gets rid of the ugly .unknown_domain part which you get in case you don’t have a domain configured.