trace file access on OSX

OSX contains some tools for system level analysis originally developed for Solaris – one of them is opensnoop.
The tools’ descriptions can be found here: http://www.brendangregg.com/dtrace.html

using python to set mp4 tags from a csv file

using python to create the lengthy AtomicParsley calls described in the last post:

<br />
#!/usr/bin/python<br />
import csv<br />
import pipes<br />
import StringIO</p>
<p>#metadata.csv has to contain the following rows:<br />
#filename, show, season, episode, title, artwork, description<br />
csvfile='metadata.csv'<br />
csvreader = csv.reader(open(csvfile, 'rbU'), delimiter=',', quotechar='&quot;')</p>
<p>class Command:<br />
	def __init__(self, file):<br />
		self.command = StringIO.StringIO()<br />
		self.command.write('AtomicParsley ')<br />
		self.command.write(pipes.quote(file))<br />
	def addParam(self, key, value):<br />
		self.command.write(' --')<br />
		self.command.write(key)<br />
		self.command.write(' ')<br />
		self.command.write(pipes.quote(value))<br />
	def toString(self):<br />
		return self.command.getvalue()<br />
	def close(self):<br />
		self.command.close()</p>
<p>def handleFile(row):<br />
	m4vfile = row[0]<br />
	show = row[1]<br />
	season = row[2]<br />
	episode = row[3]<br />
	title = row[4]<br />
	artwork = row[5]<br />
	description = row[6]<br />
	episodeCode = season + '' + str(episode).zfill(2) ##leading zeroes</p>
<p>	command = Command(m4vfile)</p>
<p>	command.addParam('artist', show)<br />
	command.addParam('title', title)<br />
	command.addParam('album', show + ', Season ' + season)<br />
	command.addParam('artwork', artwork)<br />
	command.addParam('stik', 'TV Show')<br />
	command.addParam('description', description)<br />
	command.addParam('TVShowName', show)<br />
	command.addParam('TVEpisode', episodeCode)<br />
	command.addParam('TVEpisodeNum', episode)<br />
	command.addParam('TVSeasonNum', season)</p>
<p>	print command.toString()<br />
	command.close()</p>
<p>for row in csvreader:<br />
	handleFile(row)</p>
<p>

set meta data in MP4 (m4v) files

you can use AtomicParsley, a command line based open source tool to add metadata and artwork to your MPEG-4 files. On OS X you can use macports to install the tool.

example for an AtomicParsley call:
AtomicParsley 'Simpsons - Chili.m4v' --artist Simpsons --title 'Homer and the Chili' --album 'Simpsons, Season 6' --artwork Simpsons.jpg --stik 'TV Show' --TVShowName Simpsons --TVEpisode 605 --TVEpisodeNum 6 --TVSeasonNum 5 --description 'Homer attends a hot chili competition.'

convert from AVI to MP4 (M4V)

M4V is just an alias for MP4.
So you can use ffmpeg to copy the audio/video streams in your AVI file to a more recent MP4 container:

ffmpeg -i source.avi -f mp4 -vcodec copy -acodec copy destination.mp4

install Sun Java on Ubuntu

add-apt-repository "deb http://archive.canonical.com/ lucid partner"
apt-get update
apt-get install sun-java6-jdk
update-alternatives --config java

new Java Decompiler

Everybody working with Java has met JAD some time sooner or later.
Unfortunately JAD is pretty old, has no GUI and cannot handle Java 5/6 bytecode.

Now there’s a new player in town – you can directly open JAR archives in its nice GUI:
http://java.decompiler.free.fr/?q=jdgui

Audi/e.solutions on CES 2011, Las Vegas

There are many articles about Audi on CES, I think this is one of the best:
http://www.golem.de/1101/80597.html (german)

By the way: e.solutions is Audi’s joint venture to develop the new MMI infotainment system for the next A3 in 2012.

Xmas holiday project: PowerNap

I’ve wanted to implement a fully integrated Java based OSX tool for a while, during Xmas holidays I finally got to it: PowerNap.

PowerNap puts your computer to sleep after a given amount of time. Available for OSX and Windows.

PowerNap screenshot
featuring a design of my favourite web specialist :*

Sourcecode also available via GoogleCode.

Snap/Align windows on OSX (like Win7 does)

If you miss the Win7 way of aligning windows by pushing WinKey + ArrowKey on OSX, there’s help: https://github.com/fikovnik/ShiftIt

Just press ctrl+alt+cmd and a Arrow key and your windows will be arranged as you are used to.

Best of all: It’s free.

php :: check if person is adult


function isAdult($birthyear, $birthmonth, $birthday)
{
$birthdayTime = mktime(0, 0, 0, $birthmonth, $birthday, $birthyear);
$now = time();

$ageSeconds = $now - $birthdayTime;
$years = $ageSeconds / 3600 / 24 / 365.25;

return $years >=18;
}

if(isAdult($year, $month, $day))
{
echo "your adult! feel free to buy guns.";
}
else
{
echo "goto kindergarden!";
}