The TTY demystified

April 22, 2009 by

I came across this link.

Daemonizing a process

April 7, 2009 by

This link explains how to create a daemon process in C within a unix environment.

Working with remote GIT branches

March 28, 2009 by

This page describes how to use remote branches in git, when setup in a manner similar to subversion.

Creating a branch

First we create an ordinary branch, called experimental-branch:

git branch experimental-branch

Then we push it to the server:

git push origin experimental-branch

Listing branches

List all branches:

git branch -a

The one with the asterisk is the current branch.

Create a local branch to track a remote one

I don’t remember what the -b is for:

git checkout --track -b experimental-branch origin/experimental-branch

That is two dashes before track instead of a long one. WordPress don’t seem to handle this very well …

Note: If you get errors along the line of

fatal: git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout 'origin/experimental-branch' which can not be resolved as commit?

, then you might want to run:

git fetch

Switching to a branch

Simply check it out:

git checkout experimental-branch

Comitting within a branch

You are always in some branch. It does not matter if it is named master or something else.

Pushing to a remote branch from a tracking branch

If the current branch is tracking some remote branch, it is as simple as:

git push

Merging back a branch

Merging from some branch is done by:

git merge experimental-branch

Other sources

GitCasts

June 1, 2008 by

Someone has put up a site providing video demonstrations of various uses of GIT. Looking at the dates it becomes clear that, at least at the moment, a lot of material is being produced. I will definitely look into this one.

GIT repository hosting

June 1, 2008 by

These people are providing commercial GIT repository hosting (with a limited free option). Among the features is a web-based interface. It does seem a little feature-ridden, but might be worth a try …

Programming and large integers

March 2, 2008 by

We are following DIKU‘s course on Cryptography. In exercises we need to deal with large integers (> 264).

Since 264 = 18446744073709551616, I decided to implement some calculations on some larger value (i = 10000000000000000000001): subtraction, division, modulo. Below are implementations in a few languages. Each implementation lists instructions for compiling and running.

  • Java using the BigInteger class [code]
  • C using the GMP library [code]
  • Python using buildin long type [code]
  • C# No support in standard .NET namespace. Both Mono and J# are supposed to provide suitable classes.

Working with remote branches

December 8, 2007 by

Note: Better description here.

Our current project is held in a git repository. It is set up for anonymous (cvs/subversion style) push/pull operation using an ssh keypair so that we don’t need to enter password.

Recently we have been experimenting with branches. Two main branches exists: origin (which represent the serverside copy) and master (which represents the clientside copy). In git, ordinary branches exists only on the clientside and are not transferred when pushing. The solution is to use remote branches. A few commands for listing available branches:

(A) git branch
(B) git branch -r
(C) git branch -a

They list local branches (A), remote branches (B) and both local and remote branches (C). An asterisk is used to mark the current branch.

One does not work directly on a remote branch. Instead you create a corresponing local branch which tracks the remote branch. The syntax is

git checkout --track -b LOCAL_BRANCH_NAME origin/REMOTE_BRANCH_NAME

where LOCAL_BRANCH_NAME is the name of the local tracking branch and REMOTE_BRANCH_NAME is the name of the the remote branch.

Pulling works as expected, but pushing to a remote branch is a bit more complicated than one might expect. The syntax is

git push origin LOCAL_BRANCH_NAME:REMOTE_BRANCH_NAME

I’m sure there exists some fancy way to store this information so that a ‘git push‘ would do as expected, but at the moment we will cope.

Full description at this page.

Man pages of interest:
git branch
git push
git checkout

References:
Checking out a remote branch
Pushing to a remote branch (see examples)

Some java versions causing strange errors

December 3, 2007 by

We recently came across the following error message resulting from an ant-call:

/home/user/dabf/test/tuning/Indexes/Scan.xml:23: java.sql.SQLException: Error during query: Unexpected Exception: java.io.CharConversionException message given: null

Here, Scan.xml is the ant-file, which contains no java code at all. The line number gives no indication of the nature of the problem. After googling for a while we found this. The behaviour is being called very indeterministic and is caused by certain versions of java. We installed Sun Java 6 and everything worked out just fine. So much for portable code …

Accessing Absalon with Epiphany

November 20, 2007 by

For some obscure reason the university of copenhagen is trying to push Absalon as their ‘Virtual Learning Environment’ under the slogan ‘it’s learning 3.1’. The portal is available here.

The site makes use of off-site cookies and will not log you in unless you accept them. Guides for various browsers are available, but Epiphany was left out. In order to setup this browser to accept the cookies offered by Absalon, open the preferences dialog (Edit -> Preferences), go to the ‘Privacy’ tab and set ‘Cookies’ to ‘Always accept’. Be aware that this is generally considered a bad idea.

Preferences dialog for Epiphany browser. Correct cookie setting for Absalon displayed

WordPress and source code inclusion

November 7, 2007 by

Unless you know how to bend this trick, wordpress will do a very decent job at messing up everything resembling source code. This is especially true if the language you are using depends heavely on indentation. Python springs to mind.

The trick is – in the ‘Visual’ editing mode – to encapsulate the code in these tags


While entering these tags, the visual editor should report ‘Path: p‘. The value of the language attribute should – of course – be chosen to match the style of the code being included. The first link on this page lists the supported languages.

Leading spaces seems to be removed in the visual editor, but not in the code editor. So one has to do some flip-flopping … be carefull though, the interface is very eager to forget about these spaces.