<?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>FLX &#187; Code Snippet of the Week</title>
	<atom:link href="http://flx.me/category/code-snippet-of-the-week/feed/" rel="self" type="application/rss+xml" />
	<link>http://flx.me</link>
	<description>rambles, code and science!</description>
	<lastBuildDate>Fri, 17 Dec 2010 23:33:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Command line snippet of the week: 3</title>
		<link>http://flx.me/command-line-snippet-of-the-week-3/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-3/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 13:59:35 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>

		<guid isPermaLink="false">http://flx.me/?p=597</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice to check if a program is running? You can do that and make it start conditionally if it isn&#8217;t running. Very handy for service daemons that always need to be running. Can be used with cron as well: ps -C servicedaemon &#124;&#124; { servicedaemon &#038; } Replace servicedaemon with your own [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice to check if a program is running? You can do that and make it start conditionally if it isn&#8217;t running. Very handy for service daemons that always need to be running. Can be used with cron as well:</p>
<pre lang="bash">ps -C servicedaemon || { servicedaemon &#038; }</pre>
<p>Replace<strong> servicedaemon</strong> with your own process that needs to be checked. The second servicedaemon value describes what program it needs to start if it&#8217;s not running.</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 2</title>
		<link>http://flx.me/command-line-snippet-of-the-week-2/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-2/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 13:34:47 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>

		<guid isPermaLink="false">http://flx.me/?p=593</guid>
		<description><![CDATA[The snippet this week will be about copying arguments without retyping everything. It would be easier to show you how this works: $ cd /home/user/flx cd: /home/user/flx: No such file or directory $ mkdir !* mkdir /home/user/flx By using !* it repeats all arguments previously used. If you only want to use the second argument [...]]]></description>
			<content:encoded><![CDATA[<p>The snippet this week will be about copying arguments without retyping everything. It would be easier to show you how this works:</p>
<pre lang="bash">$ cd /home/user/flx
cd: /home/user/flx: No such file or directory
$ mkdir !*
mkdir /home/user/flx</pre>
<p>By using <strong>!*</strong> it repeats all arguments previously used. If you only want to use the second argument for example, you use <strong>!:2</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 1</title>
		<link>http://flx.me/command-line-snippet-of-the-week-1/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-1/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 13:32:15 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>

		<guid isPermaLink="false">http://flx.me/?p=590</guid>
		<description><![CDATA[New year, new snippets! Belated good wishes from me as well :-) Anyway, this week&#8217;s snippet is on basic steganography. In this case we would like to hide a rar file in a image, we can do that by doing the following: cat picture.png archive.rar > hidden_archive_in_pic.png This will create a valid png image for [...]]]></description>
			<content:encoded><![CDATA[<p>New year, new snippets! Belated good wishes from me as well :-)</p>
<p>Anyway, this week&#8217;s snippet is on basic <a href="http://en.wikipedia.org/wiki/Steganography">steganography</a>. In this case we would like to hide a rar file in a image, we can do that by doing the following:</p>
<pre lang="bash">cat picture.png archive.rar > hidden_archive_in_pic.png</pre>
<p>This will create a valid png image for viewing with a secret rar file inside!<br />
When you want to retrieve the hidden files, download the image, rename to .rar and extract.</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 53</title>
		<link>http://flx.me/command-line-snippet-of-the-week-53/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-53/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 14:00:39 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://flx.me/?p=303</guid>
		<description><![CDATA[Last one of this year! Need to mass extract several RAR archives from different folders? Create a file called &#8220;massunrar&#8221; in /usr/bin and paste the following content: find . -type f -name *.r01 -exec unrar e {} \; find . -type f -name *.part01.rar -exec unrar e {} \; echo "Found files:" find . -type [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><strong>Last one of this year!</strong></p>
<p style="text-align: left;">Need to mass extract several RAR archives from different folders? Create a file called &#8220;massunrar&#8221; in /usr/bin and paste the following content:</p>
<pre lang="bash">find . -type f -name *.r01 -exec unrar e {} \;
find . -type f -name *.part01.rar -exec unrar e {} \;
echo "Found files:"
find . -type f -name *.r01
find . -type f -name *.part01.rar</pre>
<p>Be sure to chmod &#8220;massunrar&#8221; to make it executable:</p>
<pre lang="bash">chmod +x /usr/bin/massunrar</pre>
<p>Run &#8220;massunrar&#8221; in the parent folder to let it search for rar files in all subdirectories and extract them.<br />
More to follow next year!</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-53/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 52</title>
		<link>http://flx.me/command-line-snippet-of-the-week-52/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-52/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 14:00:19 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://flx.me/?p=301</guid>
		<description><![CDATA[Need to have IP location information? Use: curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" &#124; sed '/^IP:/!d;s/][^>]*>//g' It returns with your IP information such as: IP: 13.13.133.713 Location: Amsterdam, NOORD-HOLLAND, Netherlands (N.V. XS4ALL) Replace (curl -s icanhazip.com) to show a different IP than your own.]]></description>
			<content:encoded><![CDATA[<p>Need to have IP location information? Use:</p>
<pre lang="bash">curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" | sed '/^IP:/!d;s/<[^>][^>]*>//g'</pre>
<p>It returns with your IP information such as:</p>
<pre lang="bash">IP: 13.13.133.713 Location: Amsterdam, NOORD-HOLLAND, Netherlands   (N.V. XS4ALL)</pre>
<p>Replace <em><strong>(curl -s icanhazip.com)</strong></em> to show a different IP than your own.</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-52/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 51</title>
		<link>http://flx.me/command-line-snippet-of-the-week-51/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-51/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 14:00:23 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://flx.me/?p=297</guid>
		<description><![CDATA[Need to empty a file fast? Try: > file.txt Shortest emptier in town!]]></description>
			<content:encoded><![CDATA[<p>Need to empty a file fast? Try:</p>
<pre lang="bash">> file.txt</pre>
<p>Shortest emptier in town!</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-51/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 50</title>
		<link>http://flx.me/command-line-snippet-of-the-week-50/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-50/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 14:00:40 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://flx.me/?p=293</guid>
		<description><![CDATA[Forget that your running as underprivileged? No need to retype the command: > command_with_insufficient_permissions Permission denied sudo !! The !! parameter repeats the previous command, thus no need to retype! Source: shell-fu]]></description>
			<content:encoded><![CDATA[<p>Forget that your running as underprivileged? No need to retype the command:</p>
<p>> command_with_insufficient_permissions<br />
Permission denied</p>
<pre lang="bash">sudo !!</pre>
<p>The <em>!!</em> parameter repeats the previous command, thus no need to retype!</p>
<p>Source: <a href="http://www.shell-fu.org">shell-fu</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-50/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 49</title>
		<link>http://flx.me/command-line-snippet-of-the-week-49/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-49/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 14:00:57 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://flx.me/?p=291</guid>
		<description><![CDATA[Want to show something on your machine to someone over the web? Don&#8217;t copy it or upload it somewhere, try this command (requires Python): alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"' Just run &#8220;webshare&#8221; and the current directory and everything beneath it will be served from a new web server listening on port 8000. When you are [...]]]></description>
			<content:encoded><![CDATA[<p>Want to show something on your machine to someone over the web? Don&#8217;t copy it or upload it somewhere, try this command (requires <a href="http://python.org">Python</a>):</p>
<pre lang="bash">alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'</pre>
<p>Just run &#8220;webshare&#8221; and the current directory and everything beneath it will be served from a new web server listening on port 8000. When you are finished, just hit control-c to close the webserver.</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-49/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line snippet of the week: 48</title>
		<link>http://flx.me/command-line-snippet-of-the-week-48/</link>
		<comments>http://flx.me/command-line-snippet-of-the-week-48/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 14:05:22 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://flx.me/?p=287</guid>
		<description><![CDATA[Hate having to remember all switches for each different unpacker? You can fix that! Create a new file in /usr/bin/ called &#8220;extract&#8221; and paste the following code: if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 [...]]]></description>
			<content:encoded><![CDATA[<p>Hate having to remember all switches for each different unpacker? You can fix that!<br />
Create a new file in /usr/bin/ called &#8220;extract&#8221; and paste the following code:</p>
<pre lang="bash">if [ -f $1 ] ; then
case $1 in
    *.tar.bz2)   tar xvjf $1        ;;
    *.tar.gz)    tar xvzf $1     ;;
    *.bz2)       bunzip2 $1       ;;
    *.rar)       unrar x $1     ;;
    *.gz)        gunzip $1     ;;
    *.tar)       tar xvf $1        ;;
    *.tbz2)      tar xvjf $1      ;;
    *.tgz)       tar xvzf $1       ;;
    *.zip)       unzip $1     ;;
    *.Z)         uncompress $1  ;;
    *.7z)        7z x $1    ;;
    *)           echo "'$1' cannot be extracted via &gt;extract&lt;" ;;
esac
else
echo "'$1' is not a valid file"
fi</pre>
<p>be sure to chmod it to executable:</p>
<pre lang="bash">chmod +x /usr/bin/extract</pre>
<p>This code will save you time by extracting almost any kind of archive by using the command:</p>
<pre lang="bash">extract my_awesome_archive.tar.gz</pre>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/command-line-snippet-of-the-week-48/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

