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 »


Sjelen må få tid til å flytte inn i klærne

6. oktober 2011

Bilde av en moderne bunadsvariant

Var på en fin visning av Hansen i Norwegian Rains/T. Michaels lokaler i dag. Hansen (ved sjefsdesigner Åse Helen Hansen) har en karakteristisk stil som føles veldig dansk; naturmaterialer, god kvalitet, ikke strengt, men deilig og ledig å ha på. Kanskje en effekt av flere års utlendighet i Danmark? Det skal sies at Åse er ekte bergenser – på lik linje med Silje og Aleksander som driver butikken i Kirkegata – en butikk som er det nærmeste man kommer bergensbølgen i tekstilform. (Aleksander Helle har faktisk leflet med tanken på å utvide butikken til en showcase for noe mer enn bare bergenske tekstiler. Kanskje et eget Tellé Records-hjørne ville gjort seg?)

Klær produsert med ull fra Gudbrandsdalen eller restpartier av engelsk høykvalitets tweed fra en ære som lengst er forbi blir naturligvis ikke billig. På den annen side er mange av klærne nærmest for investeringer å regne; kvaliteten er så god at man kan regne med å ha dem i år etter år. I samtale med Åses danske kjæreste om hvordan virkelig gode klær blir ens favorittøy med tiden, kom det utsagnet som fikk synapsene mine til å fyre av som et fyrverkeri:

Det er viktig at (…) sjelen må få tid til å flytte inn i klærne.

Jeg likte det så godt at jeg bare måtte få det ut – noe dette innlegget bare er en dårlig unnskyldning for :)


Infinitest in IntelliJ

5. oktober 2011

We had TDD guru Johannes Brodwall deliver a workshop on TDD and refactoring for my company last Friday, and that prompted me to (yet again) try to get Infinitest working in IntelliJ. Today I managed to get it working, but it was certainly not thanks to the non-existing documentation!

The key missing part of getting it working after installing the plugin through the IntelliJ plugin wizard is to enable the Infinitest facet for your project. Right click on the project, choose facet, add Infinitest and voila! You now have a new tab called Infinitest.


Getting a Chrome Offline Installer for another OS

29. september 2011

Due to some restrictions at work, we need to install software via USB and not by direct download. The problem is that when trying to get the Chrome Offline Installer it seems virtually impossible to download it for another os.

There are links for other operating systems, but these lead to the online installers. Duh! Fortunately I found a trick by looking at the URL generated for the online installer, where I saw that two parameter that could be used to select the right version:
platform and hl.

Example url: http://www.google.com/chrome/eula.html?standalone=1&platform=win&hl=no

The url above would select a standalone (offline) installer for Windows where the language version would be Norwegian. Cool,huh?

Platform choices are: “mac”, “win” and “linux


[OS X] Dial-up using Bluetooth on SE C702

14. september 2011

I recently lost my iPhone and so I was back to my trusty, old Sony Ericsson C702. Far from fancy, but it works and I can use it for far longer than I ever could with my iPhone without charging. But I sometimes need on-the-road access to the internet, and now I kneed to do that using C702, which is what this post concerns. Les resten av dette innlegget »


Getting the IP of a SaMBa server or Windows machine

6. september 2011

At times my server gets a new ip from my router, thus rendering my hosts file invalid and generally making life less pleasant. So in order to get contact with the server again, I need to get the IP. This is where nmblookup comes in.

Simply type
nmblookup name-of-the-machine
(where name-of-the-machine obviously is the samba configured name) will pop out a result like this
querying name-of-the-machine on 192.168.10.0
192.168.10.114


[Java] Checking for null values quickly

7. juni 2011

Thought I might share a little favorite code snippet that I like to use. It is quite useful if you need to check that a long list of variables do not contain any null variables, for instance as validation at the start of a public method. It makes use of the varargs version of Arrays.asList(Object …) and List.contains() and is for instance used like this:

if (asList(foo, bar, baz, fooFoo, fooBar, fooBaz, barFoo, barBar, barBaz )
           .contains(null)) {
    throw new IllegalArgumentException("No objects are allowed to be null");
}

Here I have used static imports to be able to simply write asList() instead of Arrays.asList(). Hope it turns out useful for someone :)


Follow

Get every new post delivered to your Inbox.

Join 68 other followers