Archive

Posts Tagged ‘tips’

How to upgrade all dependencies of a debian package

June 4th, 2010

Sometimes Debian Unstable users may find it useful to upgrade all dependencies of a package (missing version dependencies etc). The following command can be used to do it:

$ aptitude safe-upgrade ~Rpackage~U

tips ,

Blocking Facebook’s web history tracking

May 23rd, 2010

Now that Facebook is providing a “service” for sites to allow showing an iframe that allows you to like any URL (and see friends who have liked it as well), it is coincidentally collecting data on your browsing habits. Opt-out can be done using Adblock Plus with the following URL:

http://www.facebook.com/plugins/like.php?*

From privacy point of view Facebook’s iframe is a bit like Google Analytics, except that the data of your browsing habits is in the hands of a company that has consistently demonstrated that it is incapable of writing secure code and could not care less about privacy of their users.

Naturally, most of the sites out there care only about increasing incoming visitors, so they are happy to jump on the bandwagon, ignoring all the privacy issues for their users. Sigh.

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