obda.net

git push to Multiple Remotes

1 comment

If you happen to have two remotes for your git repository—e.g. one at GitHub and one on a private server—you might want to git push your changes to both remotes at once.

To achieve this, you can leverage Git’s ability to have multiple push URLs for a remote. Create a new remote, e.g. named all, and set both remotes’ URLs as push URLs:

git remote add all <remote_url1>
git remote set-url all --add --push <remote_url1>
git remote set-url all --add --push <remote_url2>

Pushing the master branch to both remotes is now as easy as running:

git push all master

Note: of course you could just set both remote URLs as push URLs for origin. However, by creating a new remote for this purpose, you can still push to any remote separately if you want.

Convert px to rem with Sass

1 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

4 comments

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.