<?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>Claus Witt &#187; Development</title> <atom:link href="http://www.clauswitt.com/category/development/feed/" rel="self" type="application/rss+xml" /><link>http://www.clauswitt.com</link> <description>software and web developer</description> <lastBuildDate>Thu, 24 Jun 2010 20:07:03 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Project Euler Problem Five</title><link>http://www.clauswitt.com/project-euler-problem-five/</link> <comments>http://www.clauswitt.com/project-euler-problem-five/#comments</comments> <pubDate>Mon, 07 Jun 2010 06:30:37 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[evenly divisable]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[nodejs]]></category> <category><![CDATA[problem five]]></category> <category><![CDATA[project euler]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=398</guid> <description><![CDATA[Continuing our combined node.js and project euler posts. We got to problem five, which asks us &#8220;What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?&#8221;. First of all we only check numbers below or equal to 20! because we know for sure that this number [...]]]></description> <content:encoded><![CDATA[<p>Continuing our combined <a href="http://nodejs.org">node.js</a> and <a href="http://www.clauswitt.com/tag/project-euler/">project euler posts</a>. We got to <a href="http://projecteuler.net/index.php?section=problems&#038;id=5">problem five</a>, which asks us &#8220;What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?&#8221;.</p><p>First of all we only check numbers below or equal to 20! because we know for sure that this number will satisfy the criterium of the question, we just don&#8217;t know if there is a result below this number, we also know that the number must be at least 20. For this reason we check all numbers between 20 and 20! if all numbers between 1 and 20 is a divisor &#8211; if one of the numbers fail, we move on to the next candidate. As soon as a candidate proves to be correct, we exit and return the result.</p> <script src="http://gist.github.com/420267.js"></script> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/project-euler-problem-five/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Project Euler Problem Four</title><link>http://www.clauswitt.com/project-euler-problem-four/</link> <comments>http://www.clauswitt.com/project-euler-problem-four/#comments</comments> <pubDate>Fri, 04 Jun 2010 06:00:34 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[largest palindrome]]></category> <category><![CDATA[problem four]]></category> <category><![CDATA[project euler]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=390</guid> <description><![CDATA[Find the largest palindrome made from the product of two 3-digit numbers. This is problem four of project euler, and this one actually caused me some problems. The reason was that I wrongly assumed that a number with the largest divisor would also would be the largest number. But of course this is not necessarily [...]]]></description> <content:encoded><![CDATA[<p>Find the largest palindrome made from the product of two 3-digit numbers. This is <a href="http://projecteuler.net/index.php?section=problems&#038;id=4">problem four of project euler</a>, and this one actually caused me some problems. The reason was that I wrongly assumed that a number with the largest divisor would also would be the largest number. But of course this is not necessarily the case.</p> <script src="http://gist.github.com/418472.js"></script> <p>As the <a href="http://www.clauswitt.com/project-euler-problem-one/">previous</a> <a href="http://www.clauswitt.com/project-euler-problem-two/">three</a> <a href="http://www.clauswitt.com/project-euler-problem-three/">problems</a> I have posted about, this is written to run on <a href="http://nodejs.org">node.js</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/project-euler-problem-four/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>From Subversion to Git</title><link>http://www.clauswitt.com/from-subversion-to-git/</link> <comments>http://www.clauswitt.com/from-subversion-to-git/#comments</comments> <pubDate>Wed, 02 Jun 2010 11:00:33 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[git]]></category> <category><![CDATA[github]]></category> <category><![CDATA[projects]]></category> <category><![CDATA[subversion]]></category> <category><![CDATA[using git]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=395</guid> <description><![CDATA[This past weekend I moved our work repositories from Subversion to Git. I have been using Git for my private projects for a couple of months now, and really wanted the same workflow and features for my daily work at VoiceArchive. Installing gitosis Even though I use github privately, I opted for the selfhosted version for our [...]]]></description> <content:encoded><![CDATA[<p>This past weekend I moved our work repositories from Subversion to Git. I have been using Git for my private projects for a couple of months now, and really wanted the same workflow and features for my daily work at VoiceArchive.</p><p><strong>Installing gitosis</strong><br /> Even though I use github privately, I opted for the selfhosted version for our work-repositories. The reasoning behind this was mostly that we host our own subversion repo&#8217;s today, then we could just as well host our own git repo&#8217;s. (This also made the change possible without needing the company to pay more for hosting than we allready do).</p><p>I will not go through the installation, but just link to <a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way">this excellent guide</a> I followed to get everything up and running.</p><p><strong>Creating repositories</strong><br /> When all users, roles and repositories have been saved in the file gitosis.conf &#8211; you are able to create local repositories for your projects and push the to the server. (This works just as with github, btw). Again instead of showing you an example I recommend <a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way">the guide I used</a>.</p><p><strong>Exporting from subversion</strong><br /> The easiest part was exporting from subversion and commiting in git. Only downside was that the repository history was lost. But I still have the subversion repos as a backup, if I need them in the future.</p> <script src="http://gist.github.com/420247.js"></script> <p><strong>Final thoughts</strong><br /> We are running Redmine and Hudson on our dev-server. Both were setup to use the git repository instead of the svn repo in just under 30 minutes. (And that included 5 projects). Apart from some splitting up of projects into minor parts this was pretty straightforward.</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/from-subversion-to-git/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Project Euler Problem Three</title><link>http://www.clauswitt.com/project-euler-problem-three/</link> <comments>http://www.clauswitt.com/project-euler-problem-three/#comments</comments> <pubDate>Tue, 01 Jun 2010 06:00:54 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[nodejs]]></category> <category><![CDATA[problem three]]></category> <category><![CDATA[project euler]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=388</guid> <description><![CDATA[Continuing my posts about Project Euler Problems, this time with problem three, which asks us to find the &#8220;the largest prime factor of the number 600851475143&#8243;. This time I have decided to explain the code a bit more, through comments &#8211; since this problem is a bit more tricky than the previous two problems. Once [...]]]></description> <content:encoded><![CDATA[<p>Continuing my posts about <a href="http://projecteuler.net/index.php?section=problems">Project Euler Problems</a>, this time with <a href="http://projecteuler.net/index.php?section=problems&#038;id=3">problem three</a>, which asks us to find the &#8220;the largest prime factor of the number 600851475143&#8243;.</p><p>This time I have decided to explain the code a bit more, through comments &#8211; since this problem is a bit more tricky than the previous two problems.</p> <script src="http://gist.github.com/418464.js"></script> <p>Once again, you will need node.js to run the code.</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/project-euler-problem-three/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Project Euler Problem Two</title><link>http://www.clauswitt.com/project-euler-problem-two/</link> <comments>http://www.clauswitt.com/project-euler-problem-two/#comments</comments> <pubDate>Sun, 30 May 2010 09:00:51 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[euler]]></category> <category><![CDATA[fibonacci]]></category> <category><![CDATA[nodejs]]></category> <category><![CDATA[problem two]]></category> <category><![CDATA[project euler]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=386</guid> <description><![CDATA[Yesterday I posted my first euler-code. This time we will take a look at problem two, again with the help of some javascript running on node.js. The problem is &#8220;Find the sum of all the even-valued terms in the [fibonacci] sequence which do not exceed four million.&#8221; My take on the solution was to [...]]]></description> <content:encoded><![CDATA[<p>Yesterday I posted <a href="http://www.clauswitt.com/project-euler-problem-one/">my first euler-code</a>. This time we will take a look at <a href="http://projecteuler.net/index.php?section=problems&amp;id=2">problem two</a>, again with the help of some javascript running on node.js.</p><p>The problem is &#8220;Find the sum of all the even-valued terms in the [fibonacci] sequence which do not exceed four million.&#8221;</p><p>My take on the solution was to run through all fibonacci numbers below 4.000.000 and adding them to the total, if they were equal. The next fibonacci number is calculated by always saving the last two numbers found.</p> <script src="http://gist.github.com/418453.js"></script> <p>You will need node.js to run this code.</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/project-euler-problem-two/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Project Euler Problem One</title><link>http://www.clauswitt.com/project-euler-problem-one/</link> <comments>http://www.clauswitt.com/project-euler-problem-one/#comments</comments> <pubDate>Sat, 29 May 2010 18:55:17 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[nodejs]]></category> <category><![CDATA[project euler]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=365</guid> <description><![CDATA[A long time ago I decided to do a couple of posts about project euler. I find the problems to be great excersize. It was not before I began to look into node.js though, that I began writing code for the problems for the purpose of publishing it. The first problem on the list is [...]]]></description> <content:encoded><![CDATA[<p>A long time ago I decided to do a couple of posts about <a href="http://projecteuler.net/">project euler</a>. I find <a href="http://projecteuler.net/index.php?section=problems">the problems</a> to be great excersize. It was not before I began to look into <a href="http://nodejs.org/">node.js</a> though, that I began writing code for the problems for the purpose of publishing it.</p><p><a href="http://projecteuler.net/index.php?section=problems&#038;id=1">The first problem</a> on the list is very simple. &#8220;Find the sum of all the multiples of 3 or 5 below 1000&#8243;. The solution, then, must be to find all numbers that are multiples of 3 and 5, and then adding those&#8230;</p> <script src="http://gist.github.com/418446.js"></script> <p>This solution is pretty simple. You (probably) need nodejs to run the code.</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/project-euler-problem-one/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Patterns of Enterprise Application Architecture</title><link>http://www.clauswitt.com/patterns-of-enterprise-application-architecture/</link> <comments>http://www.clauswitt.com/patterns-of-enterprise-application-architecture/#comments</comments> <pubDate>Sun, 14 Feb 2010 19:00:50 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[application architecture]]></category> <category><![CDATA[patterns]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=342</guid> <description><![CDATA[I decided at the beginning of this year to start reading more. I have read a lot of books in the past, but in the last couple of years I have been neglecting this form of learning. So I decided to go to the library and get all the books from my Amazon wish list. [...]]]></description> <content:encoded><![CDATA[<p>I decided at the beginning of this year to start reading more. I have read a lot of books in the past, but in the last couple of years I have been neglecting this form of learning. So I decided to go to the library and get all the books from my Amazon wish list. This has two good consequences &#8211; first of all I start reading books with a lot of wisdom in them without paying for them, and second I get to delete the books from my amazon wishlist which I found to lack in quality.</p><p>One of the books which are still in my wishlist is &#8220;Patterns of Enterprise Application Architecture&#8221;. It is a phenomenal book, or rather catalog,  of design patterns specifically for enterprise software, but most of them are universally usable. I first heard about this book when the FLOW3 project started, and now having read the book I find it easier to understand some of the architectural decisions made by the FLOW3 team. Furthermore the FLOW3 framework made it a lot easier to understand a lot of the patterns from the book. since many of them has a implementation in the framework.</p><p>The author, <a href="http://www.martinfowler.com/">Martin Fowler</a>, has published a short overview of each of the patterns at <a href="http://www.martinfowler.com/eaaCatalog/">http://www.martinfowler.com/eaaCatalog/</a>.</p><p>It is hard to go into detail about the book, since it would involve discussing a lot of the patterns &#8211; but I would just recommend it for any developer, you will learn something!</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/patterns-of-enterprise-application-architecture/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Using Quicksilver to edit hosts file</title><link>http://www.clauswitt.com/using-quicksilver-to-edit-hosts-file/</link> <comments>http://www.clauswitt.com/using-quicksilver-to-edit-hosts-file/#comments</comments> <pubDate>Wed, 04 Nov 2009 14:38:41 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[applescript]]></category> <category><![CDATA[hosts]]></category> <category><![CDATA[quicksilver]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=322</guid> <description><![CDATA[This is mostly just a follow up for my previous post on using a shell script to add and remove test domains in the hosts file. I have created two small applescripts for use in Quicksilver to execute that script. If you need to use these you place them in ~/Library/Application Support/Quicksilver/Actions and set your [...]]]></description> <content:encoded><![CDATA[<p>This is mostly just a follow up for my previous post on <a href="http://www.clauswitt.com/2009/11/04/319/">using a shell script to add and remove test domains in the hosts file</a>. I have created two small applescripts for use in Quicksilver to execute that script. If you need to use these you place them in ~/Library/Application Support/Quicksilver/Actions and set your password. (Beware this could pose a threat, since you will have your password in cleartext on your harddrive).</p><p>The two scripts are almost identical. Actually the only difference is the action the shell script should call (add or remove). The rest of the scripts are completely the same.</p><p>I call this file addhost.</p><pre name="code" class="applescript">
using terms from application "Quicksilver"
	on process text txt
		set the_password to "YOURPASSWORD"
		repeat with delimiter_position from 1 to (length of txt)
			if character delimiter_position of txt = " " then exit repeat
		end repeat
		if delimiter_position = (length of txt) then
			set hostname to txt as string
			set ipaddress to ""
		else
			set hostname to characters 1 thru (delimiter_position - 1) of txt as string
			set ipaddress to characters (delimiter_position + 1) thru (length of txt) of txt as string

		end if

		do shell script "sudo hosts.sh add " &#038; hostname &#038; " " &#038; ipaddress password the_password with administrator privileges

		return nothing
	end process text
end using terms from
</pre><p>I call this file removehost.</p><pre name="code" class="applescript">
using terms from application "Quicksilver"
	on process text txt
		set the_password to "YOURPASSWORD"
		repeat with delimiter_position from 1 to (length of txt)
			if character delimiter_position of txt = " " then exit repeat
		end repeat
		if delimiter_position = (length of txt) then
			set hostname to txt as string
			set ipaddress to ""
		else
			set hostname to characters 1 thru (delimiter_position - 1) of txt as string
			set ipaddress to characters (delimiter_position + 1) thru (length of txt) of txt as string

		end if

		do shell script "sudo hosts.sh remove " &#038; hostname &#038; " " &#038; ipaddress password the_password with administrator privileges

		return nothing
	end process text
end using terms from
</pre><p>Now I am able to create a local domain by opening Quicksilver (double-control in my case) press period, write the domain name, press tab, and select the addhost action (ad is enough in my case). Removing is just as easy &#8211; the last step is just to select the removehost action (re is enough in my case).</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/using-quicksilver-to-edit-hosts-file/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Bash script for editing the hosts file</title><link>http://www.clauswitt.com/319/</link> <comments>http://www.clauswitt.com/319/#comments</comments> <pubDate>Wed, 04 Nov 2009 09:02:46 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Web development]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[easy creation]]></category> <category><![CDATA[hosts]]></category> <category><![CDATA[shell script]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=319</guid> <description><![CDATA[I just read a post about local development in apache by Jesper Rasmussen and thought one thing was missing. I usually test my sites and applications locally with the real domain &#8211; to ensure that functionality based on the url works as expected. However this means editing the hosts file several times a day. Now [...]]]></description> <content:encoded><![CDATA[<p>I just read a <a href="http://jesperrasmussen.com/coding-on-the-go-setting-up-local-apache">post about local development in apache</a> by <a href="http://jesperrasmussen.com/">Jesper Rasmussen</a> and thought one thing was missing. I usually test my sites and applications locally with the real domain &#8211; to ensure that functionality based on the url works as expected. However this means editing the hosts file several times a day. Now I have made a small shellscript that will add and remove lines from the hosts file.</p><pre name="code" class="bash">
#! /bin/bash
DEFAULT_IP=127.0.0.1
IP=${3:-$DEFAULT_IP}

case "$1" in
  add)
        echo "$IP $2"  >> /etc/hosts
        ;;
  remove)
        sed -ie "\|^$IP $2\$|d" /etc/hosts
        ;;

  *)
        echo "Usage: "
		echo "hosts.sh [add|remove] [hostname] [ip]"
		echo
		echo "Ip defaults to 127.0.0.1"
		echo "Examples:"
		echo "hosts.sh add testing.com"
		echo "hosts.sh remove testing.com 192.168.1.1"
        exit 1
        ;;
esac

exit 0
</pre><p>As you can see the script defaults the ip to 127.0.0.1 for easy creation of local domains. Next step is to create a quicksilver (and a gnome do) plugin for easy creation without ever touching the terminal. (Even though we all love the terminal, right?)</p> ]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/319/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Converting Filenames to Lowercase with Bash</title><link>http://www.clauswitt.com/converting-filenames-to-lowercase-with-bash/</link> <comments>http://www.clauswitt.com/converting-filenames-to-lowercase-with-bash/#comments</comments> <pubDate>Wed, 03 Jun 2009 07:24:36 +0000</pubDate> <dc:creator>Claus Witt</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[bash oneliner]]></category> <category><![CDATA[import script]]></category> <category><![CDATA[voicearchive]]></category><guid isPermaLink="false">http://www.clauswitt.com/?p=246</guid> <description><![CDATA[Once again I have a bash-oneliner. For some reason it is all I blog about at the moment. I had an import script for importing demo files (in mp3 format) to a database used at Voicearchive. Only problem the import script depended on the files being named precisely according to a specific rule. But for [...]]]></description> <content:encoded><![CDATA[<p>Once again I have a bash-oneliner. For some reason it is all I blog about at the moment.</p><p>I had an import script for importing demo files (in mp3 format) to a database used at <a href="http://www.voicearchive.com/">Voicearchive</a>. Only problem the import script depended on the files being named precisely according to a specific rule. But for some reason some times it was named with uppercase letters, and sometimes with lowercase letters. I decided to rename all files to lowercase, and change the importscript accordingly.</p><pre name="code" class="bash">
find . -maxdepth 1 -type f -execdir rename 'y/A-Z/a-z/' '{}' \;
</pre>]]></content:encoded> <wfw:commentRss>http://www.clauswitt.com/converting-filenames-to-lowercase-with-bash/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached (user agent is rejected)
Database Caching 5/39 queries in 0.030 seconds using memcached

Served from: www.clauswitt.com @ 2010-07-30 04:26:55 -->