<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
	<title><![CDATA[davelens.be]]></title>
	<link>http://code.davelens.be/blog?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=davelens-be</link>
	<description>
		<![CDATA[
		A backlog of coding tidbits and shenanigans
		]]>
</description>
	<image>
		<title><![CDATA[davelens.be]]></title>
		<url>http://code.davelens.be/frontend/core/layout/images/rss_image.png</url>
		<link>http://code.davelens.be/blog?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=davelens-be</link>
	</image>
	<lastBuildDate>Sun, 20 May 2012 19:36:46 +0200</lastBuildDate>
	<pubDate>Sun, 20 May 2012 19:36:46 +0200</pubDate>
	<copyright>2012 code.davelens.be</copyright>
	<generator><![CDATA[Fork CMS]]></generator>
	<language>en</language>
<item>
	<title><![CDATA[Exclude a list of files with rsync]]></title>
	<link>http://code.davelens.be/blog/detail/exclude-a-list-of-files-with-rsync?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=exclude-a-list-of-files-with-rsync</link>
	<description>
		<![CDATA[
			<p>Most of you will be familiar with rsync - a nice little *nix tool that syncs files between a given source and destination. Its original purpose was to allow an easy way of creating backups from a multitude of *nix clients to a single server.</p>
<p>Depending on your workspace you might want to always skip a series of source files before sending them over. You can do this easily with the <em>--exclude-from=/path/to/exclude/folder</em> parameter.</p>
<p>In my <a href="http://github.com/davelens/dotfiles?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=exclude-a-list-of-files-with-rsync">dotfiles</a> I made an alias for rsync that incorporates this param, so every sync I execute will only push the files I want it to.</p>
<pre class="brush: bash">alias rsync='rsync --exclude-from=$HOME/.bin/rsync-exclude-list.txt'
</pre>
<p>Example of an rsync-exclude-list.txt:</p>
<pre class="brush: bash">.svn/ 
files/ 
cache/ 
install/ 
.DS_Store 
Thumbs.db
</pre>
<p>So every time I use rsync, it would effectively ignore all matches in the file above. You can still use any parameters freely:</p>
<pre class="brush: bash">rsync -vurn www/ davelens.be:www/
</pre><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/exclude-a-list-of-files-with-rsync?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=exclude-a-list-of-files-with-rsync" title="Exclude a list of files with rsync">Exclude a list of files with rsync</a> written by Dave in <a href="http://code.davelens.be/blog/category/cli?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=exclude-a-list-of-files-with-rsync" title="CLI">CLI</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Fri, 03 Feb 2012 15:00:00 +0100</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[CLI]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/exclude-a-list-of-files-with-rsync</guid>
	</item>
<item>
	<title><![CDATA[Extract files recursively from child folders in the current directory]]></title>
	<link>http://code.davelens.be/blog/detail/extract-files-recursively-from-child-folders-in-the-current-directory?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=extract-files-recursively-from-child-folders-in-the-current-directory</link>
	<description>
		<![CDATA[
			<p>Yesterday I was rearranging my photo albums, and decided to get rid of my old folder structure. All files were located into several nested directories, and I needed to collect all .jpg files into one directory so I could start rearranging them into new albums in iPhoto. The <em>find</em> command-line tool can do this in a simple one-liner. I will show you the build-up:</p>
<pre class="brush: bash;">find . -type f -name '*.jpg'
</pre>
<p>This will recursively search all folders in the active directory in order to return a list of matching file locations. <strong>-type f</strong> means we're looking for files. <strong>-name</strong> accepts a search query, which may contain wildcards.</p>
<p>We could now pipe the line above to work with the output, but <em>find</em> has built-in functionality in the form of the <strong>-exec</strong> parameter. So the end result will be:</p>
<pre class="brush: bash;">find . -type f -name '*.jpg' -exec mv -fv '{}' '.' ';'
</pre>
<p>This loops all lines of the output and initiates a <em>mv</em> command on the active line in the loop (<strong>'{}'</strong>), and moves them to the specified destination folder (<strong>'.'</strong>)</p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/extract-files-recursively-from-child-folders-in-the-current-directory?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=extract-files-recursively-from-child-folders-in-the-current-directory" title="Extract files recursively from child folders in the current directory">Extract files recursively from child folders in the current directory</a> written by Dave in <a href="http://code.davelens.be/blog/category/cli?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=extract-files-recursively-from-child-folders-in-the-current-directory" title="CLI">CLI</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Sat, 06 Aug 2011 13:00:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[CLI]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/extract-files-recursively-from-child-folders-in-the-current-directory</guid>
	</item>
<item>
	<title><![CDATA[Testing your REST-services in the commandline]]></title>
	<link>http://code.davelens.be/blog/detail/testing-your-rest-services-in-the-commandline?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=testing-your-rest-services-in-the-commandline</link>
	<description>
		<![CDATA[
			<p>Developing a REST API often requires requests to be accessible with a specific request method; GET to retrieve data, POST to send data and DELETE to indicate a removal of data. If there is time you could write a client with a basic gui to accomplish this, or you could test it by using the commandline and cURL. I've made a small alias method to do just that:</p>
<pre class="brush: bash">curlrest()
{
	method=$1
	url=$2
	parameters=$3

	if [[ "$method" == "" ]] || [[ "$url" == "" ]]
	then
		echo "usage: curlrest <method> <url> <*parameters>"
	else
		if [[ "$parameters" != "" ]]
		then
			parameters="--data-urlencode $(echo $parameters | xargs | sed 's/&/ --data-urlencode /g')"
		fi
	
		curl -v --globoff --get -X$method $url $parameters
		echo ""
	fi
}
</pre>
<p>The key here is the combination of the --get and -X parameters of cURL. It allows you to overwrite the request method with whatever string you like, and send any additional parameters along as GET data.</p>
<p>I realise this is cheating and technically not a correct way to do it (+ sending files with PUT is not testable this way), but I find it an effective way to quickly test API responses to any other request during development.</p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/testing-your-rest-services-in-the-commandline?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=testing-your-rest-services-in-the-commandline" title="Testing your REST-services in the commandline">Testing your REST-services in the commandline</a> written by Dave in <a href="http://code.davelens.be/blog/category/cli?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=testing-your-rest-services-in-the-commandline" title="CLI">CLI</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Sat, 30 Jul 2011 18:00:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[CLI]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/testing-your-rest-services-in-the-commandline</guid>
	</item>
<item>
	<title><![CDATA[Zend Studio 8 - Fixing that white gutter in dark colourschemes]]></title>
	<link>http://code.davelens.be/blog/detail/zend-studio-8-fixing-that-white-gutter-in-dark-colourschemes?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=zend-studio-8-fixing-that-white-gutter-in-dark-colourschemes</link>
	<description>
		<![CDATA[
			<p>When you switch from a white colourscheme to a dark one in Zend Studio 8, there's a 10px wide gutter that remains white no matter what you do. Restarting doesn't help either.</p>
<p>What you need to do to fix it is very simple; disable & re-enable the code folding in the preferences.</p>
<p><img src="http://code.davelens.be/screenshots/2011-07-16-01-54-31.png" alt="" height="194" width="366" /></p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/zend-studio-8-fixing-that-white-gutter-in-dark-colourschemes?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=zend-studio-8-fixing-that-white-gutter-in-dark-colourschemes" title="Zend Studio 8 - Fixing that white gutter in dark colourschemes">Zend Studio 8 - Fixing that white gutter in dark colourschemes</a> written by Dave in <a href="http://code.davelens.be/blog/category/php?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=zend-studio-8-fixing-that-white-gutter-in-dark-colourschemes" title="PHP">PHP</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Sat, 16 Jul 2011 01:55:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[PHP]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/zend-studio-8-fixing-that-white-gutter-in-dark-colourschemes</guid>
	</item>
<item>
	<title><![CDATA[Get a human-readable list of file sizes in the current directory]]></title>
	<link>http://code.davelens.be/blog/detail/get-a-human-readable-list-of-file-sizes-in-the-current-directory?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=get-a-human-readable-list-of-file-sizes-in-the-current-directory</link>
	<description>
		<![CDATA[
			<p>On occasion I have need in the unix shell to display all files in a folder <strong>without</strong> directories. Sometimes it's useful to show their filesizes too, sorted descending by size. This is convenient for instance in a large folder of images, where you want to see which ones are diskspace-hogs.</p>
<p>I'll build it up step by step, and explain each part so you understand the three core methods used here.</p>
<pre class="brush: bash;">ls -laSh</pre>
<p>You know what ls does. For a rundown of the parameters I'll refer you to <em>man ls</em> which explains it much better than I do. Suffice to say that it generates a list of all files and folders in the active directory (including names starting with .), sorted descending by filesize in human-readable notation.</p>
<pre class="brush: bash;">ls -laSh | grep -v ^d</pre>
<p>The piped grep does an inverse selection (-v) of all results of <em>ls -l</em> starting with "d". So we effectively end up with all files, excluding the directories.</p>
<pre class="brush: bash;">ls -laSh | grep -v ^d | awk '{print $5 "\t" $9}'</pre>
<p>We already have our desired result at this point, but we want to cut away the information we don't want to see. What the piped awk basicly does is "show me column 5 and 9 of the output, separated by a tab".</p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/get-a-human-readable-list-of-file-sizes-in-the-current-directory?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=get-a-human-readable-list-of-file-sizes-in-the-current-directory" title="Get a human-readable list of file sizes in the current directory">Get a human-readable list of file sizes in the current directory</a> written by Dave in <a href="http://code.davelens.be/blog/category/cli?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=get-a-human-readable-list-of-file-sizes-in-the-current-directory" title="CLI">CLI</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Fri, 01 Jul 2011 13:00:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[CLI]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/get-a-human-readable-list-of-file-sizes-in-the-current-directory</guid>
	</item>
<item>
	<title><![CDATA[Let the shell ignore cases when browsing directories]]></title>
	<link>http://code.davelens.be/blog/detail/let-the-shell-ignore-cases-when-browsing-directories?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=let-the-shell-ignore-cases-when-browsing-directories</link>
	<description>
		<![CDATA[
			<p>The default Terminal behaviour while browsing folders is to be case-sensitive. Luckily you can easily disable this by adding an .inputrc file to your user dir and put the following in it:</p>
<pre class="brush: bash">set completion-ignore-case on
</pre>
<p>run a <em>source .inputrc</em> and you're good to go!</p>
<p>Thanks to <a href="http://www.twitter.com/janmoesen?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=let-the-shell-ignore-cases-when-browsing-directories">@janmoesen</a> for pointing this out to me.</p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/let-the-shell-ignore-cases-when-browsing-directories?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=let-the-shell-ignore-cases-when-browsing-directories" title="Let the shell ignore cases when browsing directories">Let the shell ignore cases when browsing directories</a> written by Dave in <a href="http://code.davelens.be/blog/category/cli?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=let-the-shell-ignore-cases-when-browsing-directories" title="CLI">CLI</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Fri, 24 Jun 2011 12:01:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[CLI]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/let-the-shell-ignore-cases-when-browsing-directories</guid>
	</item>
<item>
	<title><![CDATA[SVN export all changed files between two revisions in a tarball]]></title>
	<link>http://code.davelens.be/blog/detail/svn-export-all-changed-files-between-two-revisions-in-a-tarball?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=svn-export-all-changed-files-between-two-revisions-in-a-tarball</link>
	<description>
		<![CDATA[
			<p>Not a default functionality in SVN, but it should be. Exporting changes between two revisions is however possible through CLI. Put the function below into your .bash_profile and run <em>source .bash_profile</em> afterwards.</p>
<pre class="brush: bash">svnecf()
{
        tarfile=$1
        start_rev=$2
        end_rev=$3
        
        if [[ "$end_rev" == "" ]]; then
                 end_rev='HEAD'
        fi
        
        svn diff -r "$start_rev":"$end_rev" --summarize |
        awk '{if ($1 != "D") print $2}'|   
        xargs  -I {} tar -rvf "$tarfile" {}
}
</pre>
<p>Then go to your local working copy and run it like this:</p>
<pre class="brush: bash">svnecf ~/Desktop/exported_changes.tar 150
</pre>
<p>You'll now have a a tarball with your exported changes on your desktop. Note that if you don't specify an ending revision it will compare the given starting revision to the HEAD.</p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/svn-export-all-changed-files-between-two-revisions-in-a-tarball?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=svn-export-all-changed-files-between-two-revisions-in-a-tarball" title="SVN export all changed files between two revisions in a tarball">SVN export all changed files between two revisions in a tarball</a> written by Dave in <a href="http://code.davelens.be/blog/category/cli?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=svn-export-all-changed-files-between-two-revisions-in-a-tarball" title="CLI">CLI</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Tue, 21 Jun 2011 16:51:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[CLI]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/svn-export-all-changed-files-between-two-revisions-in-a-tarball</guid>
	</item>
<item>
	<title><![CDATA[My mac config on Github]]></title>
	<link>http://code.davelens.be/blog/detail/my-mac-config-on-github?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=my-mac-config-on-github</link>
	<description>
		<![CDATA[
			<p>I recently did a format on my Mac for a fresh start (it's been two years), and found myself putting too much time into resetting my config the way I like it. After pondering for a bit on how to avoid this (without resorting to the bloated Time Machine), I stumbled upon <a href="https://github.com/garybernhardt/dotfiles/" rel="nofollow">Gary Bernhardt's dotfiles on github</a> and found an instant and obvious answer to my predicament.</p>
<p>The idea behind it is that you maintain a git repo in your Mac's user dir, containing all relevant config files. All I have to do after running a format is pulling it all back into my user dir and I'm good to go.</p>
<p>You can find my config at <a href="http://github.com/davelens/config?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=my-mac-config-on-github">http://github.com/davelens/config</a>.</p><div class="meta">
	<p><a href="http://code.davelens.be/blog/detail/my-mac-config-on-github?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=my-mac-config-on-github" title="My mac config on Github">My mac config on Github</a> written by Dave in <a href="http://code.davelens.be/blog/category/mac?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=my-mac-config-on-github" title="Mac">Mac</a>.</p>
</div>

		]]>
	</description>
	<pubDate>Mon, 20 Jun 2011 20:55:00 +0200</pubDate>
	<author><![CDATA[dave@example.com (Dave)]]></author>
	<category><![CDATA[Mac]]></category>
	<guid isPermaLink="true">http://code.davelens.be/blog/detail/my-mac-config-on-github</guid>
	</item>
</channel>
</rss>

