<?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; github</title>
	<atom:link href="http://blog.mro.name/tag/github/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>Binary Search NSArray</title>
		<link>http://blog.mro.name/2010/01/binary-search-nsarray/</link>
		<comments>http://blog.mro.name/2010/01/binary-search-nsarray/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 22:02:07 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Articles in english]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[NSArray]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Search]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1652</guid>
		<description><![CDATA[Though CFArray comes with binary search capability, NSArray does not &#8211; at least not within the iPhone SDK. The indexOfObject:inSortedRange:options:usingComparator: can&#8217;t be found. Plus the CFArrayBSearchValues doesn&#8217;t tell you whether the key actually is part of the list or not. That&#8217;s what the Java JDK does, so let&#8217;s implement some category methods -&#40;NSInteger&#41;binarySearch:&#40;id&#41;key; -&#40;NSInteger&#41;binarySearch:&#40;id&#41;key usingSelector:&#40;SEL&#41;comparator; [...]]]></description>
			<content:encoded><![CDATA[<p>Though <a href="http://developer.apple.com/mac/library/DOCUMENTATION/CoreFoundation/Reference/CFArrayRef/index.html">CFArray</a> comes with <a href="http://en.wikipedia.org/wiki/Binary_search_algorithm#Iterative">binary search</a> capability, <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html">NSArray</a> does not &#8211; at least not within the iPhone SDK. The <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/indexOfObject:inSortedRange:options:usingComparator:">indexOfObject:inSortedRange:options:usingComparator:</a> can&#8217;t be found.</p>
<p>Plus the <a href="http://developer.apple.com/mac/library/DOCUMENTATION/CoreFoundation/Reference/CFArrayRef/Reference/reference.html#//apple_ref/doc/uid/20001192-CH201-F10956">CFArrayBSearchValues</a> doesn&#8217;t tell you whether the key actually is part of the list or not. That&#8217;s what the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#binarySearch(T[],%20T,%20java.util.Comparator)">Java JDK</a> does, so let&#8217;s implement some <a href="http://developer.apple.com/mac/library/documentation/General/Conceptual/DevPedia-CocoaCore/Category.html">category</a> methods</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingSelector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>comparator;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingSelector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>comparator inRange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSRange</span><span style="color: #002200;">&#41;</span>range;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingFunction<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger <span style="color: #002200;">&#40;</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span>, <span style="color: #a61390;">id</span>, <span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>comparator context<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>context;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingFunction<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger <span style="color: #002200;">&#40;</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span>, <span style="color: #a61390;">id</span>, <span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>comparator context<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>context inRange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSRange</span><span style="color: #002200;">&#41;</span>range;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingDescriptors<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sortDescriptors;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingDescriptors<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sortDescriptors inRange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSRange</span><span style="color: #002200;">&#41;</span>range;</pre></div></div>

<p>ourselves, like</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>binarySearch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>key usingFunction<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger <span style="color: #002200;">&#40;</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span>, <span style="color: #a61390;">id</span>, <span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>comparator context<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>context inRange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSRange</span><span style="color: #002200;">&#41;</span>range
<span style="color: #002200;">&#123;</span>
    NSLogD<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;[NSArray(MroBinarySearch) binarySearch:%@ usingFunction:]&quot;</span>, key<span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self.count <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span> || key <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span> || comparator <span style="color: #002200;">==</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>self binarySearch<span style="color: #002200;">:</span>key usingSelector<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> inRange<span style="color: #002200;">:</span>range<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">//	check overflow?</span>
    NSInteger min <span style="color: #002200;">=</span> range.location;
    NSInteger max <span style="color: #002200;">=</span> range.location <span style="color: #002200;">+</span> range.length <span style="color: #002200;">-</span> <span style="color: #2400d9;">1</span>;
&nbsp;
    <span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span>min <span style="color: #002200;">&amp;</span>lt; <span style="color: #002200;">=</span> max<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #11740a; font-style: italic;">// http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html</span>
        <span style="color: #a61390;">const</span> NSInteger mid <span style="color: #002200;">=</span> min <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>max <span style="color: #002200;">-</span> min<span style="color: #002200;">&#41;</span> <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span>;
        <span style="color: #a61390;">switch</span> <span style="color: #002200;">&#40;</span>comparator<span style="color: #002200;">&#40;</span>key, <span style="color: #002200;">&#91;</span>self objectAtIndex<span style="color: #002200;">:</span>mid<span style="color: #002200;">&#93;</span>, context<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>
        <span style="color: #002200;">&#123;</span>
            <span style="color: #a61390;">case</span> NSOrderedSame<span style="color: #002200;">:</span>
                <span style="color: #a61390;">return</span> mid;
            <span style="color: #a61390;">case</span> NSOrderedDescending<span style="color: #002200;">:</span>
                min <span style="color: #002200;">=</span> mid <span style="color: #002200;">+</span> <span style="color: #2400d9;">1</span>;
                <span style="color: #a61390;">break</span>;
            <span style="color: #a61390;">case</span> NSOrderedAscending<span style="color: #002200;">:</span>
                max <span style="color: #002200;">=</span> mid <span style="color: #002200;">-</span> <span style="color: #2400d9;">1</span>;
                <span style="color: #a61390;">break</span>;
        <span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">return</span> <span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>min <span style="color: #002200;">+</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>See the <a href="http://gist.github.com/275631/">full interface + implementation + testcase without html encoding dirt at github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2010/01/binary-search-nsarray/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
