Archive

Posts Tagged ‘tips’

Separating history of a git repository subtree

February 20th, 2010

Most people probably already know that it’s possible to merge histories of multiple repositories by using the subtree merge strategy [1]. However, sometimes you also need to separate/decouple the history of a repository’s subdirectory into a stand-alone repository. This post outlines how.

Read more…

tips ,

git status / utf-8 umlaut tip

January 16th, 2010

git status and other commands display utf-8 filenames containing umlauts (äö etc) differently from the shell, eg. as escaped (\266, \303 etc). So in case you are having problems with umlauts, the following command should help:

$ git config core.quotepath false

From man git-config(1) for core.quotepath:

The commands that output paths (e.g.  ls-files, diff), when not
given the -z option, will quote “unusual” characters in the
pathname by enclosing the pathname in a double-quote pair and with
backslashes the same way strings in C source code are quoted. If
this variable is set to false, the bytes higher than 0×80 are not
quoted but output as verbatim. Note that double quote, backslash
and control characters are always quoted without -z regardless of
the setting of this variable.

tips ,

git tips/tricks

December 14th, 2009

I have to admit the more I use git the more I love it. Here are some random tips of commands I have found useful.

Read more…

tips ,

Sorting dicts by value in python

November 27th, 2009

A couple of tips (read: notes to self:) using sorted() and lambda to sort dicts by values in python.

Read more…

tips ,

How to modify author of multiple commits in git

July 12th, 2009

I needed a nifty way of changing author name/e-mail in multiple commits when someone made commits with wrong authorship details.

The orig branch here contains the commits to be modified, and rewrite will contain the rewritten commits.

git checkout -b rewrite
git reset --hard HEAD~4 # last four commits
git format-patch --stdout HEAD..orig |
  sed 's/^From: Joe <foo@bar>/From: New <new@mail>/' > mbox
git am mbox

Stanislav found another way to change author of git commits, but I prefer mine. ;-)

git checkout -b rewrite

tips ,

A good read on vtables

March 31st, 2009

I happened to find some good reading on C++’s virtual tables, their implementation (on g++) and dynamic_cast. Nothing too special, but somehow I’ve always managed to neglect thinking about this. The Wikipedia article “Virtual method table” is a good starting point, followed by a more detailed explanation on dynamic_cast, courtesy of  carcino.gen.nz. Don’t miss the conclusions!

tips ,

jmap: UnmappedAddressException

November 23rd, 2008

Exception in thread “main” sun.jvm.hotspot.debugger.UnmappedAddressException

Googling didn’t help much, so in case anyone else is looking for solution to this problem: my case was that I was running the java process using 1.6 and running jmap of java 1.5.

Bitten by Debian java alternatives once again…

$ readlink -f $(which jmap)

The above command is your friend when checking what version you are using. To set the version explicitly to 1.6:

$ update-alternatives –set jmap /usr/lib/jvm/java-6-sun/bin/jmap

$ update-alternatives –set jhat /usr/lib/jvm/java-6-sun/bin/jhat

tips ,

Vacuuming Firefox 3 SQLite databases

November 16th, 2008

Firefox 3 uses SQLite for history, places and various other things. These databases occasionally need VACUUMing. Quoting SQLite manual:

When an object (table, index, or trigger) is dropped from the database, it leaves behind empty space. This makes the database file larger than it needs to be, but can speed up inserts. In time inserts and deletes can leave the database file structure fragmented, which slows down disk access to the database contents.

NOTE: You need to shut down Firefox to run VACUUM.

The following commands can be used to VACUUM all FF3 sqlite databases:

$ cd ~/.mozilla/firefox/$profile/
$ tar -cf backup.tar *.sqlite # take a backup if paranoid
$ for i in *.sqlite; do sqlite3 $i vacuum; done

The difference can be quite large. For example, urlclassifier3.sqlite before and after for me:

-rw-r--r-- 1 user user 55226368 2008-11-16 13:31 urlclassifier3.sqlite
-rw-r--r-- 1 user user 29134848 2008-11-16 13:35 urlclassifier3.sqlite

So that file shrunk to about 52%. Happy vacuuming! :-P

tips

Tip: monitoring URLs in irssi

September 23rd, 2008

Some people have expressed interest in my irssi configuration, more specifically, the list of URLs that pour into my status window. Read on to learn how, but be warned that this is a serious time sink…

Read more…

tips ,

Real-time network monitoring utilities

August 13th, 2008

For after-the-fact monitoring of network usage there are various graphing frameworks such as Cacti, Munin and Serverstats. Sometimes, however, you need to use a real-time network monitoring utilities to see what is going on right now. This post shows some examples of what iftop, iptraf and vnstat can do.

Read more…

software ,