<?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>marius &#187; Code</title>
	<atom:link href="http://devilx.net/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://devilx.net</link>
	<description></description>
	<lastBuildDate>Mon, 14 May 2012 21:25:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Automagic Promo-Code Redeemer.</title>
		<link>http://devilx.net/2010/12/23/automagic-promo-code-redeemer/</link>
		<comments>http://devilx.net/2010/12/23/automagic-promo-code-redeemer/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 23:34:18 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Mac and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Promo]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=1174</guid>
		<description><![CDATA[Okay, so first of all, let me just describe you with a screenshot of a recent Twitter conversation what this post is about: I thought, it might be a cool idea to actually proof that something like that should be &#8230; <a href="http://devilx.net/2010/12/23/automagic-promo-code-redeemer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Okay, so first of all, let me just describe you with a screenshot of a recent Twitter conversation what this post is about:<br />
<a href="http://www.devilx.net/wp-content/uploads/2010/12/Screen-shot-2010-12-23-at-12.19.50-AM.png"><img class="alignnone size-full wp-image-1175" title="Screen shot 2010-12-23 at 12.19.50 AM" src="http://www.devilx.net/wp-content/uploads/2010/12/Screen-shot-2010-12-23-at-12.19.50-AM.png" alt="" width="280" height="280" /></a></p>
<p>I thought, it might be a cool idea to actually proof that something like that should be possible within a few lines of code. No C code, no Objective-C, even more simple: AppleScript (and a little bit of Bash scripting).</p>
<p>However, so I just took about an hour and a half and wrote down this little bad boy:</p>
<pre>
global used_codes
global code_used

on run
	set used_codes to {}
end run

on idle
	set promocodes to paragraphs of (do shell script "/opt/local/bin/wget --quiet -O - http://twitter.com/statuses/user_timeline/166916511.rss | while read sentence; do for word in $sentence; do echo $word | grep '^[A-Z0-9]\\{12\\}' | sed 's/\\(.\\{12\\}\\).*/\\1/'; done; done | sort | uniq")
	repeat with promocode in promocodes
		set code_used to false
		repeat with used_code in used_codes
			if promocode = used_code then
				set code_used to true
			end if
		end repeat
		if code_used = false then
			tell application "iTunes"
				launch
				activate
				open location "itmss://phobos.apple.com/WebObjects/MZFinance.woa/wa/freeProductCodeWizard?code=" &#038; promocode
				copy promocode to the end of used_codes
				set used_codes to used_codes &#038; promocode
			end tell
		end if
	end repeat
	return 30
end idle
</pre>
<p>Simply hack it into your AppleScript editor and save it as &#8220;Application&#8221; with the &#8220;Stay Open&#8221; option clicked. Now after double-clicking the file that has just been created the script starts fetching a Twitter RSS-feed (in this case @verbsapp&#8217;s, heh) every 30 seconds, grabs all iTunes promo-codes it can find and automagically redeems them in the iTunes store. If the could is still valid &#8211; lucky you. If not, better luck next time! In any case each code will be added to a temporary &#8220;black list&#8221; so it won&#8217;t be redeemed again.</p>
<p>Feel free to customize and use this script! GNU GPL v2 and stuff. Enjoy. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':)' class='wp-smiley' /> </p>
<p><strong>//update: I&#8217;ve just adapted the script a bit more to include promo codes with more than 12 characters length. Besides, I&#8217;ve applied John&#8217;s &#8220;patch&#8221; to it &#8211; thanks for that one John! <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':)' class='wp-smiley' /> </strong></p>
<pre>
global used_codes
global code_used

on run
	set used_codes to {}
end run

on idle
	set promocodes to paragraphs of (do shell script "for word in `/usr/bin/lwp-download 'http://twitter.com/statuses/user_timeline/166916511.rss' -`; do echo $word | grep '^[A-Z0-9]\\{12,16\\}' | sed 's/\\(.\\{12,16\\}\\).*/\\1/'; done | sort | uniq")
	repeat with promocode in promocodes
		set code_used to "false"
		repeat with used_code in used_codes
			if promocode as string is used_code as string then
				set code_used to "true"
			end if
		end repeat
		if code_used is "false" then
			tell application "iTunes"
				display dialog "Found a new code: " &#038; promocode &#038; " - use it now?"
				launch
				activate
				copy promocode to the end of used_codes
				set used_codes to used_codes &#038; promocode
				open location "itmss://phobos.apple.com/WebObjects/MZFinance.woa/wa/freeProductCodeWizard?code=" &#038; promocode
			end tell
		end if
	end repeat
	return 30
end idle
</pre>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2010/12/23/automagic-promo-code-redeemer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Palm webOS (formerly Palm Pre) Development Bundle for TextMate 0.3</title>
		<link>http://devilx.net/2009/11/13/palm-webos-formerly-palm-pre-development-bundle-for-textmate-0-3/</link>
		<comments>http://devilx.net/2009/11/13/palm-webos-formerly-palm-pre-development-bundle-for-textmate-0-3/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 23:45:23 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Mac and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[This Site]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[Austin Powers]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bundle]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Mojo]]></category>
		<category><![CDATA[Palm]]></category>
		<category><![CDATA[Pre]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[webOS]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=1077</guid>
		<description><![CDATA[Releasing version 0.3 of my Palm webOS development bundle for TextMate, with plenty new features and a stand-alone &#8220;Mojo&#8221;-language. So, what&#8217;s new in 0.3? Well, just about everything. I&#8217;ve renamed the bundle (at least its metadata), since webOS is not &#8230; <a href="http://devilx.net/2009/11/13/palm-webos-formerly-palm-pre-development-bundle-for-textmate-0-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.devilx.net/wp-content/uploads/2009/11/Palm-webOS-0.3.png"><img class="alignleft size-thumbnail wp-image-1079" title="Palm webOS 0.3" src="http://www.devilx.net/wp-content/uploads/2009/11/Palm-webOS-0.3-150x150.png" alt="Palm webOS 0.3" width="150" height="150" /></a>Releasing version 0.3 of my Palm webOS development bundle for TextMate, with plenty new features and a stand-alone &#8220;Mojo&#8221;-language.</p>
<p>So, what&#8217;s new in 0.3? Well, just about everything. I&#8217;ve renamed the bundle (at least its metadata), since webOS is not just limited to the Pre and I&#8217;ve modified the shortcuts of existing features to fit TextMate&#8217;s styling guidelines a bit better. I&#8217;ve also created some snippets which can be used for faster code-writing now and in addition to that, I&#8217;ve implemented a very own language for the bundle, which can&#8217;t be found in the document type picker named as &#8220;Mojo&#8221;. &#8220;Yeah baby!&#8221;, as Austin would say now. Actually, yet it&#8217;s just a copy &amp; paste of the JavaScript-language implementation in TextMate, but I&#8217;m planning to extend it to fit the Mojo-framework even better.</p>
<p>The TextMate bundle is now also available on <a title="devilx's palm-webos-development-tmbundle" href="http://github.com/devilx/palm-webos-development-tmbundle">GitHub</a>, for everyone who can&#8217;t wait for me packaging the releases and releasing them here. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> If you have any ideas for improvement, feel free to contact me by mail or just leave some lines here on my blog.</p>
<p>Enjoy!</p>
<p><strong><span style="text-decoration: line-through;">Download: </span><a href="http://www.devilx.net/wp-content/uploads/2009/11/Palm_webOS-Bundle-0.3.zip"><span style="text-decoration: line-through;">Palm_webOS-Bundle-0.3</span></a></strong></p>
<p><strong>Download: <a href="http://www.devilx.net/wp-content/uploads/2009/11/Palm_webOS-Bundle-0.31.zip">Palm_webOS-Bundle-0.3</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2009/11/13/palm-webos-formerly-palm-pre-development-bundle-for-textmate-0-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>iStat My Linux on My Phone</title>
		<link>http://devilx.net/2009/08/24/istat-my-linux-on-my-phone/</link>
		<comments>http://devilx.net/2009/08/24/istat-my-linux-on-my-phone/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 17:44:03 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[Mac and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[iStat]]></category>
		<category><![CDATA[Lenny]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Package]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=952</guid>
		<description><![CDATA[After checking out bjango&#8217;s web-site again after a long time, to check out the status of the &#8220;remote vital statistics&#8221; project called &#8220;iStat for iPhone&#8221;, I was suprised to see an iStat Server for Linux (and Solaris, and FreeBSD, &#8230;). &#8230; <a href="http://devilx.net/2009/08/24/istat-my-linux-on-my-phone/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After checking out <a title="iStat, an iPhone app by Bjango" href="http://bjango.com/apps/istat/">bjango&#8217;s web-site</a> again after a long time, to check out the status of the &#8220;remote vital statistics&#8221; project called &#8220;iStat for iPhone&#8221;, I was suprised to see an iStat Server for Linux (and Solaris, and FreeBSD, &#8230;).</p>
<p>The last time I check out the project, there was no such daemon for Unix(-like) platforms but Mac OS X itself. I decided to take a quick look at the independend <a title="istatd" href="http://code.google.com/p/istatd/">istatd Project on Google Code</a> and give it a shot. I fetched the sources, built them on a Debian Lenny and ran the daemon with a slighly modified configuration &#8211; and it worked! <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>I found it pretty cool. Actually, I found it so cool that it was the reason for me to buy the actual iPhone App. I have no Mac OS X Servers I&#8217;d like to monitor, but I could think of plenty of Linux machines which I&#8217;d like to keep an eye on &#8211; not as an replacement for Nagios, just as a solution for quick-live-monitoring.</p>
<p>However, I decided to build a Debian package, to make it easier to deploy the istatd on a couple of machines. I attached the Debian package to this post, so you can just download and install it on your Lenny machines. Warning: It&#8217;s not a clean and tidy built, lintian conform packge! I just hacked it together to have something that &#8220;just works&#8221;. And that&#8217;s what it actually should. Besides, be warned that the daemon takes quite long to shut-down, due to the fact that I&#8217;ve just used the regular /etc/init.d/skeleton to create an own /etc/init.d/istatd script, without going into deep workflow-checks. Here, the script takes something around half a minute to kill the istatd.</p>
<p>Anyway, now I&#8217;m going to take a look at the sources and see, if I could probably commit some enhancements to the projects. The last time I was doing C++ is *quite* a time ago, but it shouldn&#8217;t be too hard from what I&#8217;ve seen so far. On the project&#8217;s site it says that there&#8217;s no support for fans and temperature measuring, yet. I will check whether it&#8217;s possible to use lmsensors for getting those information and maybe hack it in &#8211; or even rewrite the daemon in C, what would be the best to do anyway. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/wink.png' alt=';-)' class='wp-smiley' /> </p>
<p>Oh well, however. Enjoy the package. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Download:</strong> <a href="http://www.devilx.net/wp-content/uploads/2009/08/istatd_0.5.4-1_i386.deb">istatd_0.5.4-1_i386.deb</a></p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2009/08/24/istat-my-linux-on-my-phone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>REX: Sources Released!</title>
		<link>http://devilx.net/2008/05/07/rex-sources-released/</link>
		<comments>http://devilx.net/2008/05/07/rex-sources-released/#comments</comments>
		<pubDate>Wed, 07 May 2008 11:20:50 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Car]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[REX]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=408</guid>
		<description><![CDATA[Just a little info: I finally managed to release the sources (MonoDevelop project) for my REX User-Interface software. You can now find them in version 0.1 on the REX Project-Page. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>Just a little info: I finally managed to release the sources (MonoDevelop project) for my REX User-Interface software. You can now find them in version 0.1 on the <a title="REX" href="http://rex.devilx.net" target="_self">REX Project-Page</a>. Enjoy! <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2008/05/07/rex-sources-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

