Manage your Finances with GnuCash

I have been GnuCash to help manage my finances for a while now. If used correctly, it is useful tool for tracking your finances and planning for those big ticket purchases. You do not require a lot of knowledge of accounting to use this software – just enough discipline to keep the data up to date! It is also an open source software. This tutorial provide a quick introduction to some of its basic functions.

Setup the Accounts

All assets, expenses, etc. are organised into a hierarchy of accounts. When you create a new file for the first time, you can use a wizard to set up some default accounts and custom them later. To begin, create your first accounts by selecting FileNewNew File. A New Account Heirarchy Setup druid (or a wizard) will guide you through to setting up the first set of accounts. Feel free to go through the druid to setup the first accounts. Once the wizard finishes, you’ll be brought to the accounts page.

Accounts Page

Here, you should review which accounts have been setup, as the hierarchy of accounts also represents the breakdown of your asserts, income, expenses, etc. You should check that the accounts are broken down to a level that you are happy with. For example, if you have multiple savings account you may wish to have separate subaccounts for each one instead of having just one account to represent all of them.

Tracking your Accounts

When you create a new account, the dialog will have an Opening Balance tab for you to enter the opening amount.

Opening Balance Tab

If you did not enter an opening balance, you can still enter this manually. First, open up the account that you want to enter the initial balance for. An empty accounts page will looks something like this:

Transactions For an Account

The transfer column is the account that the amount is taken from. All transactions must result in a transfer to or from another account. If you leave the column blank, GnuCash will assign a default account. For opening balances, GnuCash would have suggested using a separate equity account. After entering your opening balance, you can open the account that you transferred from. You should be able to find a corresponding entry back to your account. Each time you enter a transaction into an account, there will always be a corresponding entry in the account that you transfer from or to. When you return to the main account page, the amounts in each account will be updated to account for the transactions. The totals under each account reveal how much is in an account or how much has been spent, etc.

Recurring Transactions

GnuCash allows can automatically enter recurring transactions. There are a couple of ways to setup the transactions. The scheduled transactions editor accessed through ActionsScheduled TransactionsScheduled Transaction Editor. You should be able to go through each of the options and fill in the fields without much trouble. Once you have created your scheduled transaction, it should be added to the list of transactions on the Scheduled Transactions page. You can also create scheduled transactions from an accounts page by right clicking when you are entering a new transaction.

Generating Reports

The data collected by GnuCash can be displayed in many different ways. Firstly, there is the main accounts page that provides a snapshot of how much is in each account or how much you have spent in each category. Expense Piechart and Expense Barchart reports available under Income and Expenses are especially useful if you are trying to find ways at reducing spending. If you are also wondering how much you are worth over a period of time, you should check out the Net Work Barchart under Assests & Liabilities. However, it is important to note that the reliability of the information provided by these reports depends on how well you manage to keep the data up to date.

This covers the some of the features that you would most likely use in managing your personal finances. However, there are many more features not yet covered. If you run a business, it also has features for employee salaries, invoices and bills. If you hold shares, it also has features for entering purchased stocks and retrieving the latest prices. There are simply too many features to cover in this tutorial! If you are interested in using the other functions, the Tutorial and Concepts Guide under Help will provide most of the information that you require.

Merge Tracking with Subversion (pre 1.5.0)

Merge tracking is a feature of some revision control software. This feature remembers which merges have taken place, allowing you to later see what merges have been done and what else needs to be merged. The feature was not part of Subversion until version 1.5.0. However, not all projects are using the latest version of Subversion. Fortunately, for projects that are using older versions of subversion, there is still the svnmerge script. If your project is using the latest version of Subversion, it should already have similar functionality.

Initialising Merge Tracking

To use the script, the branch should be made by using the svn cp command. The branch is usually created from trunk. Once the branch has been created and checked out, you must tell it to initialise your checkout before making any changes. It is also important to execute the initalisation command at the top level directory of the branch. For example, lets say you check out the file:///repository/branch/example to /home/user/work so that you now the contents of the branch is located in /home/user/work/example. Then you should change to the directory /home/user/work/example before executing the initialisation command:

svnmerge init

If you had already made any changes, you should receive an error similar to the following:

svnmerge: “.” has local modifications; it must be clean

If it was successful, you should now have a file svnmerge-commit-message.txt in the directory. This file is used by the script to track the merges that are performed and can also be added to your repository so that you do not lose your merge tracking information if you delete your current checkout. The contents of the file is also human readable, so you can view it to see what has been merged.

Finding Out What is Available for Merging

Now that the svnmerge has initialised merge tracking for the directory, you can find what changes from trunk need to be merged. The avail command will tell you which versions need to be merged. To view the log messages of the versions that need to be merged, you can simply use:

svnmerge avail –log

Omitting the “–log” option will cause svnmerge to output just the revision numbers that need to be merged. The avail command also has the option “–diff” to output the differences that need to be applied. If the initialisation was not properly done, you might receive the error:

svnmerge: no integration info available

Another message that you might receive is when you have created a branch from another branch. For example, if you create branch b from a and then c from b and you executed the command on branch c, you would receive an error message that is similar to the following:

svnmerge: multiple sources found. Explicit source argument (-S/–source) required.

The merge sources available are:

/trunk

/branch/test

The problem here is that svnmerge needs to know which of the parent branches to compare branch c with. As suggested in the message, using the “-S” option will tell svnmerge which branch to compare with.

Merging to the Branch

To perform the merge, you just have to use the merge command, as follows:

svnmerge merge

Once the command has been executed, the file svnmerge-commit-message.txt will be updated with latest merge information. Note that because this file is updated when the script is called on to perform the merge, it will NOT detect any merges that you may have performed manually. Should you perform a merge without using svnmerge, you can try executing the merge with svnmerge to update the file. Alternatively, the merge command has a “-M” command to record a merge without actually performing the merge. The merge command also allows you to specify the revisions that are merged. The option for this is “-r”.

Merging Back to Parent

After you complete making changes on the branch, the script can also be used to merge the changes back to the parent branch. To do this, first change to the top level directory where the parent branch was checked out (similar to what was done in Initialising Merge Tracking). Merge tracking needs to be initialised again. Beware that if you have a svnmerge-commit-message.txt file in the directory, it will be overwritten. This path to the branch where the changes were made needs to also be specified, by using the following form of the initialising command:

svnmerge init [path to branch]

While staying in the same directory, execute the merge command to merge the changes back. Again, depending on the number of branches created from the parent, it may be necessary to specify the source branch if it complains about multiple sources (see Finding Out What is Available for Merging). Note that when merging back to the parent, you do not have to execute the initialisation command at the location of the branch.

Preventing Specific Versions From Being Merged

After executing the avail command, you might discover revisions that you might not want to merge. Revisions that should never be merged can be blocked using:

svnmerge block -r [revisions to block]

When you execute the merge again, you should find that the specified revisions are left out of the merge. Note that omitting the “-r” option and the revisions will cause all available revisions to be added to the blocked list. This is also reflected in the output from executing the avail command.

If you later decide would like to make the revision available for merging later, you can use the unblock command.

svnmerge unblock -r [revisions to unblock]

Again, omitting the “-r” and listing the revisions altogether will unblock all revisions. Should you also forget which revisions were previously blocked, you can examine the property svnmerge-blocked.

Finding Out What has Been Merged

After having committed the merges, you might want to view the merges that have been previously performed. This viewable with the integrated command, which can be used like this:

svn integrated –log

Similar to the avail command, omitting the “–log” option will cause to print out just revision numbers and “–diff” can be used to view the differences. The versions that have been merged are also recorded in the property svnmerge-integrated.

[Android] Android SDK 0.9 beta released

If you haven’t heard yet, Android SDK 0.9 beta has been released. Examples from my earlier posts were tested on m5. There has been some API changes and it has broken at least on example in one of my previous posts. I hope to go through the rest of the posts and have the examples updated sometime soon …

Generating random characters in C.

In C, when you type cast an integer to a character, the character that is assigned is the ASCII character corresponding to that number.  This property can be used to generate a set of random of characters, as follows:


1   #include <stdio.h>
2   #include <stdlib.h>
3   #include <time.h>
4
5   int main(int argc, char *argv[])
6   {
7       char randChar = ‘ ‘;
8       int counter = 0;
9       int randNum = 0;
10
11      // Provide seed for the random number
12      // generator.
13      srand(time(NULL));
14      for (counter = 0; counter < 10; counter++)
15      {
16          // First, pick a number between 0 and
17          // 25.
18          randNum = 26 * (rand() / (RAND_MAX +
19              1.0));
20
21          // The ASCII code for ‘a’ is 97, so
22          // add 97 to the random number to get
23          // a lower case letter.
24          randNum = randNum + 97;
25
26          // Type cast to character to convert
27          // it to a char type.
28          randChar = (char) randNum;
29
30          printf (“Random char: %c\n, randChar);
31      }
32  }

The documentation for rand() states that it returns a pseudorandom number between 0 and MAX_RAND. An alternative method is to use the modulus operator (“%”) to choose a number between 0 and 26 like this:

randNum = rand() % 26;

The difference between the two methods is that if the MAX_RAND was less than 26, the maximum number generated using the modulus operator will be, at most, MAX_RAND whereas the numbers will be more distributed using the first technique – although you still would not be able to get all possible numbers (thanks to Riccardo for the correction!).

Note that at line 13, the call to srand() provides a seed for the call to rand() later. If this seed was not provided, then the exact same sequence would be generated everytime. Also, if you also compile and run the example enough times, you should notice that the exact same sequence will appear after a number of tries. This is because rand is a pseudo random number generator (PRNG – see this wiki page for a detailed description).

Changing the Ubuntu Boot Screen

While installing some packages in Ubuntu, I once installed installed the edubuntu-artkwork package. At the time, I was just looking for alternatives to the default Ubuntu themes that I had. Once it was installed, I was asked to reboot it. That was when I found out that the boot screen (Uslpash) image was replaced with a rather (in my opinion) ugly one … Wanting to change it back to the original, I went searching on Google to find out how to change the boot screen back. I could only find instructions that required some building and configuration file editing (at this page). Since I just wanted to restore the previous boot screen image, I sought (and found) an easier way …

To change boot screens easily in Ubuntu, you need to first install the StartUp-Manager. This can be easily done by going to System -> Administration -> Synaptic Package Manager. In the manager, search for “startupmanager” (yes, one word). Right click on the start manager and select “mark for installation” and click on apply (the apply option becomes enabled once you have marked the start up manager for installation.

Installing the start up manager using the Synaptic package manager.

Installing the start up manager using the Synaptic package manager.

Once the manager is installed, you can access the startup manager by the menu System -> Administration -> StartUp-Manager.Now, go to the Appearance tab and you should see the options for changing the Usplash theme at the bottom.

Choose the theme you want to use. The next time Ubuntu boots up, you should see the new theme that you have selected.

Ubuntu Bootscreen

Ubuntu Bootscreen

A Virtual Box

If you are like me, you like to play games in Windows, but like to do some programming using Linux. Its pain rebooting the computer just to switch between the operating systems. Virtualization lets you use one operating system inside another. However, mention the two words and most people would probably only think of VMWare. I too used to use VMWare. However, VMPlayer doesn’t let you create your own virtual machine – you have to get an image from another source. For this reason, I went looking for an open source virtualisation software and I came across Virtual Box. I now use it run the Ubuntu 8.04. It didn’t take long to get used to the Virtual Box way of things. The only thing that really took a while for me to figure out how to get the guest operating system to truly occupy the fullscreen. It turned out to be something as simple as installing the guest add-ons. If you have been using VMWare, this one extra step to take and one that required me to read the manual. Performance wise, it runs well on my quadcore machine with Windows XP as the host operating system, although the only thing I use it for is doing some development work in Linux. More importantly, Virtual Box allows you to create and customise your own virtual machine without having to buy a license.