<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tadek's Blog &#187; Progs/Tools/Libs</title>
	<atom:link href="http://tadek.pietraszek.org/blog/category/programstools/feed/" rel="self" type="application/rss+xml" />
	<link>http://tadek.pietraszek.org/blog</link>
	<description>Some random notes about computers, security, cool links and others.</description>
	<lastBuildDate>Fri, 12 Dec 2008 22:49:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Finding top-N items in a stream</title>
		<link>http://tadek.pietraszek.org/blog/2007/07/04/finding-top-n-items-in-a-stream/</link>
		<comments>http://tadek.pietraszek.org/blog/2007/07/04/finding-top-n-items-in-a-stream/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 21:22:53 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Progs/Tools/Libs]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2007/07/04/finding-top-n-items-in-a-stream/</guid>
		<description><![CDATA[How to (approximately) generate a top-N items list without counting the number of occurrences of all instances?
Two interesting papers I found on the topic: http://citeseer.ist.psu.edu/charikar02finding.html and http://citeseer.ist.psu.edu/jin03dynamically.html. I also somebody&#8217;s seminar powerpoint presentation explaining it.
]]></description>
			<content:encoded><![CDATA[<p>How to (approximately) generate a top-N items list without counting the number of occurrences of all instances?
Two interesting papers I found on the topic: <a href="http://citeseer.ist.psu.edu/charikar02finding.html">http://citeseer.ist.psu.edu/charikar02finding.html</a> and <a href="http://citeseer.ist.psu.edu/jin03dynamically.html">http://citeseer.ist.psu.edu/jin03dynamically.html</a>. I also somebody&#8217;s seminar <a href="http://www.math.tau.ac.il/~haimk/seminar03/FindingFrequentItemsInDataStreams.ppt">powerpoint presentation</a> explaining it.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2007/07/04/finding-top-n-items-in-a-stream/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Adding custom firewall rules in OSX</title>
		<link>http://tadek.pietraszek.org/blog/2007/05/01/adding-custom-firewall-rules-in-osx/</link>
		<comments>http://tadek.pietraszek.org/blog/2007/05/01/adding-custom-firewall-rules-in-osx/#comments</comments>
		<pubDate>Tue, 01 May 2007 17:57:53 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Progs/Tools/Libs]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2007/05/01/adding-custom-firewall-rules-in-osx/</guid>
		<description><![CDATA[Having extensively used Linux before I found GUI configuration of OSX firewall somewhat lacking. In particular, I wanted to limit outgoing access to some IP addresses (but I can imagine you may want to play with other things as well).

I found that I could buy Flying Buttress which should allow me to do this, but [...]]]></description>
			<content:encoded><![CDATA[<p>Having extensively used Linux before I found GUI configuration of OSX firewall somewhat lacking. In particular, I wanted to limit outgoing access to some IP addresses (but I can imagine you may want to play with other things as well).</p>

<p>I found that I could buy <a href="http://personalpages.tds.net/~brian_hill/flyingbuttress.html">Flying Buttress</a> which should allow me to do this, but I really don&#8217;t need a graphical ipfw frontend, especially the one I&#8217;d have to pay for <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  All I needed was to write some ipfw rules and make them persistent.</p>

<p>Here&#8217;s what I did:</p>

<pre><code> mkdir /Library/StartupItems/CustomIPFWRules
 cd !$
</code></pre>

<p>Created a file called <code>StatupParameters.plist</code> containing:</p>

<pre><code>{
  Description     = "Custom Tadek's IPFW Rules";
  Provides        = ("CustomIPFWRules");
  Uses            = ("Network");
}
</code></pre>

<p>Created a file called <code>CustomIPFWRules</code> (the name has to match the directory name) containing a simple shell script:</p>

<pre><code>#!/bin/sh

. /etc/rc.common

case "$1" in
        start)

        ConsoleMessage "applying tadek's ipfw rules"
        ipfw add 2045 deny tcp from any to "ip_I_want_to_block" out
        ;;
esac

exit 0
</code></pre>

<p>Voila!</p>

<p>BTW: a <a href="http://www.macdevcenter.com/pub/a/mac/2005/03/15/firewall.html">useful link on playing with Firewall in OSX</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2007/05/01/adding-custom-firewall-rules-in-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Recovering deleted photos &#8211; my experiences</title>
		<link>http://tadek.pietraszek.org/blog/2007/01/04/recovering-deleted-photos-my-experiences/</link>
		<comments>http://tadek.pietraszek.org/blog/2007/01/04/recovering-deleted-photos-my-experiences/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 00:07:48 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2007/01/04/recovering-deleted-photos-my-experiences/</guid>
		<description><![CDATA[
(playing with the camera) Cool. You can change the format of the CF card&#8230; Whops&#8230;.
My CF card got corrupted.
The photos I thought had been already uploaded to the gallery were deleted from both the CF card and the harddisk. Moreover, I already took 50 photos on the CF card after reformatting it.


Time and time again, [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>(playing with the camera) Cool. You can <strong>change</strong> the format of the CF card&#8230; Whops&#8230;.</li>
<li>My CF card got corrupted.</li>
<li>The photos I thought had been already uploaded to the gallery were deleted from both the CF card and the harddisk. Moreover, I already took 50 photos on the CF card after reformatting it.</li>
</ul>

<p>Time and time again, I realize how precious my photos are, only after they are gone. The last time they were my PhD defense photos&#8230; Auch. Fortunately, they are gone, but not forever <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>You will find several tools for photo recovery on Google, but most of them either commercial or give you a only a &#8220;free preview&#8221;. Thinking about it, it&#8217;s a very good business model: people are very willing to swipe their card if they can see that they get their photos back. Should have written one as well <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Fortunately, there are also free ones, two of them I tried by myself.</p>

<p><a href="http://www.pcinspector.de/smart_media_recovery/welcome.htm">PC Inspector Smart Recovery</a> is an excellent and easy-to-use Windows application for photo recovery. It is extremely easy to use and does an amazing job. It is also completely free, but I think is fair to reward the author with a PayPal donation.</p>

<p><a href="http://www.cgsecurity.org/wiki/PhotoRec">PhotoRec</a> is a cross-platform program for photo recovery. In fact, it runs on Dos/Windows/Linux/BSD/Solaris/MacOSX, which is really impressive. It also supports a whole range of filesystems, including FAT/NTFS/Ext2/3/HFS+. It has a simple (n)curses based interface, which is a bit of a disappointment in the age of cool animated GUIs, but it&#8217;s also relatively easy to use. Also, it has an impressive range of configuration options. And it works on Linux and my Mac. I no longer need Windows! Simialrly, the program is really free (including the sourcre) and you can rewerd the author with a donation.</p>

<p>Both tools worked for me smoothly and (unlike some other commercial ones I tried which ran out of memory) managed to recover almost one thousand photos from my 4GB CF card, including the wanted defense photos <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I don&#8217;t know which of the tools is better and I recommend both (although I would lean slightly towards the PhotoRec as I don&#8217;t have Windows anymore). Also, if you don&#8217;t get what you&#8217;re looking for, you can try both of them (as a rule all image/disk recovery tools are read-only so you can try all of them many times with no risk).</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2007/01/04/recovering-deleted-photos-my-experiences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two friends: GeoWebStats and GeoBroStats &#8211; visualizing Apache and Bro logs with Google Maps</title>
		<link>http://tadek.pietraszek.org/blog/2007/01/02/two-friends-geowebstats-and-geobrostats-visualizing-apache-and-bro-logs-with-google-maps/</link>
		<comments>http://tadek.pietraszek.org/blog/2007/01/02/two-friends-geowebstats-and-geobrostats-visualizing-apache-and-bro-logs-with-google-maps/#comments</comments>
		<pubDate>Tue, 02 Jan 2007 14:35:33 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2007/01/02/two-friends-geowebstats-and-geobrostats-visualizing-apache-and-bro-logs-with-google-maps/</guid>
		<description><![CDATA[One of my pet (a.k.a. procrastination) projects has been to visualize my server logs using Google Maps. In fact, this has been my &#8216;procrastination hub&#8217; giving me excuses to work on a variety of pet projects, including:


playing with Bro and packaging Bro for Debian
playing with Apache logs and importing them to the relational database
playing with [...]]]></description>
			<content:encoded><![CDATA[<p>One of my pet (a.k.a. <a href="http://www.thefreedictionary.com/procrastination">procrastination</a>) projects has been to visualize my server logs using <a href="http://maps.google.com">Google Maps</a>. In fact, this has been my &#8216;procrastination hub&#8217; giving me excuses to work on a variety of pet projects, including:</p>

<ul>
<li>playing with <a href="http://bro-ids.org">Bro</a> and packaging Bro for Debian</li>
<li>playing with Apache logs and importing them to the relational database</li>
<li>playing with Bro logs and importing them to the relational database</li>
<li>learning Python and Javascript</li>
<li>playing with Google Maps</li>
<li>writing a web application to visualize the collected logs on Google maps</li>
<li>creating a webpage documenting all the above.</li>
</ul>

<p>As with procrastination projects, they are by definition never complete. I do have something working now, and you can see it in action (works best in a <a href="http://www.mozilla.com/en-US/firefox/">decent browser</a>, but should show something in IE as well).</p>

<h3>GeoWebStats</h3>

<p>Visualizing Apache logs on a webpage. Here are three links (it might take a while to load them for the first time, so please be patient):</p>

<ul>
<li><a href="http://plum.ibao.net/webstats/?vhost=tadek.pietraszek.org&amp;regexpmatch=%2Fblog&amp;regexpnomatch=%2Fblog%2Fwp-%7C%2Fblog%2Ffeed&amp;cutoff=10&amp;start=-7&amp;cc_locked=vhost%2Cregexpmatch%2Cregexpnomatch%2Cstart%2Cend%2Cstriplevel&amp;cc_hash=6049f98622a55ac5cb3b87dd535820d0&amp;submit=1">Blog  Visitors &#8211; last 7 days</a></li>
<li><a href="http://plum.ibao.net/webstats/?vhost=gallery.ibao.net&amp;regexpnomatch=%5E%2Fd%2F%5B0-9%5D%2B%7C%5E%2Fc%2F%7C%5E%2Findex.php%7C%2Ffavicon.ico&amp;cutoff=5&amp;start=-7&amp;cc_locked=vhost%2Cregexpmatch%2Cregexpnomatch%2Cstart%2Cend%2Ccutoff%2Cstriplevel&amp;cc_hash=e5366f30cae72af7a33f166394e96bc6&amp;submit=1">Gallery Visitors &#8211; last 7 days</a></li>
<li><a href="http://plum.ibao.net/webstats/?vhost=tadek.pietraszek.org&amp;regexpnomatch=%2Fblog%7C%2Ffavicon.ico%7C%5E%2Fimages&amp;striplevel=2&amp;start=-7&amp;cc_locked=vhost%2Cregexpmatch%2Cregexpnomatch%2Cstart%2Cend%2Ccutoff%2Cstriplevel&amp;cc_hash=992cd263f64643edf909c6eea6a9624e&amp;submit=1">Homepage Visitors &#8211; last 7 days</a></li>
</ul>

<p>The script is quite customizable (for example you can specify the regular expressions you want to filter on, group stuff) but for security resons those demo links are locked.</p>

<h3>GeoBroStats</h3>

<p>Simiarly to GeoWebStats, GeoBroStats visualizes raw TCP/UDP conections based on Bro conection summaries (this might also take a while to load):</p>

<ul>
<li><a href="http://plum.ibao.net/brostats/?service=smtp&amp;cutoff=10&amp;start=0&amp;cc_locked=service%2Cport%2Cstate%2Ccutoff%2Cstart%2Cend&amp;cc_hash=3f41b93fc42c40fe3d60920af7e207f5&amp;submit=1">Today&#8217;s SMTP connections that transfered 10kB+ (mostly spammers) </a></li>
</ul>

<p>The script is also quite customizable, but for security resons those demo links are locked.</p>

<p>Let me know what you think about it. I know that the user interface is very crude and needs some work. I have also almost finished GeoWebStat&#8217;s website, but knowing me, it will take a while <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2007/01/02/two-friends-geowebstats-and-geobrostats-visualizing-apache-and-bro-logs-with-google-maps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Polish keyboad on OSX &#8211; a rant</title>
		<link>http://tadek.pietraszek.org/blog/2007/01/02/polish-keyboad-on-osx-a-rant/</link>
		<comments>http://tadek.pietraszek.org/blog/2007/01/02/polish-keyboad-on-osx-a-rant/#comments</comments>
		<pubDate>Tue, 02 Jan 2007 12:31:11 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Progs/Tools/Libs]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2007/01/02/polish-keyboad-on-osx-a-rant/</guid>
		<description><![CDATA[I recently had to write some Polish text on my MacBook Pro and discovered that the Polish keyboard is messed up. In fact, coming from a PC world I&#8217;ve always thought Mac&#8217;s keyboards are messed up (e.g., lack of Home/End PageUp/PageDown, which can be simulated by some weird and application-dependent two/three key combination, an almost [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to write some Polish text on my MacBook Pro and discovered that the Polish keyboard is messed up. In fact, coming from a PC world I&#8217;ve always thought Mac&#8217;s keyboards are messed up (e.g., lack of Home/End PageUp/PageDown, which can be simulated by some weird and application-dependent two/three key combination, an almost completely useless Enter/Rename key, an annoying Eject key, which pressed accidentally generates an eject sound regardless whether you have something in your drive or not), but this time I got annoyed.</p>

<p>To give a bit of background, in Poland, we use nine additional letters, namely Ä™Ã³Ä…Å›Å‚Å¼ÅºÄ‡Å„ (and their uppercase counterparts) and historically typewriter&#8217;s keyboard had them allocated at the right side (where brackets and quotes are). Now, unless you&#8217;re a typewriter, this is not very useful (especially if you need the braces and quotes more often) and we have two Polish keyboard mappings: a typewriter&#8217;s keyboard and a programmer&#8217;s keyboard (with Polish letters generated with an Alt+&lt;Latin letter&gt;). As we have two z-derivatives: Å¼Åº one of them is Alt+z (the more common Å¼) and the other is Alt+x (the less common Åº).</p>

<p>Playing with my Mac I discovered that Å¼Åº are swapped. I am not sure if there&#8217;s any rationale for it (apparently it was ok in OS9 and only changed in OSX), maybe it&#8217;s easier to press Alt+x (which gives a more commonly used character), in particular that on a PC it&#8217;s a right Alt, not the left one (in fact, I was trying to get it to be more ergonimic, I would remap the right Enter to Alt), but I found it confusing. To get a feeling what it&#8217;s like, imagine what if Apple replaced a Control key with Enter or PageUp with an eject button. Whops&#8230; they already did it. Imagine something else then <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>Doing a bit of research I found discovered I am not the only one annoyed with it.  Somebody made a correct programmer&#8217;s keyboard and which can be downloaded from <a href="http://www.srebrnysen.co.uk/e4aws/downloads/files/poprawiona_klawiatura_programisty_dla_OSX_10.4_v1.4.zip">here</a>.
There are two versions: one replacing a system file and one installing a local keyboard for a user. I took the latter approach and it works great!</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2007/01/02/polish-keyboad-on-osx-a-rant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bro IDS &#8211; Debian Package</title>
		<link>http://tadek.pietraszek.org/blog/2007/01/02/bro-ids-debian-package/</link>
		<comments>http://tadek.pietraszek.org/blog/2007/01/02/bro-ids-debian-package/#comments</comments>
		<pubDate>Mon, 01 Jan 2007 22:51:22 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2007/01/02/bro-ids-debian-package/</guid>
		<description><![CDATA[I&#8217;ve been using bro for quite a while on my server and consider is a great IDS. Actually, I&#8217;ve been using it mostly as a network analysis tool (connection summaries, tracking HTTP connections, analyzing headers, etc.), rather than an IDS itself, but I still think it&#8217;s great.

What has been bothering me most this time is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://bro-ids.org">bro</a> for quite a while on my server and consider is a great IDS. Actually, I&#8217;ve been using it mostly as a network analysis tool (connection summaries, tracking HTTP connections, analyzing headers, etc.), rather than an IDS itself, but I still think it&#8217;s great.</p>

<p>What has been bothering me most this time is that my cleanly-installed server with a proper package manager (I&#8217;m running Debian and I am very happy about it, regardless what some friends of mine say) is running a <em>service</em> installed in my home directory in a screen. In fact, as the server&#8217;s uptime is on average half a year, it&#8217;s not such a big problem, but it really bothered me <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>Almost a half a year ago, I started Bro&#8217;s &#8216;Debianization&#8217; process, as one of my many procrastination projects (a.k.a. pet project), but I haven&#8217;t been active (maybe now that I defended my thesis I don&#8217;t need to procrastinate so much? <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ). Now during the Christmas break I finally managed to (almost) finish it!</p>

<p>The whole job turned out to be more difficult than I&#8217;d thought, but it works now. Here&#8217;s a proof:</p>

<p><pre><code>
tadekp@plum:~$ apt-cache show bro
Package: bro
Version: 1.1d-1
Priority: optional
Section: net
Maintainer: Tadeusz Pietraszek &lt;tadek@pietraszek.org&gt;
Depends: libc6 (&gt;= 2.3.2.ds1-21), libgcc1 (&gt;= 1:3.4.1-3), libncurses5 (&gt;= 5.4-1), libpcap0.7, libssl0.9.7, libstdc++5 (&gt;= 1:3.3.4-1), c-shell
Architecture: i386
Filename: ./bro_1.1d-1_i386.deb
Size: 3061038
Installed-Size: 8916
MD5sum: 880901a64a7fc44766e4645f445799a6
Description: Network Intrusion Detection System (NIDS)
 Bro is an open-source, Unix-based Network Intrusion Detection System (NIDS)
 that passively monitors network traffic and looks for suspicious traffic.
 .
 Bro detects intrusions by comparing network traffic against a customizable
 set of rules describing events that are deemed troublesome. These rules
 might describe specific attacks (including those defined by signatures)
 or unusual activities (e.g., certain hosts connecting to certain services
 or patterns of failed connection attempts).
 .
 Bro uses a specialized policy language that allows a site to tailor Bro's
 operation, both as site policies evolve and as new attacks are discovered.
 If Bro detects something of interest, it can be instructed to either generate
 a log entry, alert the operator in real-time, execute an operating system
 command (e.g., to terminate a connection or block a malicious host
 on-the-fly). In addition, Bro's detailed log files can be particularly
 useful for forensics.</p>

<p>tadekp@plum:~$ 
</code></pre></p>

<p><pre><code>
tadekp@plum:~$ /etc/init.d/bro status
Bro is running (pid: 2859)
Autorestart: ON
Running since: Mon Jan  1 16:11:37 CET 2007
Bro Version: 1.1d
Active log suffix: plum.07-01-01_16.11.33
tadekp@plum:~$ 
</code></pre></p>

<p>The package is in <strong>alpha</strong> stage now and I still get a few lintian errors (for example, the man page is missing), but otherwise is ok (even including the init.d scripts and checkpointing). If you&#8217;re interested in trying it out, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2007/01/02/bro-ids-debian-package/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gallery2 plugin &#8211; displaying googlemaps with GPS coordinates from EXIF</title>
		<link>http://tadek.pietraszek.org/blog/2006/08/31/gallery2-plugin-displaying-googlemaps-with-gps-coordinates-from-exif/</link>
		<comments>http://tadek.pietraszek.org/blog/2006/08/31/gallery2-plugin-displaying-googlemaps-with-gps-coordinates-from-exif/#comments</comments>
		<pubDate>Thu, 31 Aug 2006 10:05:27 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[New Ideas]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2006/08/31/gallery2-plugin-displaying-googlemaps-with-gps-coordinates-from-exif/</guid>
		<description><![CDATA[After resuming my geotaggin script (see this post), I decided to do something useful with it. We&#8217;re using gallery2 to store our photos and with a googlemap plugin, but found it useful only for displaying a single pointer per album (see here). For a more fine-grained selection we needed something else.

Therefore, I decided to write [...]]]></description>
			<content:encoded><![CDATA[<p>After resuming my geotaggin script (see this post), I decided to do something useful with it. We&#8217;re using gallery2 to store our photos and with a <a href="http://codex.gallery2.org/index.php/Gallery2:Modules:Map">googlemap plugin</a>, but found it useful only for displaying a single pointer per album (see <a href="http://gallery.ibao.net/Map/">here</a>). For a more fine-grained selection we needed something else.</p>

<p>Therefore, I decided to write my own plugin (yeah, there are already two out there, why not write my own? <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) and also learn Gallery2 API. The idea is to display a google map at the bottom of each photo, showing exactly where the photo was taken. Yes, it photo-specific and there&#8217;s only one pointer on the map. I find it nonetheless very useful.</p>

<p>Here&#8217;s a <a href="http://gallery.ibao.net/travel/Switzerland/melchsee/IMG_2991.JPG.html">sample output</a> (you can also admire the beautiful scenery of Melchsee <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). The plugin adds a new &#8220;block&#8221; in the template (therefore can be configured using a standard block management tool in Gallery2).</p>

<p>The position of the current photo is always in the middle (although you can move the map around, change the map type, zoom in and out etc.). The changes you make are stored as session cookies, and preserved between consecutive photo loads. Also, the whole panel can be hidden to speed up load and only shown on demand (show map|hide map).</p>

<p>Any comments? suggestions? ideas?</p>

<p>The plugin is currently in <em>alpha</em> stage, I will release it in a week or two (I want to create a webpage for it as well). In the meantime, if you&#8217;re interested in trying it out, drop me a line <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>BTW: I also found out that when iPhoto edits a photo, it converts Exif from Intel to Motorola (little endian -> big endian). There was a bug in <a href="http://www.offsky.com/software/exif/index.php">exifer</a> used in gallery, which corrpted the tags. The patch is only two lines long and can be found here (I also emailed the author):
<code>
<pre>
--- gps.inc.orig        2006-08-31 10:25:27.000000000 +0200
+++ gps.inc     2006-08-31 10:36:37.000000000 +0200
@@ -116,13 +116,24 @@
                        $minutes = GPSRational(substr($data,16,16),$intel);
                        $hour = GPSRational(substr($data,32,16),$intel);</p>

<ul>
<li>/* now we need a hack, since the whole data has been flipped in :103</li>
<li>
<ul>
<li>the order here is sec:min:hour. However, in the motorla mode the data</li>
</ul></li>
<li>
<ul>
<li>has not been flipped and the order is h:m:s. This breaks compatibility</li>
</ul></li>
<li>
<ul>
<li>with Motorola exif. (Tadek) */</li>
</ul></li>
<li>if($intel==1)
                    $data = $hour+$minutes/60+$seconds/3600;</li>
<li>else</li>
<li><pre><code>                                $data = $seconds+$minutes/60+$hour/3600;
        } else if($tag=="0007") { //Time
                $seconds = GPSRational(substr($data,0,16),$intel);
                $minutes = GPSRational(substr($data,16,16),$intel);
                $hour = GPSRational(substr($data,32,16),$intel);
</code></pre></li>
<li><pre><code>                /* I guess the same HACK as above. Tadek */
</code></pre></li>
<li>if ($intel==1)
                    $data = $hour.":".$minutes.":".$seconds;</li>
<li>else</li>
<li>$data = $seconds.":".$minutes.":".$hour;
            } else {
                    if($bottom!=0) $data=$top/$bottom;
                    else if($top==0) $data = 0;</li>
</ul>

<p></pre>
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2006/08/31/gallery2-plugin-displaying-googlemaps-with-gps-coordinates-from-exif/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>GeoTagging in EXIF (resumed)</title>
		<link>http://tadek.pietraszek.org/blog/2006/08/31/geotagging-in-exif-resumed/</link>
		<comments>http://tadek.pietraszek.org/blog/2006/08/31/geotagging-in-exif-resumed/#comments</comments>
		<pubDate>Thu, 31 Aug 2006 10:04:15 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2006/08/31/geotagging-in-exif-resumed/</guid>
		<description><![CDATA[After almost a year after I had done some initial experiments with geotagging my images. I decided to pursue this idea further. I also realized that taking an approach &#8220;It&#8217;s simple let&#8217;s write in Perl&#8221; is good, but &#8220;Let&#8217;s see if somebody hasn&#8217;t done it yet&#8221; is even better  

First, I recall I had [...]]]></description>
			<content:encoded><![CDATA[<p>After almost a year after I had done some initial experiments with geotagging my images. I decided to pursue this idea further. I also realized that taking an approach &#8220;It&#8217;s simple let&#8217;s write in Perl&#8221; is good, but &#8220;Let&#8217;s see if somebody hasn&#8217;t done it yet&#8221; is even better <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>First, I recall I had some problems with reading GPS data and hacked gpstransfer to do this. In the meantime, I found out that <a href="http://pygarmin.sourceforge.net/pygarmin">pygarmin</a> is a nice and working interface to Garmin GPSs, which works. More recently I discovered a much better and more versatile tool <a href="http://www.gpsbabel.org/">gpsbabel</a>. Like the tower of Babel it really does speak all the languages (including plurality of GPS and very exotic formats (see <a href="http://www.gpsbabel.org/capabilities.html">here</a>). The user interface is a bit weird and not all types of information (i.e. waypoints, tracks) are supported in all formats. Sadly, if the format is not supported, the program does transfer all the data (which takes a while) and prints nothing just to confuse you <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>After a bit of experimenting I discovered a magic formula:</p>

<pre><code>gpsbabel -t -i garmin -f /dev/ttyS0 -o psitrex -F &lt;track_file&gt;
</code></pre>

<p>&#8220;psitrex&#8221; stands for KuDaTa PsiTrex format, however, as exotic as it sounds, it is just a comma separated format. I tried a couple of others (actually all of them in my version (1.2.7) and the only ones I found useful were:</p>

<ul>
<li>psitrex -> an easy to parse CSV format</li>
<li>gpx -> produces results in XML</li>
<li>nmea -> looks ok, but does not show the start and end of each segment, which is useful for determining whether to interpolate data or not.</li>
</ul>

<p>I also revisited my geotagging script. First, as Diego pointed out there&#8217;s a nice tool on Mac to do this: <a href="http://www.macupdate.com/info.php/id/22283">iPhototoGoogleEarth</a>, which unfortunately doesn&#8217;t work on intel-Macs yet. For geotagging they use <a href="http://oregonstate.edu/~earlyj/gpsphotolinker/">GPSPhotoLinker</a>, which in turn uses gpsbabel. So at the end we use the same backend tool.</p>

<p>In the meantime I revisited my geotagging script and made it a bit more useful adding a bunch of options, debugging it, etc. Now that I actually use it on my photos, I had to make sure that it actually works <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>Here it is:</p>

<pre><code>$ ./geotag.pl 
ERROR: Need track file to proceed - use -t &lt;trackfile&gt;
Usage:
  ./geotag.pl -t &lt;track_file&gt; [-b] [-f] [-s &lt;seconds&gt;] [-a &lt;seconds&gt;] [-n &lt;seconds&gt;] [-z &lt;tz&gt;] files_to_process...


  Where:
  -b -&gt; keep backup,
  -f -&gt; force, overwrites an existing EXIF tag (or removes it)
  -s &lt;seconds&gt; -&gt; time shift (in case of time discrepancies)
  -a &lt;seconds&gt; -&gt; approximate non-continuous segements in the tracklog (default 300s)
  -n &lt;seconds&gt; -&gt; don't approximate but take the closest segment (default 10800s)
  -z &lt;tz&gt; -&gt; use the follwoing timezone for your camera (default current timezone)

  &lt;track_file&gt; can be best created using gpsbabel (http://www.gpsbabel.org):
   (e.g. Serial Garmin GPS: gpsbabel -t -i garmin -f /dev/ttyS0 -o psitrex -F &lt;track file&gt;)    
   at ./geotag.pl line 288.
</code></pre>

<p>Now what do I do with the script? Well&#8230; I wrote a <a href="http://gallery.menalto.com/">gallery2</a> plugin to display google maps. See <a href="http://tadek.pietraszek.org/blog/2006/08/31/gallery2-plugin-displaying-googlemaps-with-gps-coordinates-from-exif/">this post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2006/08/31/geotagging-in-exif-resumed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Web-based diagram drawing</title>
		<link>http://tadek.pietraszek.org/blog/2006/06/29/web-based-diagram-drawing/</link>
		<comments>http://tadek.pietraszek.org/blog/2006/06/29/web-based-diagram-drawing/#comments</comments>
		<pubDate>Thu, 29 Jun 2006 07:37:14 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2006/06/29/web-based-diagram-drawing/</guid>
		<description><![CDATA[
http://www.gliffy.com/ &#8211; a web-based &#8220;Flashy&#8221; Visio-like drawing program. A bit basic now, but I&#8217;m sure it&#8217;s getting there. Wonder when they will be bought by &#8230;  
http://www.google.com/googlespreadsheets/ &#8211; Spreadsheets from Google. Again, a bit basic, but quite impressive.

]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="http://www.gliffy.com/">http://www.gliffy.com/</a> &#8211; a web-based &#8220;Flashy&#8221; Visio-like drawing program. A bit basic now, but I&#8217;m sure it&#8217;s getting there. Wonder when they will be bought by &#8230; <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li><a href="http://www.google.com/googlespreadsheets/">http://www.google.com/googlespreadsheets/</a> &#8211; Spreadsheets from Google. Again, a bit basic, but quite impressive.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2006/06/29/web-based-diagram-drawing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pattern-based file renaming</title>
		<link>http://tadek.pietraszek.org/blog/2006/04/03/pattern-based-file-renaming/</link>
		<comments>http://tadek.pietraszek.org/blog/2006/04/03/pattern-based-file-renaming/#comments</comments>
		<pubDate>Mon, 03 Apr 2006 11:31:25 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2006/04/03/pattern-based-file-renaming/</guid>
		<description><![CDATA[Ever wanted to do bulk operations on files, similar to xargs, but much more flexible? For example:


rename all files .jpeg to .jpg
remove a prefix from many file names?
add a suffix/extension?
remove a prefix/suffx/extension?


Here&#8217;s a script I wrote:




!/bin/bash

#

Pattern-based file rename

#(c)2006 by Tadeusz Pietraszek

#

Usage:

./mv-pattern -i a *.txt &#60;- delete all 'a's in file names

./mv-pattern -i jpeg -o jpg [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to do bulk operations on files, similar to xargs, but much more flexible? For example:</p>

<ul>
<li>rename all files .jpeg to .jpg</li>
<li>remove a prefix from many file names?</li>
<li>add a suffix/extension?</li>
<li>remove a prefix/suffx/extension?</li>
</ul>

<p>Here&#8217;s a script I wrote:</p>

<p><code>
<pre></p>

<h1>!/bin/bash</h1>

<p>#</p>

<h1>Pattern-based file rename</h1>

<h1>#(c)2006 by Tadeusz Pietraszek</h1>

<p>#</p>

<h1>Usage:</h1>

<h1>./mv-pattern -i a *.txt &lt;- delete all 'a's in file names</h1>

<h1>./mv-pattern -i jpeg -o jpg *.jpeg &lt;- rename all jpegs to jpg</h1>

<h1>./mv-pattern -o .txt &lt;- add an extension</h1>

<h1>./mv-pattern -i .txt &lt;- remove an extension</h1>

<p>#</p>

<p>if [ $# -eq 0 ]
then
  echo "Usage: <code>basename $0</code> [-i <pattern>]  [-o <pattern>]  [-c <command>] files"
  exit -1;
fi</p>

<p>INPATTERN="";
OUTPATTERN="";
COMMAND="echo";</p>

<p>while getopts "i:o:c:" Option
do
  case $Option in
    i ) INPATTERN=$OPTARG;;
    o ) OUTPATTERN=$OPTARG;;
    c ) COMMAND=$OPTARG;;
    * ) echo "Unimplemented option chosen. Has to be one of -i -o -c"; exit -1;;
  esac
done</p>

<p>if [ -z "$INPATTERN" ]; then
  echo "No input pattern. Are you sure it's what you want?";</p>

<h1>exit -1;</h1>

<p>fi</p>

<p>if [ -z "$INPATTERN" ]; then
  echo "No input pattern. Are you sure it's what you want?";</p>

<h1>exit -1;</h1>

<p>fi</p>

<p>shift $(($OPTIND - 1))</p>

<h1>Decrements the argument pointer so it points to next argument.</h1>

<h1>echo "in: $INPATTERN, out: $OUTPATTERN";</h1>

<h1>rename</h1>

<p>for FILE in  "$@" ; do
    if [ -f $FILE ]; then
        NEWFILE=<code>echo $FILE | sed -re "s/(.*)$INPATTERN(.*)/\1$OUTPATTERN\2/"</code>;
        if [ "$FILE" != "$NEWFILE" ]; then
            $COMMAND $FILE $NEWFILE;
        fi;
    fi;
done</p>

<p>exit 0
</pre>
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2006/04/03/pattern-based-file-renaming/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
