rblog

From Lindesnes to Nordkapp with bicycle V

Yesterday was my fiftieth time going to work with my bike this year, and also the fifth leg on my virtual trip to Nordkapp from Lindesnes. I have now arrived at Arnes in Ballangen. Apparently not the place to be, since the only thing I have been able to find out about the place using Google is…the weather forecast at Yr.no.

On my way to work, just as I have passed E18 using the footbridge close to the Opera I have taken picture of graffiti with a message. “Utrydd bananflua!” – “Exterminate the fruit fly

Bash – Insert content of one file into another file

Had to insert a XML-snippet into another XML-file at a given location in a Bash-script. Reading the snippet into a variable is quite easy, just by using cat. The trouble was how to find the tag to replace most efficiently, then replace it with the xml-snippet. Learned that reading the file content using stdin/stdout in a bash-script can cause side effects not easy to figure out, so that was no option. Instead I first tried to use sed, but sed had problems with the fact that the content of the snippet is XML-code. So instead with good help from Geir we ended up using Perl, which made it all very simple – everything done in just 2 lines of code.

First it searches for <!– END jaas –> then replaces the string with the content of the snippet variable and lt;!– END jaas –>

value=$(cat jaas_snippet.xml)
perl -pi -e "s#<!--\sEND\sjaas\s-->#${value}\n\t\t<!-- END jaas -->#" jaas.xml

Comments:

  • Using # instead of ` – while struggling with XML in the variable $value
  • \s = whitespace, like \n is newline and \t is tab
  • Double quote’s so that perl uses the value of the variable, and not just reads it as plain text
  • In this case we expect only one occurrence of the end-tag, so we have skipped the /g parameter at the end of the search-string. /g meaning global, compared to for instance the usage described in my previous blog post at WPC.

Perl is power!

Heavy duty protection for my cell phone

Got my Otterbox Defender Case here the other day. Superb protection for my phone, makes it waaaay more shock resistant, and also makes it water resistant. Note – not waterproof, just water resistant, but it cover my needs. I have a waterproof bag for moments when the going gets really tough (Birkebeinerrittet last year for instance).

I have access to all features of the phone without problems, loving it!

How to exclude files when using ls

Had a directory with > 150 *.properties-files and needed to check if there where any files not ending with .properties. ls lists all the files, combine it with grep and you are saved.

# See all files ending in .html
ls | grep “\.html$”
# see all files not ending in .html
ls | grep -v “\.html$”

Solution found at unix.com

Cycling season 2010 has started for real

Last Wednesday was my first bike ride not going to work. With my single speed bike I headed for Vestreng in +2, rain and occasionally strong headwinds. And when average speed is limited to about 20 km/h I was quite cold after 48 km. Got to shorter rides as well on Thursday and Friday, but with small changes in the weather it was not pleasant at all.

Yesterday I mounted my Thule rack, together with the summer tires, so now the car is ready for yet another cycling season.

Yesterday evening I mounted brand new SPD pedals (the old ones are on my commuter bike) and a new Selle Italia SLR bike saddle. Needed a new saddle since the old one soaked up water if it was raining hard, reason – to soft, who needs a soft saddle?

And today Espen and I enjoyed the nice weather and was out together for about two hours. Had a nice ride to Lillestrøm, via Skedsmokorset, Hellerudsletta and back home. Here we have a short brake nearby Hellerudsletta.

Summer tyres in winter

Yesterday I had planned to change to summer tyres, but did not find the time, but Lars Tormod did. Woke up this morning as saw this out of the kitchen window. Must admit this is one day I’m quite happy I was lazy the day before. Guess Volvo-driving is not the best thing to do today 🙂

Found a video on Youtube showing why not to use summer tyres on snow

[video:youtube:rFODBAr5q7M]

Link

Band of Brothers – tv mini-series

Finally finished all ten episodes of Band of Brothers and what a serie. A monumental documentation of Easy Company and their struggles from the D-Day until the end of WW2. Really enjoy how you get to know each one of the men, each episode have short interviews of men from Easy before it starts. Must also say that the last episode with the ending with one of them telling a story about a grandson asking grandpa if he was a hero in the war. “No, but I fought with a company of heroes!”. One of them being Major Dick Winters for sure!

A must see, again and again – like Generation Kill, another great HBO series. Also exited about the new series The Pacific, wondering if it will be as good as Band of Brothers and Generation Kill.