SNCF: France in a nutshell

10. mars 2013

To enable the SNCF to investigate your application please send a letter to:

Service relation clients SNCF
62 973 ARRAS Cedex 9

We hope this information will answer all your questions and that TGV-europe keeps your trust, wishing you a pleasant day.

Best Regards
Samuel TOPET

After forming a complaint letter, and managing to send it through the labyrinth of a web page SNCF keeps, this is what I got as a response. One thing is that SNCF is so hopelessly stuck in the past that they do not even accept e-mail inquiries on the service level. Another thing is that they would rather have you send snail mail into the black hole they call their service department than forward your complaint to the right person. Somehow I sense that even if I should be able to get hold of the right department (eventually), my complaint would never be read, because it is not in the right language (which would be French, of course). Les resten av dette innlegget »

Mass killing Oracle connections

4. februar 2013

If you have started to run out of connections due to some rogue program running wild, hanging your connections, you might need to kill a session or two. This is how to achieve this Les resten av dette innlegget »

When OS X refuses to remember your (Enterprise) WPA passwords

26. september 2012

Due to a password policy at work, we need to change the password for our Enterprise WPA network quite often. Unfortunately this has surfaced some weird bug in OS X, where it will prompt me for my password each time I log on the network, even though I can see it has been stored correctly in the Keychain. Got some tips from this post on the Apple Discussion forums, but it was not sufficient for me to get it working. I therefore present you the full five steps needed to fix this (at least in my case):

  1. Turn off Airport while doing this
  2. Open your Keychain (just search for «Keychain» in Spotlight) and remove the password associated with the WIFI you are having problems with
  3. Open Networks, press «Advanced» and remove your network from Airport
  4. Without closing the Advanced windows, open the tab marked «802.1X». This was the missing (crucial) step for me to get it working.
  5. Turn on Airport again, choose your network, and type in your username and password.

Hopefully you will no longer be prompted for your network password again!

Absolute file path function for Bash shell scripts

19. juni 2012

An often wanted function when writing shell scripts is one that when given a file or directory, returns the absolute file path of the file. Googling for this will return many results, but few that are cross platform compatible. For instance will a search often bring up use of readlink, but this is not useful on BSD systems (such as Mac) and will thus only (?) work on Linux.

One solution that was both elegant, uncomplicated and works on all bash systems, was found on LinuxQuestions. This will probably only work in Bourne style shells, but is easy to read and reuse:

function abspath {
	if [[ -d "$1" ]]
		pushd "$1" >/dev/null
		popd >/dev/null
	elif [[ -e $1 ]]
		pushd $(dirname $1) >/dev/null
		echo $(pwd)/$(basename $1)
		popd >/dev/null
		echo $1 does not exist! >&2
		return 127

I have included it in my shell function library on GitHub.

Review: A Song of Ice and Fire

4. mars 2012

A Song of Ice and Fire
A Song of Ice and Fire by George R.R. Martin
My rating: 4 of 5 stars

Sum up: A complex plot with intriguing characters and unexpected twists made me race through the first book in the course ofna few days (and late nights). The formula is getting a bit repetitive by the second book, the prose somewhat limited in expression, and my willingness to spend time on the third book was nowhere near the eagerness I felt after finishing the first book. Not bad by any means, but the author has a harder time keeping my interest after 2000 pages. I would definitely recommend the first book.

This review is made on the basis of the two first books – not the entire series (which is not completed), nor the set of four books. Will read the rest as the HBO series progress beyond season two.

The author keeps us in suspense, throws unexpected twists at us when we are least expecting it, and keeps us humoured by the likes of Tyrion and Varys. I’m thoroughly entertained, quite simply. The way the characters are slowly being built up to form people we start caring for (in some way), is what sets it apart from other series. Unfortunately they never live for long…

The series/ is by no means without its flaws; the prose is awkward and feels unnatural. I believe there is ample room for a presentation of ancient worlds in a modern day language. To me it feels as if the author is leaning too much on the heritage of Tolkien. The
Going directly from book one to book two, there were also quite a few annoyances that struck me: for one, the writing style of book two differs from book one. The most nagging irritation is that Martin insists on spelling every character’s thought out for us, however simple it might be to retrieve from the context. Another thing is the constant reminders of what happened in the previous book – few would read the second volume if they never read the first.

But these are minor complaints: this is not great literature, but great entertainment it definitely is. I would recommend this series to anyone that is in need of a thrilling and entertaining read. It has a heavy page count, but other than that it is smooth sailing all the way to King’s Landing.

View all my reviews

[OS X] Better battery life while on the road.

10. februar 2012

After being annoyed for the last year that my MacBook Pro was eating up my battery life while in hibernation, I finally chose to investigate the matter further. Several articles describe the pmset command (here is one), but to make a long story short I wrote a script that will let my Mac enter hibernation mode (suspend to disk) immediately, without altering the settings (permanently at least).

I uploaded it to pastebin to increase the chances of it being spread. Link.

It should be pretty self explanatory, but to sum it up it does the following:

  1. Back up your existing hibernation settings
  2. Sets new ones that will suspend to disk and then cut power (not keeping any power to RAM)
  3. Hibernates (and shuts off)
  4. On power on, it restores the previous settings

If you find it useful, drop me a comment. Maybe I could make this into a small systray utility some day if someone finds it useful.

Clean SOAP output with tcpdump

14. desember 2011

I often have to resort to tcpdump to debug the input and output to production services consuming SOAP messages. The problem with tcpdump is that the ASCII output is littered with binary garbage at the start, and this makes it a rather laborious thing to clean up. The following article is a description of some scripts, along with the source code, that cleans up the output. Les resten av dette innlegget »

Counting occurrences of a word matching a regex

14. desember 2011

This is a brief code snippet showing how to use command line tools to count the occurences of words matching a regex. In the following example, I am trying to list all the unique hits on the urls from the apache access log matching «/chart». Les resten av dette innlegget »

Matching Java method signatures with sed

10. november 2011

In the process of removing PMD warnings from our main product at work I was trying to automate some parts of this process by using sed (Stream EDitor), a command line program common on all Unices (such as OS X and Linux). I had already been using a regex in Vim to do remove final modifiers from methods on a file by file basis, but thought it might be quicker to do this using «find» and «sed» in stead. Boy was I wrong 🙂 But mainly just because of the different regex dialect of sed that took me a long time to figure out.

The problem was mainly due to trying to match square brackets, such as in «final public int[] myMethod(int[] args)». Les resten av dette innlegget »

[Java] Solving the case of IllegalCharsetNameException: «UTF-8»

2. november 2011

Have you specified file.encoding as a parameter to the JVM, but ended up getting an unexpected startup exception instead? Here is what caused it and how to fix it.
Les resten av dette innlegget »