Git: set up remote branch tracking post factum

I often have the following scenario:
– create local repository/branch
– create gitorious project/repository
– push branch to gitorious

This way you end up with your local branch not tracking the remote one. You know you’re not tracking when you have to specify the branch every time you push/pull and when you don’t see how much commits you are ahead of the remote. It is a matter of setting up the correct tracking configuration, something like this for the master branch:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

However, I just discovered that since git 1.7 there is now a command for this:

git branch --set-upstream master origin/master

much easier to remember!

I <3 libpcap

A few years ago, I wrote a small app showing the open network connections (announcement following shortly). I never figured out how to measure transfer rates over the connections since the kernel does not seem to provide this info through the /proc filesystem (only some data queue length which is related to kernel mem usage).

Today we all know and love iftop, but where does it get that info? Simple: pcap! Out of curiosity, I checked out the libpcap docs to see how hard it would be to get started. Turned out to be pretty simple! There are a few excellent tutorials which get you started real fast. In about half an hour I made this very simple sniffer which accumulates the received bytes and packets per second and prints it out when the second changes. Each line contains the timestamp (sec), KB/s and number of packets received in that second. Here you can see me watching a youtube vid 🙂

Opening device eth0
ts = 1285276934, load = 0.7 KB/s (4)
ts = 1285276935, load = 0.3 KB/s (1)
ts = 1285276939, load = 0.9 KB/s (4)
ts = 1285276940, load = 14.4 KB/s (44)
ts = 1285276941, load = 294.9 KB/s (764)
ts = 1285276942, load = 608.9 KB/s (1505)
ts = 1285276943, load = 1164.4 KB/s (2882)
ts = 1285276944, load = 1242.6 KB/s (3064)
ts = 1285276945, load = 1166.6 KB/s (2880)
ts = 1285276946, load = 69.9 KB/s (179)
ts = 1285276947, load = 140.1 KB/s (363)
ts = 1285276948, load = 139.9 KB/s (361)
ts = 1285276949, load = 139.7 KB/s (358)
ts = 1285276950, load = 139.7 KB/s (358)
ts = 1285276951, load = 139.3 KB/s (358)
....

It is a good test to see if the calculated payload is correct. The initial burst of ~1.2MB/s confirms that. 🙂

git through proxy

You’re at work and want to access your git repo who’s residing in the free external world?

create the following config file in your .ssh folder:

Host
ProxyCommand connect -S <proxy host>:<proxy port> %h %p

replace the hosts and port as appropriate.

You can find the connect executable for windows here (contains a lot of other useful socks info as well).
Hat tip to pieter.

Amazing

The 1989 C standard didn’t allow variable argument macros. They were added in the 1999 standard. To use one according to the standard, plug in “__VA_ARGS__” where you want the variable arguments. For example:

#define print(…) real_print( __VA_ARGS__ , 0)

Of course, your compiler may or may not support either this feature or a nonstandard variation.

You might have guessed that, after all those years, the MS compiler still does not support them!!! arghh. crap.

Wiimote fun

Some while ago, I was considering to buy a gyroscopic mouse from Gyration for my future Media Center, but I’m becoming more and more convinced I should simply buy a Wiimote instead 🙂

There are lots more possibilities while still fulfilling the original needs. The Wiimote IS a gyroscopic mouse but adds the following advantages:

  • IR blaster / receiver (1024×768 resolution!!) 4 point tracking @ 100Hz
  • relatively cheap! (40 EUR)
  • speaker
  • joystick and more buttons than standard mouse
  • on-board storage
  • programmer / hacker friendly
  • go play multiplayer on a friends console 🙂

After looking at all the neat programs Johnny Lee put together, I guess you understand I can’t wait to try this out myself 😉 Also, be sure to check out his blog and numerous videos floating around the web.

First time I heard of the cool wiimote possibilities was when reading a post of Xfennec, in which he made a simple showcase of the possibilities with libwiimote using his favorite 3D engine Raydium. Be sure to check out the vid. I was really impressed back then, but of course Johnny did a lot more impressive stuff, the guy is a legend by now. Johnny does not use the libwiimote lib, but rather the dotnet WiimoteLib (I mention this ref especially for andrasj 😉 )

I have to admit that at first glance the .net lib seems more attractive due to its event based mechanism (internally, it does an async read on a stream in a loop though). The C lib looks a bit more basic but very easy to get started.

DIY gadgets

I was quite astonished to read about this BUG platform: “an open source, web-enabled, modular software + hardware platform”. This kinda says it all. 🙂 It’s still in beta, but they are targeting Q4 2007 right now to release their BUG-base, the core product, featuring an ARM microprocessor and all kind of interfaces you might desire (notice the MPEG4 HW encoding/decoding support!). Like this featurefest is not enough yet, you can extend the base station with all kind of modules: “GPS, Digital Camera / Videocam, Touch-sensitive Color LCD Screen, Accelerometer, Motion Sensor”, you name it! Before you stop drooling over the hardware specs, save some drool to drool on the software specs. 🙂 They have it nicely running on an OSGi framework! Extension galore. Judging by the screenshots, I have the impression they are running it on the eclipse framework which is an extension of OSGi (Paul, correct me if I’m wrong ;)).

This really seems the ultimate “toy for boys” or “Lego Mindstorms for adults” 🙂 at least in a geeky world 😉

Reminds me of this site/magazine where creating DIY gadgets is just daily routine.. 🙂