rblog

Linux – find files older than 24 hours

Something that easy turned out to be pretty hardcore

Take the file modification time in seconds and subtract the start time of the find program. This is the number of seconds in the past that the file was modified. Now divide by 86400 and discard any remainder. This is the number of days ago (as computed by the find command) that the file was modified. So the result you see is the expected result. You want:
-mtime +0

Solution found here www.unix.com/…/..problem-find

Blog upgraded to latest version 4.1.2

Have spent some hours upgrading from 4.0.5 to 4.1.2. But note that the actual process of upgrading did not take more than an hour or so, most of the time spent uploading new files using FTP-client Filezilla. Since it had to check each file “if newer” it takes some extra time. But the actual work of upgrading took only five minutes or so.

But, yesterday I spent some hours creating a script that helped me change from the Youtube-plugin which is no longer being developed to the “out-of-the-box” video plugin.

As usual I found a script helping me almost all the way, thanks to Stackoverflow.com, but I had to fine-tune it to my needs.

First, I had to create a SQL-statement that selected all blog posts containing the tag [youtube], but also the post_render column since the video-render plugin was changed.

$sql = "SELECT post_ID, post_content,post_renderers FROM evo_items__item WHERE LOCATE('[youtube]',post_content) != 0";

Then later in the script when doing the actual work, removing the old tag replacing it with the new

$post_content = preg_replace('#\[youtube\](.*?)\[/youtube\]#', '[video:youtube:$1]', $post_content);

The regex is searching for the [youtube][/youtube]-tag, crabbing the content of it (.*?) and backreferencing it to create the new tag.

And then at last adding the post_render for the new plugin, check that it does not exist already.

$pos = strpos($post_renderers,'.evo_videoplug');

	if($pos === false) {
	 	$post_renderers = $post_renderers . ".evo_videoplug";
	}

One liner: Adding files to svn

List all files needed to be commited into Subversion, then grep only files not added, this being lines starting with question mark. The ‘^\?’ means

  • ^ = line start
  • \ = escape next charater
  • ? = The character to search for, since ? is a metacharater in Regex, it must be escaped.

Then using awk print the file path and name and at last using xargs and svn add – add the files to svn.

svn status | grep ^\? | awk '{print $2}' | xargs svn add

Finally I bother to do it…WEP to WPA

I have known it for a long time, I should have done it a long time ago, but still, needed to see http://www.nrk.no/programmer/tv/brennpunkt/1.7848190 (Nettverk i offentlige miljøer er lette å hacke) before actually changing from WEP to WPA2…

Using WEP really is nothing more than a keylock made of plastic.

IBM WebSphere Technical Conference 2011 in Berlin

I’ve spent a few days in Berlin attending the IBM WebSphere Technical Conference. While walking down the streets I saw this poster of Petterson and Findus which I first thought was written by a Norwegian, but it turns out to be Swedish.

Staying at a hotel close to the Deutsche Oper Berlin, off course they had to have pictures like this on the wall in the rooms. No idea what so ever which opera this is from…

Tuesday, dinner at the Fernsehturm, nice view and pretty good food as well.

Me at the conference on Wednesday preparing for the session me and Geir would have talking about Telenor and Rational Automation Framework.

Moon above Bismarckstraße.

At the Genazvale restaurant, serving food from Georgia. Me just about to try out the kebab, served on this giant spear totally hiding Geir. If ever going to Berlin, I would recommend a visit to this place.

Kindzmarauli, sweet wine from Georgia.

Giant colored balls at Ernst Reuter Platz

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”