<?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>MRo Blog &#187; Ruby</title>
	<atom:link href="http://blog.mro.name/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mro.name</link>
	<description>Marcus Rohrmoser mobile Software</description>
	<lastBuildDate>Wed, 23 Jun 2010 11:32:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Radio Geeky</title>
		<link>http://blog.mro.name/2010/03/radio-geeky/</link>
		<comments>http://blog.mro.name/2010/03/radio-geeky/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 12:05:02 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Artikel auf deutsch]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Bayern2]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mitschnitt]]></category>
		<category><![CDATA[Podcast]]></category>
		<category><![CDATA[Radio]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[scrAPI]]></category>
		<category><![CDATA[Screen Scraping]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[streamripper]]></category>
		<category><![CDATA[Zündfunk]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1714</guid>
		<description><![CDATA[wie schon in einem älteren Artikel angerissen möchte ich zeitgesteuert Radiosendungen aufnehmen &#8211; und zwar auf einem Rechner (mit Apache Webserver), der rund um die Uhr läuft. Nun habe ich kürzlich einem großen Zündfunk-Fan, der selten Zeit hat ihn zu hören, diesen Mitschnitt als Podcast zum Geburtstag geschenkt. Das ganze wurde aufwändiger als ich dachte [...]]]></description>
			<content:encoded><![CDATA[<p>wie schon in einem <a href="http://blog.mro.name/2009/12/radiomitschnitt-per-rezept/">älteren Artikel</a> angerissen möchte ich zeitgesteuert Radiosendungen aufnehmen &#8211; und zwar auf einem Rechner (mit Apache Webserver), der rund um die Uhr läuft.</p>
<p>Nun habe ich kürzlich einem großen <a href="http://www.br-online.de/bayern2/zuendfunk/">Zündfunk</a>-Fan, der selten Zeit hat ihn zu hören, diesen Mitschnitt als <a href="http://de.wikipedia.org/wiki/Podcast">Podcast</a> zum Geburtstag geschenkt. Das ganze wurde aufwändiger als ich dachte und setzt sich mittlerweile zusammen aus:</p>
<ol>
<li><a href="http://www.rechtzweinull.de/index.php?/archives/100-Screen-Scraping-Wann-ist-das-Auslesen-und-die-Veroeffentlichung-fremder-Daten-zulaessig.html">Screen Scraping</a> der <a href="http://www.br-online.de/br/jsp/global/funktion/programmvorschau/programmfahne.jsp?programm=B2">B2 Programmwebsite</a> mit <a href="http://blog.labnotes.org/tag/scrapi/">scrAPI</a> &#8211; incl. Datumskorrektur weil das Programm nicht um Mitternacht umbricht sondern um 5 Uhr früh,</li>
<li>diese Daten in einer <a href="http://www.sqlite.org/">SQLite</a> DB <a href="http://de.wikipedia.org/wiki/Cache">cachen</a> um nicht mehrmals am Tag zu scrapen (wenn man z.B. noch andere Sendungen aufnimmt),</li>
<li>per <a href="http://de.wikipedia.org/wiki/Cron">cron</a> einige Minuten vor Sendungsbeginn den <a href="http://de.wikipedia.org/wiki/Streamripper">streamripper</a> starten (<a href="http://sourceforge.net/projects/streamripper/files/streamripper%20%28older%20unix%29/1.62.3/streamripper-1.62.3.tar.gz/download">v1.62.3</a> wegen alter <a href="http://de.wikipedia.org/wiki/GLib">glib</a> auf <a href="http://de.wikipedia.org/wiki/Debian">Debian Linux</a>),
<ul>
<li>da der einige Zeit zum Starten braucht triggere ich Sendungsbeginn und -ende zeitlich exakt über ein <a href="http://code.google.com/p/xstreamripper/source/browse/trunk/streamripper/fetch_external_metadata.pl">Script, das Titelwechsel in den laufenden Streamripper injiziert</a> &#8211; der B2 Stream liefert selbst keine Sendungsinfos,</li>
</ul>
</li>
<li>falls der Stream zwischendurch unterbrochen wurde setzen wir die verschiedenen <a href="http://de.wikipedia.org/wiki/MP3">mp3</a> Dateien zu einer zusammen (ohne Überblendung per Holzhammer: <a href="http://en.wikipedia.org/wiki/Cat_(Unix)">cat</a>)</li>
<li>Sendungsinfos parallel zum mp3 als <a href="http://de.wikipedia.org/wiki/Extensible_Markup_Language">xml</a> speichern, um nach Aufnahmeende von der DB unabhängig zu sein,</li>
<li>aus allen vorhandenen mp3+xml Paaren ein <a href="http://de.wikipedia.org/wiki/RSS">Podcast RSS</a> bauen und mit <a href="http://www.gnu.org/software/gzip/">gzip</a> packen,</li>
<li>tägliche Gleitlöschung (mp3 älter als 3 Wochen) per cron+<a href="http://de.wikipedia.org/wiki/Find">find</a> damit die Platte nicht volläuft.</li>
</ol>
<p>Den Podcast abonniert man schließlich z.B. mit <a href="http://de.wikipedia.org/wiki/ITunes">iTunes</a> und bekommt direkt nach der Sendung die frische Zündfunkfolge incl. komplettem Text zur Sendung frei Haus.</p>
<p>Das komplette <a href="http://gist.github.com/345983">Ruby Script gibts bei github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2010/03/radio-geeky/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>hübsche Dropbox Links</title>
		<link>http://blog.mro.name/2010/01/hubsche-dropbox-links/</link>
		<comments>http://blog.mro.name/2010/01/hubsche-dropbox-links/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 13:09:31 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Artikel auf deutsch]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Dropbox]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Netiquette]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[RewriteEngine]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1633</guid>
		<description><![CDATA[Weil große Email Anhänge stinken, bietet sich z.B. die Dropbox als Dateiaustauschplatform an. Einfach die Datei in den (lokalen) Dropbox/Public Ordner verfrachten, syncen lassen und per &#8220;Rechte Maustaste -&#62; Copy Public Link&#8221; in die Mail kopieren. Redirect Nun sind solche Links nicht besonders hübsch (Branding!, Branding!, CI! ruft die Marketingabteilung) und  spätestens wenn man&#8217;s abtippen [...]]]></description>
			<content:encoded><![CDATA[<p>Weil <a href="http://friendfeed.com/akawee/10ab93b0/e-mail-missbrauch-teil-2-der-anhang-ist-oft-die">große Email Anhänge stinken</a>, bietet sich z.B. die <a href="http://friendfeed.com/webjuwelen/9ed5b1a9/skrupellose-werbung-fur-die-dropbox-dieser">Dropbox</a> als Dateiaustauschplatform an.</p>
<p>Einfach die Datei in den (lokalen) Dropbox/Public Ordner verfrachten, syncen lassen und per &#8220;Rechte Maustaste -&gt; Copy Public Link&#8221; in die Mail kopieren.</p>
<h3>Redirect</h3>
<p>Nun sind solche Links nicht besonders hübsch (Branding!, Branding!, CI! ruft die Marketingabteilung) und  spätestens wenn man&#8217;s abtippen muß oder per Telephon weitersagt wird&#8217;s gruslig.</p>
<p>Hat man aber eine eigene Website, lassen sich die <a href="http://www.cimitan.com/blog/2008/09/17/htaccess-to-redirect-on-dropboxs-public-folder/#">Dropbox Links aufhübschen</a> und eine Weiterleitung einrichten, dann wird aus</p>
<pre>http://dl.dropbox.com/u/1234567/BigDocument.pdf</pre>
<p>z.B.</p>
<pre>http://dropbox.mydomain.com/BigDocument.pdf</pre>
<p>und schon sind die Brandingfreunde happy.</p>
<h3>index.html</h3>
<p>Geht es nicht um eine einzelne Datei sondern um mehrere, will man evtl. eine Übersicht in einer index.html haben. So eine Übersicht legt z.B. mein <a href="http://www.ruby-lang.org/de/">ruby</a> Script <a href="http://gist.github.com/271223">htmlizedb</a> an. Das Script will im <a href="http://de.wikipedia.org/wiki/Bourne-again_shell">Terminal</a> in dem Verzeichnis gestartet werden, für das die Übersicht her soll.</p>
<h3>Redirect + index.html</h3>
<p>Bei Webservern ist allgemein üblich, daß man den Dateinamen index.html im Link weglassen kann. Der Webserver nimmt dann an man meint selbige. Die Dropbox verhält sich aber in dieser Hinsicht nicht wie ein normaler Webserver, sondern will immer den kompletten Dateinamen.</p>
<p>Hat man aber bereits den Redirect Trick in Benutzung, läßt sich die Redirect Steuerdatei (<code>.htaccess</code>) aufbohren, daß der Redirect die index.html Angabe ergänzt:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
<span style="color: #adadad; font-style: italic;"># dropbox abbreviation:</span>
<span style="color: #adadad; font-style: italic;"># http://www.cimitan.com/blog/2008/09/17/htaccess-to-redirect-on-dropboxs-public-folder/#</span>
<span style="color: #adadad; font-style: italic;"># last path component has no dot -&amp;gt; redirect to index.html</span>
<span style="color: #00007f;">RewriteRule</span> ^(.+/)?([^./]+)/?$	http://dl.dropbox.com/u/<span style="color: #ff0000;">1234567</span>/$<span style="color: #ff0000;">1</span>$<span style="color: #ff0000;">2</span>/index.html	[last,qsappend]
<span style="color: #adadad; font-style: italic;"># everything else: redirect as is</span>
<span style="color: #00007f;">RewriteRule</span> ^(.+)$	http://dl.dropbox.com/u/<span style="color: #ff0000;">1234567</span>/$<span style="color: #ff0000;">1</span>	[last,qsappend]</pre></div></div>

<p>violá, nun wird von</p>
<pre>http://dropbox.mydomain.com/FolderWithBigFiles</pre>
<p>automatisch auf den Dropbox Link</p>
<pre>http://dl.dropbox.com/u/1234567/FolderWithBigFiles/index.html</pre>
<p>weitergeleitet.</p>
<p>Toll, nicht?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2010/01/hubsche-dropbox-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-Mobile Rechnungen auspacken und umbenennen</title>
		<link>http://blog.mro.name/2009/11/t-mobile-rechnungen-auspacken-umbenennen/</link>
		<comments>http://blog.mro.name/2009/11/t-mobile-rechnungen-auspacken-umbenennen/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 17:50:19 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Artikel auf deutsch]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[GnuPG]]></category>
		<category><![CDATA[gpg]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[T-Mobile]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1354</guid>
		<description><![CDATA[über T-Mobile RechnungOnline kann man sich die Rechnung als gpg-verschlüsselten Anhang per Mail schicken lassen &#8211; incl. Einzelverbindungsnachweis. Und obwohl&#8217;s nur 1x im Monat kommt, ist das Auspacken und Umbenennen in sinnvolle Dateinamen eine lästige Routinearbeit. Also &#8211; automatisieren. Das folgende Ruby-Script erledigt das, nachdem der Rechnungsanhang in einen der Ordner &#8220;Downloads&#8221; oder &#8220;Desktop&#8221; gelegt [...]]]></description>
			<content:encoded><![CDATA[<p>über <a href="http://www.t-mobile.de/faq/1,1951,18-_,00.html">T-Mobile RechnungOnline</a> kann man sich die Rechnung als <a href="http://www.gnupg.org/">gpg</a>-verschlüsselten Anhang per Mail schicken lassen &#8211; incl. Einzelverbindungsnachweis. Und obwohl&#8217;s nur 1x im Monat kommt, ist das Auspacken und Umbenennen in sinnvolle Dateinamen eine lästige Routinearbeit.</p>
<p>Also &#8211; automatisieren. Das folgende Ruby-Script erledigt das, nachdem der Rechnungsanhang in einen der Ordner &#8220;Downloads&#8221; oder &#8220;Desktop&#8221; gelegt wurde:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
dst=<span style="color:#996600;">&quot;#{ENV['HOME']}/Documents/tmobile&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># 1. pull together all pgp crypted find Rechnung_15.10.2009.zip.pgp in Desktop, Downloads, local dir</span>
<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{ENV['HOME']}/Downloads&quot;</span>, <span style="color:#996600;">&quot;#{ENV['HOME']}/Desktop&quot;</span>, dst<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>dir<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span>dir<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
    m = <span style="color:#006600; font-weight:bold;">/</span>Rechnung_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.<span style="color:#9900CC;">zip</span><span style="color:#006600; font-weight:bold;">&#40;</span>\.<span style="color:#9900CC;">pgp</span><span style="color:#006600; font-weight:bold;">|</span>\.<span style="color:#9900CC;">gpg</span><span style="color:#006600; font-weight:bold;">&#41;</span>?<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span> file
    <span style="color:#9966CC; font-weight:bold;">if</span> m
      s = <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;mv #{dir}/#{file} #{dst}/#{m[3]}-#{m[2]}-#{m[1]}-bill.zip#{m[4]}&quot;</span>
      s = <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;gpg #{dst}/#{m[3]}-#{m[2]}-#{m[1]}-bill.zip#{m[4]}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;rm #{dst}/#{m[3]}-#{m[2]}-#{m[1]}-bill.zip#{m[4]}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> s <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      s = <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;unzip #{dst}/#{m[3]}-#{m[2]}-#{m[1]}-bill.zip&quot;</span>
      <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;rm #{dst}/#{m[3]}-#{m[2]}-#{m[1]}-bill.zip&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> s
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;de-crypted &amp; unpacked #{dst}/#{m[3]}-#{m[2]}-#{m[1]}-bill.zip&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># 2. rename unpacked files accordingly</span>
<span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span>dst<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
  m = <span style="color:#006600; font-weight:bold;">/</span>^Rechnung_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span> file
  <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;mv #{dst}/#{file} #{dst}/#{m[1]}-#{m[2]}-bill-#{m[3]}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> m
  m = <span style="color:#006600; font-weight:bold;">/</span>^Einzelverbindungsnachweis_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span> file
  <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;mv #{dst}/#{file} #{dst}/#{m[1]}-#{m[2]}-evn--#{m[3]}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> m
  m = <span style="color:#006600; font-weight:bold;">/</span>^Rechnung_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">5</span>,<span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span> file
  <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;mv #{dst}/#{file} #{dst}/#{m[3]}-#{m[2]}-bill-#{m[1]}#{m[4]}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> m
  m = <span style="color:#006600; font-weight:bold;">/</span>^Einzelverbindungsnachweis_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">5</span>,<span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span> file
  <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;mv #{dst}/#{file} #{dst}/#{m[3]}-#{m[2]}-evn--#{m[1]}#{m[4]}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> m
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2009/11/t-mobile-rechnungen-auspacken-umbenennen/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ruby: parse Apache Serverlogs</title>
		<link>http://blog.mro.name/2009/07/ruby-parse-apache-serverlogs/</link>
		<comments>http://blog.mro.name/2009/07/ruby-parse-apache-serverlogs/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 21:59:43 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Articles in english]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[logfile]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[serverlogs]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1108</guid>
		<description><![CDATA[Yields a hashmap for every line: require 'date' &#160; class Apache def self.each_request&#40;src=$stdin&#41; ip_pat=/&#40;?:&#91;0-9&#93;+\.&#41;&#123;3&#125;&#91;0-9&#93;+/ date_pat=/\&#91;&#91;^\&#93;&#93;+\&#93;/ req_pat=/&#34;([A-Z]+)\s([^\s]+)\s([^\s]+)&#34;/ ref_pat=/&#34;([^&#34;&#93;+&#41;&#34;/ date_fmt = '[%d/%b/%Y:%H:%M:%S %Z]' apache_pat = Regexp.new( &#34;&#40;#{ip_pat})\s([^\s]+)\s([^\s]+)\s&#34; &#60; &#60; &#34;(#{date_pat})\s#{req_pat}\s([0-9]+)\s(-&#124;[0-9]+)\s#{ref_pat}\s#{ref_pat}&#34;&#41; src.each_line do &#124;l&#124; m = apache_pat.match l if m r = &#123; :ip =&#62; m&#91;1&#93;, :uid =&#62; m&#91;2&#93;, :auth =&#62; m&#91;3&#93;, :date =&#62; DateTime.strptime&#40;m&#91;4&#93;,date_fmt&#41;, :method =&#62; m&#91;5&#93;, [...]]]></description>
			<content:encoded><![CDATA[<p>Yields a hashmap for every line:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'date'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Apache
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">each_request</span><span style="color:#006600; font-weight:bold;">&#40;</span>src=$stdin<span style="color:#006600; font-weight:bold;">&#41;</span>
    ip_pat=<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>?:<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span>\.<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+/</span>
    date_pat=<span style="color:#006600; font-weight:bold;">/</span>\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#91;</span>^\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span>\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">/</span>
    req_pat=<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;([A-Z]+)<span style="color:#000099;">\s</span>([^<span style="color:#000099;">\s</span>]+)<span style="color:#000099;">\s</span>([^<span style="color:#000099;">\s</span>]+)&quot;</span><span style="color:#006600; font-weight:bold;">/</span>
    ref_pat=<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;([^&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#996600;">&quot;/
    date_fmt = '[%d/%b/%Y:%H:%M:%S %Z]'
    apache_pat = Regexp.new( &quot;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#008000; font-style:italic;">#{ip_pat})\s([^\s]+)\s([^\s]+)\s&quot; &lt; &lt;</span>
      <span style="color:#996600;">&quot;(#{date_pat})<span style="color:#000099;">\s</span>#{req_pat}<span style="color:#000099;">\s</span>([0-9]+)<span style="color:#000099;">\s</span>(-|[0-9]+)<span style="color:#000099;">\s</span>#{ref_pat}<span style="color:#000099;">\s</span>#{ref_pat}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    src.<span style="color:#9900CC;">each_line</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>l<span style="color:#006600; font-weight:bold;">|</span>
      m = apache_pat.<span style="color:#9900CC;">match</span> l
      <span style="color:#9966CC; font-weight:bold;">if</span> m
        r = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:ip</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:uid</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:auth</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:date</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">DateTime</span>.<span style="color:#9900CC;">strptime</span><span style="color:#006600; font-weight:bold;">&#40;</span>m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span>,date_fmt<span style="color:#006600; font-weight:bold;">&#41;</span>,
          <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">6</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:http</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">7</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:bytes</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:referrer</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:agent</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
        <span style="color:#9966CC; font-weight:bold;">yield</span> r
       <span style="color:#9966CC; font-weight:bold;">else</span>
        <span style="color:#ff6633; font-weight:bold;">$stderr</span>.<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Unparseable line: '#{l}'&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>maybe there are faster ways, but it&#8217;s quite convenient this way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2009/07/ruby-parse-apache-serverlogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transfer Phone Numbers from gammu to the Mac Adressbook</title>
		<link>http://blog.mro.name/2009/03/transfer-phone-numbers-from-gammu-to-the-mac-adressbook/</link>
		<comments>http://blog.mro.name/2009/03/transfer-phone-numbers-from-gammu-to-the-mac-adressbook/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:34:28 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Articles in english]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[6610]]></category>
		<category><![CDATA[Addressbook]]></category>
		<category><![CDATA[gammu]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[vCard]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=761</guid>
		<description><![CDATA[ok, make yourself comfortable, fasten your seatbelt and stop smoking. This will be quite a journey: Get gammu and backup the phone data: $ gammu backup phonedata.txt -yes open phonedata.txt and save it in &#8220;MacRoman&#8221; encoding with Unix line endings run it through this ruby script: #!/usr/bin/ruby -w -- &#160; # http://www.rubycentral.com/pickaxe/ # http://homepage.mac.com/phrogz/CSV2vCard_v2.html &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>ok, make yourself comfortable, fasten your seatbelt and stop smoking. This will be quite a journey:</p>
<p><span id="more-761"></span></p>
<ol>
<li>Get <a href="http://gammu.org">gammu</a> and backup the phone data:<br />
<code>$ gammu backup phonedata.txt -yes</code></li>
<li>open <code>phonedata.txt</code> and save it in &#8220;MacRoman&#8221; encoding with Unix line endings</li>
<li>run it through this <a href="http://www.rubycentral.com/pickaxe/">ruby</a> script:

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby -w -- </span>
&nbsp;
<span style="color:#008000; font-style:italic;"># http://www.rubycentral.com/pickaxe/</span>
<span style="color:#008000; font-style:italic;"># http://homepage.mac.com/phrogz/CSV2vCard_v2.html</span>
&nbsp;
records = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
fields = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
eor = <span style="color:#006600; font-weight:bold;">/</span>^<span style="color:#006600; font-weight:bold;">&#91;</span> \t<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">*</span>$<span style="color:#006600; font-weight:bold;">/</span>
bor = <span style="color:#006600; font-weight:bold;">/</span>^\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>^<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span>\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">&#93;</span>$<span style="color:#006600; font-weight:bold;">/</span>
etype = <span style="color:#006600; font-weight:bold;">/</span>^Entry<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>Type\s<span style="color:#006600; font-weight:bold;">+</span>=\s<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span>\S<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>
etext = <span style="color:#006600; font-weight:bold;">/</span>^Entry<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>Text\s<span style="color:#006600; font-weight:bold;">+</span>=\s<span style="color:#006600; font-weight:bold;">+</span><span style="color:#996600;">&quot;(.*)&quot;</span><span style="color:#006600; font-weight:bold;">/</span>
&nbsp;
record_type = <span style="color:#0000FF; font-weight:bold;">nil</span>
entry_type = <span style="color:#0000FF; font-weight:bold;">nil</span>
tmp = <span style="color:#0000FF; font-weight:bold;">nil</span>
&nbsp;
<span style="color:#ff6633; font-weight:bold;">$stdin</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>l<span style="color:#006600; font-weight:bold;">|</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>eor =~ l<span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#006666;">0</span>
		records<span style="color:#006600; font-weight:bold;">&#91;</span>record_type<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> records<span style="color:#006600; font-weight:bold;">&#91;</span>record_type<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
		records<span style="color:#006600; font-weight:bold;">&#91;</span>record_type<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; tmp <span style="color:#9966CC; font-weight:bold;">if</span> tmp
<span style="color:#008000; font-style:italic;">#		puts '-- EOR --'</span>
		record_type = entry_type = tmp = <span style="color:#0000FF; font-weight:bold;">nil</span>
		<span style="color:#9966CC; font-weight:bold;">next</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
	m = bor.<span style="color:#9900CC;">match</span> l
	<span style="color:#9966CC; font-weight:bold;">if</span> m
<span style="color:#008000; font-style:italic;">#		puts &quot;#{m[1]} - #{m[2]}&quot;</span>
		record_type = <span style="color:#996600;">&quot;#{m[1]}&quot;</span>
		tmp = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
		<span style="color:#9966CC; font-weight:bold;">next</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#996600;">'PhonePBK'</span> == record_type
		m = etype.<span style="color:#9900CC;">match</span> l
<span style="color:#008000; font-style:italic;">#		raise &quot;Parse Error: #{l}&quot; if entry_type.nil? &amp;amp;&amp;amp; m.nil?</span>
		<span style="color:#9966CC; font-weight:bold;">if</span> m
			entry_type = <span style="color:#996600;">&quot;#{m[2]}&quot;</span>
		<span style="color:#9966CC; font-weight:bold;">else</span>
			m = etext.<span style="color:#9900CC;">match</span> l
			<span style="color:#9966CC; font-weight:bold;">if</span> m
				<span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">'Parse Error'</span> <span style="color:#9966CC; font-weight:bold;">if</span> entry_type.<span style="color:#0000FF; font-weight:bold;">nil</span>?
				<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#996600;">'Name'</span> == entry_type
					name = <span style="color:#996600;">&quot;#{m[2]}&quot;</span>.<span style="color:#CC0066; font-weight:bold;">split</span> <span style="color:#996600;">' '</span>
					tmp<span style="color:#006600; font-weight:bold;">&#91;</span>entry_type = <span style="color:#996600;">'LastName'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;#{name[name.length-1]}&quot;</span>
					fields<span style="color:#006600; font-weight:bold;">&#91;</span>entry_type<span style="color:#006600; font-weight:bold;">&#93;</span> = entry_type
					name<span style="color:#006600; font-weight:bold;">&#91;</span>name.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
					name.<span style="color:#9900CC;">compact</span>!
&nbsp;
					count = <span style="color:#006666;">0</span>
					name.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>tn<span style="color:#006600; font-weight:bold;">|</span>
						tmp<span style="color:#006600; font-weight:bold;">&#91;</span>entry_type = <span style="color:#996600;">&quot;Name_#{count}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = tn
						fields<span style="color:#006600; font-weight:bold;">&#91;</span>entry_type<span style="color:#006600; font-weight:bold;">&#93;</span> = entry_type
						count <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
					<span style="color:#9966CC; font-weight:bold;">end</span>
				<span style="color:#9966CC; font-weight:bold;">else</span>
					fields<span style="color:#006600; font-weight:bold;">&#91;</span>entry_type<span style="color:#006600; font-weight:bold;">&#93;</span> = entry_type
<span style="color:#008000; font-style:italic;">#					puts &quot;#{entry_type} = #{m[2]}&quot;</span>
					tmp<span style="color:#006600; font-weight:bold;">&#91;</span>entry_type<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;#{m[2]}&quot;</span>
				<span style="color:#9966CC; font-weight:bold;">end</span>
				entry_type = <span style="color:#0000FF; font-weight:bold;">nil</span>
			<span style="color:#9966CC; font-weight:bold;">end</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
keys = fields.<span style="color:#9900CC;">keys</span>.<span style="color:#9900CC;">sort</span>
sep = <span style="color:#996600;">','</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\#</span>#{keys.join(sep)}&quot;</span>
records<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'PhonePBK'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>item<span style="color:#006600; font-weight:bold;">|</span>
	tmp = <span style="color:#996600;">''</span>
	keys.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>key<span style="color:#006600; font-weight:bold;">|</span>
		v = item<span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span>
		v = <span style="color:#996600;">''</span> <span style="color:#9966CC; font-weight:bold;">if</span> v.<span style="color:#0000FF; font-weight:bold;">nil</span>?
		v.<span style="color:#CC0066; font-weight:bold;">gsub!</span> <span style="color:#996600;">&quot;'&quot;</span>, <span style="color:#996600;">&quot;''&quot;</span>
		tmp = <span style="color:#996600;">&quot;#{tmp}'#{v}'#{sep}&quot;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#CC0066; font-weight:bold;">puts</span> tmp
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</li>
<li>run the result through a <a href="http://homepage.mac.com/phrogz/CSV2vCard_v2.html">csv to vcard converter</a>,</li>
<li>remove all single quotes <code>'</code> from the vcards,</li>
<li>import the vcards into the osx addressbook.</li>
</ol>
<p>And guess what &#8211; that really works! The script is quite a hack but does the job. I thought about rewriting it using closures prior publishing but left it as a homework to you.</p>
<p>[<strong>Update</strong>] Maybe <a href="http://europe.nokia.com/get-support-and-software/product-support/isync">iSync</a> would have done the trick, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2009/03/transfer-phone-numbers-from-gammu-to-the-mac-adressbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remember Ragel</title>
		<link>http://blog.mro.name/2008/09/remember-ragel/</link>
		<comments>http://blog.mro.name/2008/09/remember-ragel/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 23:49:24 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Artikel auf deutsch]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[piccolo2d]]></category>
		<category><![CDATA[ragel]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mro.name/2008/09/remember-ragel/</guid>
		<description><![CDATA[Es ist schon etwas her aber dennoch einen kurzen Eintrag hier sicher wert. Ragel habe ich für ein Experiment (ist SVG als 2D Szenengraph Format für piccolo2d machbar?) benutzt um einige Parser zu bauen. Als Vorlage dienten die BNF Grammatiken direkt aus der W3C SVG Spezifikation. Nachdem der erste funktionsfähige Stand erreicht war habe ich [...]]]></description>
			<content:encoded><![CDATA[<p>Es ist schon etwas her aber dennoch einen kurzen Eintrag hier sicher wert.</p>
<p><a title="Ragel" href="http://research.cs.queensu.ca/~thurston/ragel/">Ragel</a> habe ich für ein Experiment (ist <a title="SVG" href="http://www.w3.org/TR/SVG11">SVG</a> als 2D <a href="http://de.wikipedia.org/wiki/Szenengraph">Szenengraph</a> Format für <a href="http://www.piccolo2d.org/">piccolo2d</a> machbar?) benutzt um <a href="http://code.google.com/p/piccolo2d/source/browse/?r=390#svn/piccolo2d.java/branches/svg/svg/src/main/ragel">einige Parser</a> zu bauen.</p>
<p><span id="more-33"></span>Als Vorlage dienten die <a href="http://www.w3.org/TR/SVG11/paths.html#PathDataBNF">BNF Grammatiken direkt aus der W3C SVG Spezifikation</a>. Nachdem der erste funktionsfähige Stand erreicht war habe ich noch ein <a href="https://lib2geom.svn.sourceforge.net/svnroot/lib2geom/lib2geom/trunk/src/2geom/svg-path-parser.rl">anderes Projekt</a> entdeckt, das genau dasselbe Problem ebenfalls mit Ragel gelöst hat und mich von deren Ansatz Mehrdeutigkeiten aufzulösen inspirieren lassen.</p>
<p>Schön ist dabei</p>
<ul>
<li>BNF Grammatiken direkt verwerten (die vom <a href="http://www.w3.org/TR/SVG11/paths.html#PathDataBNF">W3C</a> mußten fast nur von <a href="http://code.google.com/p/piccolo2d/source/browse/piccolo2d.java/branches/svg/svg/src/main/ragel/PathParser.rl?r=382#131">unten nach oben</a> umgedreht werden),</li>
<li>dadurch glasklare Definition der erlaubten formalen Sprache,</li>
<li>keinerlei Abhängigkeiten von irgendwelchen Libs,</li>
<li>irre schneller Parser-Code,</li>
<li>Ragel läuft auf zig Systemen,</li>
<li>Ragel spuckt aktuell C, C++, Objective-C, C#, D, Java und Ruby aus,</li>
<li>wird von richtig hellen Köpfen benutzt (nette Beispiele im Netz),</li>
<li>und die Doku taugt auch noch was!</li>
</ul>
<p>Für die Ruby Freunde unter uns gibt&#8217;s auch einen <a href="http://www.devchix.com/2008/01/13/a-hello-world-for-ruby-on-ragel-60/">speziellen netten Blog Eintrag</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2008/09/remember-ragel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
