Tomasz Gebarowski

GList iterate and remove pattern

Recently I’ve came across a problem, when I had to iterate through a GList and remove its elements depending on some condition. This is the solution I came up with:

/* Set the iterator to the beginning of our list */
GList *node_itr = priv->_list;
while (node_itr != NULL)
{
   GObject *obj = (GObject *)node_itr->data;
   /* Store next element's pointer before removing it */
   GList *next = g_list_next(node_itr);
   /* Some dummy removal condition */
   if (my_gobject_marked_for_removal(obj))
   {
      g_object_unref(obj);
      priv->_list = g_list_delete_link(priv->_list, node_itr);
   }
   node_itr = next;
}

Emacs Elisp macro for generating GObject from template

Everyone who has worked with GObjects knows how time consuming is to create a new GObject. In order to make it working you have to generate lot of boilerplate code which is more or less the same for all the objects.

In most of the cases people tend to use templates and make several find-replace substitutions to generate the output GObject.

My first Elisp script

It’s already been one year since I switched from Vim to Emacs (thanks Aleksander;) I heard a lot about how powerful Elisp was, but I didn’t have much motivation to learn it. I started playing with Elisp last weekend and I must say that is much different from everything I used before. Anyway because I work a lot with GObjects and Glib I decided to create some useful script which will speed up my coding. My first script is trivial but it helps to create GList iterator, it acts as a simple code snippet with this difference, that the initial position of the iterator is assigned with the identifier under the cursor.

Mounting ext3 partition on OS X 10.6 (Snow Leopard)

Recently I’ve faced some problems with mounting a large (~ 850 GB) ext3 partition on OS X 10.6. I didn’t except any difficulties as I have already mounted ext2 or 3 partitions on my MBP running Leopard. Normally it could be easily done with Macfuse and fuse-ext2 extension. Unfortunately in this specific case it simply didn’t work. I have realized that I’m running a 64-bit version of Snow Leopard and Macfuse is only officially delivered for 32-bit architecture. This explained a lot! I managed to find an unofficial 64-bit compilation of Macfuse which could be downloaded from Tomas Carnecky blog. I installed the 64-bit version and used the old fuse-ext2 plugin, unfortunately when trying to mount the ext3 partition I got the following error:

fuse-ext2 /dev/disk2s2 /Volumes/Private/**

fuse-ext2 /dev/disk2s2 /Volumes/Private/fuse-ext2: version:’0.0.7′, fuse_version:’27’ [main (../../fuse-ext2/fuse-ext2.c:324)]
  
fuse-ext2: enter [do\_probe (../../fuse-ext2/do\_probe.c:30)]
  
fuse-ext2: Error while trying to open /dev/disk2s2 (rc=16) [do\_probe (../../fuse-ext2/do\_probe.c:34)]
  
fuse-ext2: Probe failed [main (../../fuse-ext2/fuse-ext2.c:340)] 

GRepoApplet

GRepoApplet is a simple GNOME Panel applet for monitoring status of Version Control Systems. Currently only SVN repositories are supported but due to provided backend API it should not be difficult to support more types of VCS’s or even DVCS’s. The applet allows to specify arbitrary number of monitored repositories and time interval between each query. All the recent changes are displayed in a nicely looking notification box generate by the libnotify.