Handy Git tricks

This is a collection of tricks I use to make my life with Git easier while maintaining a clean history that helps to understand the code. Which is the whole point of version control, isn’t it?

Transplant a branch

To transplant a Git branch from one branch to another, use

git rebase --onto

Example

git rebase --onto beta develop fix

Update without checkout

To update a branch without checking it out first – e.g. to rebase onto the latest version of the parent branch, use

git fetch origin <branch>:<branch>

You really need to type the target branch twice!

Example

git fetch origin develop:develop

Rewrite history

Before I merge I rewrite my history so that each commit is clean and there are no „changes after review“ commits: they don’t help to understand why the code is the way it is.

git add .
git commit --fixup
git rebase -i --autosquash develop

Read more about this in the Git Book

Know the version

We use annotated tags to mark each release. We also never merge back but only merge older branches into newer branches. This allows us to easily determine the version number based on the tags.

git describe --first-parent [branch]

If you don’t give the name of a branch (or hash or similar), you get the version number of the current branch.

Example

git describe --first-parent beta

25 years of Clipper with a lot of Wind

My parents own a print shop which is why my first programs have been written for the management of it. The first versions were written in dBase III  which soon changed to Clipper „Summer 87“. Back then I’ve learned my first lessen of what later was called „User Experience“:

We had a secretary for whom my programm was the first contact with a computer. Accordingly her knowledge how to use that box was low. The usual programs back then were built on numbers: „enter 57 for incoming payments“. Even then nobody could memorize that. Instead I’ve built a menu hierarchy and used letters instead of numbers. You could enter the letter as well as select the menu item from the list:

This allowed for a quick start of new users as well as fast handling for seasoned operators. As little probleme were collisions with the letters. But with a little bit of creativity, I could solve that: one example was the Order – Resurrection“, which allowed to create a new order from an old one…something that happens quite often in a printer’s shop for writing paper.

There were also failures: the attempt to „rewrite the whole project in a clean way“ failed spectacular. A few years later Martin Fowler’s Refactoring gave the anwer to „Why did it fail?“. Luckily, the time last was limited – other companies were not so lucky, like Lotus or Novell.

Speaking of Novell, the software became multi-user capable a few years later. And far into the 2000s a MARS NWE did run in the print shop. Martin if you read this: I was the one who sent you a complete Novell Netware 3.x package with manuals and floppy disks, so that you could test better. Many thanks for your work, it helped us a lot!

Among the customers of the print shop were also the first companies that got their management software written by me. Altogether about 10 programs that had quite unique requirements. But most of the code was identical so that I introduced modularization quite early.

Today from these customers only one is left that now uses the software for 25 years: the Wind Saarbrücken, a retail store for sports wear, snow- and skateboards, bathing suits and more. Here I’ve created the first network connection between different locations. Back then with ISDN and a self-written database technology, which you would call eventual consistency today. All that ran on OS/2 which was the first (affordable) PC-OS that allowed real multitasking. A few years later it was replaced by Linux which still runs today. Dosemu and Dosbox were used to run the software.

The till was opened by a self soldered cable and a bit of assembly (!) code. A bit unconcerned but ran for quite some years without any hiccups until it has been replaced by a receipt printer with a dedicated port for tills. The receipt printer was also fun to integrate: as there were no printer drivers on DOS I had to manually (ok, with a little programm I wrote) convert the logo into the correct format. While printing an invoice the DOS-program reads it from a file and sends it to the printer unchanged – works like a charm for several years now.

The last change was the switch to Harbour so that the software could be run natively. Not only to be able to use a compiler from this millenium, but also so that the program did not run in an endless loop waiting for input. This can be heart by the sound of the fans as well as the power consumption.

Will the software survive another 25 years? Nobody knows! But it the Wind served faithfully and is currently been used by the third management. Best wishes for the future!

App against range anxiety

I have created a new app that helps against EV range anxiety: if you plan to buy an electric car, just install the range calculator and drive with your normal car. The app will tell you how an electric car would behave especially with respect to the battery. This easily tells you which EV fits you best. I have built the app just for myself as I want to buy one and have been confused by the press how far they would go.

Does someone have an EV and time and motivation to show burners that real world performance? I have put a lot of time in the physical model so that the results are as accurate as possible and I calibrate it with real cars on read roads. Unfortunately I currently only have access to a Model S 75 and a 30 kW Leaf…those cars are expensive when you rent them…

Who can support we for the other vehicles with real world data?

You just have to drive normally with the EV and note how much kWh the drive has used. If you want to help, just drop me a note and I will give you a special version of the app that records data so that I can tune the model (the normal version certainly does not record anything, because data privacy is important to me).

Correct connection of an RFID-RC522 to a Raspberry PI

I am currently building a simple audio book player for my kids. One part of are RFID chips for every audio book. An RFID-RF522 reader detects them and plays the corresponding audio book.

Connecting the RFID-RC522 board was more difficult than I first thought as most tutorials on the Internet have an incorrect pinout for current Raspberries. Those that are correct lack the interrupt line which causes a high power consumtion.

With this schematic the connection is simple and compact:

It allows to use interrupts which enables to write low power applications. You can find the schematics at fritzing.org.