rblog

Regex in Groovy: Match characters and some special ones

I’m writing a script that validates a file with key/value-pairs. One type of a valid value is a JNDI-name. Before the actual name it is also a whitespace. So my if-statement with the regex validating ended up like this

currentLine ==~ /^.*=\s+[A-Za-z0-9\/-]+/

To explain it:

  • ==~ means validate true/false, see http://groovy.codehaus.org/Tutorial+4+-+Regular+expressions+basics
  • Then the regex starts and ends with a forward slash
  • ^.*= means match lines with text containing any type of character ending with an equal sign (the keys)
  • \s+ means match one or more whitespaces. Should really just need to verify one and only one, but what the heck…
  • [A-Za-z0-9\/-]+ is a character class saying match all uppercase letters, all lowercase, all numbers and also forward slashes and hyphens. Some of the names have hyphens so I needed that one to. The + sign at the end says “one or more occurences”, see the heading “Regular Expression Operators” found on the above mentioned link

Paternity leave done

First day at work after ten weeks of paternity leave. Promised myself “No more cakes, waffles and such”. But since my boss instructed me to follow the rest of my department I had no other option than to follow and do my duty! “Vaffelsmell”

Remote support done easy

Needed an application to help me do remote support on my old pc now running Ubuntu which I’m about to send home to my little sister. Well aware of the fact that Linux and Ubuntu might be a giant step for mankind home at Nesna, I was on the lookout for an app that could help me out. Lars Tormod have used Teamviewer with success giving remote support to his dad, so I tested it out. Installed both on my Mac and on the Ubuntu pc in less than five minutes (including download). Started Teamviewer on the pc, got the session id, started same app on the Mac – entered session id and password…voila, full control of the Ubuntu pc…plain and very simple and easily recommended to others. Free for personal use as well, can it be better?

Upgraded blog to B2Evolution 4.0.5

Yet another successful and easy upgrade, now running 4.0.5 of B2Evolution. Had to spend some time uploading the files to the server due to very limited bandwidth this evening, but apart from that, no problems. Also used WinScp to move the media-folder on the server before upgrade and then move it back, in that way I could delete files and upload a fresh copy afterwards.

Back on track again after hosting server being hacked

Yet again http://hellem.org is up and running again after the hosting server was hacked last weekend. No real issues for me apart from a few days of not bothering to update my blog until they had fixed the security hole and rolled back to the needed backup. As I know they did not do anything other than change all index files as described here http://www.webhostingtalk.com/showthread.php?t=546049.

Anyhow, I had a backup of my blog, did not loose any information, also thanks to an exact local copy of my folders and files.

Bash: Loop a comma separated list

Just perfect!


######VARIABLE DEFINITIONS#######
LIST=1,2,3,4,5
#################################

# Add a trailing comma to the list variable
LOOPVAR=${LIST},

# Loop as long as there is a comma in the variable
while echo $LOOPVAR | grep \, &> /dev/null
do

# Grab one item out of the list
LOOPTEMP=${LOOPVAR%%\,*}

# Remove the item we just grabbed from the list,
# as well as the trailing comma
LOOPVAR=${LOOPVAR#*\,}

# some action with your variable
#
# echo $LOOPTEMP
#
# for example

done

Thanks to “The Code and the Fury” for providing the script, see the blog post for more details about how the script actually works.

Want safer surfing at home?

I’m now testing OpenDNS at home. You get

  • Web Content Filtering
  • Anti Phising
  • Malware protection
  • Whitelist/Blacklist
  • Block P2P, and more…

Have not noticed any drops in speed. Ok, a ping to the DNS server of OpenDNS is slower than to my “real” DNS, but that does not tell the whole story, since you do not surf on pages hosted on your DNS-server. It might also depend on the size of the DNS-cache on the server…have I been told…

A bit confused when it comes to verifying if I’m really using OpenDNS using the webpage http://www.opendns.com/welcome/ but it all turned out to be a need to just restart Firefox combined with a few minutes of waiting time.

Router firmware upgraded

My brother and sister are visiting us this weekend and while my brother is playing some online game I was checking the web console on my WRT54GL for ways to block the gaming. That was when I noticed that my firmware version was 4.30.7, and the latest was 4.30.15…so I decided that it was time to upgrade. Quite easy in fact, just verify hardware version, then download the .bin-file and upload it using the web console. Should work like a charm I my thought was, but nope…”Upgrade failed”, back to the manual. Noticed “Use Internet Explorer or Safari”, I was using Firefox. Fired up Safari, and tried again, about 20 seconds and “Upgrade Successful”, which also included a reboot causing my brother cursing…double success! 🙂

Hjem