<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>the web dev</title>
	
	<link>http://thewebdev.de</link>
	<description>just another blog about software development for the web</description>
	<lastBuildDate>Mon, 25 Mar 2013 19:52:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/thewebdev" /><feedburner:info uri="thewebdev" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>The Erlang stack</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/R4-U-bSZ7xk/</link>
		<comments>http://thewebdev.de/the-erlang-stack/#comments</comments>
		<pubDate>Mon, 01 Oct 2012 16:28:17 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[basho]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[otp]]></category>
		<category><![CDATA[stack]]></category>
		<category><![CDATA[unittesting]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=529</guid>
		<description><![CDATA[<p>I am learning Erlang for a little to a year now, not constantly but every now and then and a little more in the last 2-3 months. As I dug deeper and deeper in the language I started looking for the typical stack for Erlang programs. That means tools to develop and run a Erlang/OTP [...]]]></description>
				<content:encoded><![CDATA[<p>I am learning Erlang for a little to a year now, not constantly but every now and then and a little more in the last 2-3 months. As I dug deeper and deeper in the language I started looking for the typical stack for Erlang programs. That means tools to develop and run a Erlang/OTP application and here is a (not yet complete) list of what I have found.</p>
<p>Erlang is a language that has been and is used for <a href="http://programmers.stackexchange.com/questions/112417/real-world-applications-of-erlang" target="_blank">various types of applications</a>. Unfortunately many developers don&#8217;t feel comfortable with the functional programming paradigm that Erlang is built upon. To help you get started on your way as a to-be Erlang developer here are some tools that may help you:</p>
<ul>
<li><strong><a href="http://veldstra.org/whyerlang/" target="_blank">why erlang?</a></strong> reasons to use the language and runtime environment for your projects</li>
<li><strong><a href="http://learnyousomeerlang.com/">Learn you some Erlang (for Gread Good)</a></strong>: a very good (and fun) way to learn Erlang</li>
<li><strong><a href="http://www.tryerlang.org/" target="_blank">try-erlang</a></strong>: an in-browser interactive tutorial to Erlang</li>
<li><strong><a href="http://www.erlang.org/doc/apps/edoc/index.html" target="_blank">edoc</a></strong>: generates HTML documentation from .erl source files, comes with standard distribution</li>
<li><a href="http://www.erlang.org/doc/apps/eunit/chapter.html" target="_blank"><strong>eunit</strong></a>: unit testing framework, comes with the standard installation of Erlang</li>
<li><strong><a href="http://www.erlang.org/doc/apps/common_test/index.html" target="_blank">common test</a></strong>: also ships with standard installation</li>
<li><a href="https://github.com/basho/rebar" target="_blank"><strong>rebar</strong></a>: a popular build tool for erlang programs developed by Basho</li>
<li><a href="https://github.com/erlware/sinan" target="_blank"><strong>sinan</strong></a>: an alternative to rebar with a stronger focus on OTP</li>
<li><a href="https://github.com/spawngrid/kerl" target="_blank"><strong>kerl</strong></a>: manages installations of Erlang/OTP, like RVM does for Ruby</li>
<li><strong><a href="http://rashkovskii.com/2012/10/01/expm-or-meet-agner-2/">EXPM</a></strong>: a package index and manager for Erlang (supersedes <a href="http://erlagner.org" target="_blank">agner</a>)</li>
<li><a href="http://www.erlang.org/doc/man/dialyzer.html" target="_blank"><strong>dialyzer</strong></a>: a static code analysis tool (<a href="http://www.erlang.org/doc/man/dialyzer.html" target="_blank">standard dist</a>)</li>
<li><a href="https://github.com/eproxus/meck" target="_blank"><strong>meck</strong></a>: a mock library for Erlang, works perfectly with eunit</li>
<li><a href="http://basho.com/blog/technical/2011/07/20/Introducing-Lager-A-New-Logging-Framework-for-ErlangOTP/" target="_blank"><strong>lager</strong></a>: a logging framework developed @ Basho, <a href="http://theschemeway.blogspot.de/2012/10/lager-is-cool.html" target="_blank">Lager is cool!</a></li>
<li><a href="http://erldocs.com" target="_blank"><strong>erldocs</strong></a>: a nicer manual than the original docs, you can find it on <a href="http://erldocs.com" target="_blank">erldocs.com</a></li>
<li><a href="http://www.erlang.org/doc/apps/debugger/debugger_chapter.html" target="_blank"><strong>debugger</strong></a>: <a href="http://www.erlang.org/doc/apps/debugger/debugger_chapter.html" target="_blank">built-in</a> graphical debugging tool, just start it with <em>debugger:start/0</em></li>
<li><strong><a href="http://www.erlang.org/doc/man/observer.html" target="_blank">observer</a></strong>: a graphical node and application process tree viewer, also <a href="http://www.erlang.org/doc/man/appmon.html" target="_blank">built-in</a>, start it with observer<em>:start/0 (supersedes <a href="http://www.erlang.org/doc/man/appmon.html" target="_blank"><strong>appmon</strong></a>)</em></li>
<li><a href="http://www.erlang.org/doc/man/pman.html" target="_blank"><strong>pmon</strong></a>: a <a href="http://www.erlang.org/doc/man/pman.html" target="_blank">built-in</a> graphical process manager, run it with <em>pmon:start/0</em></li>
<li><strong><a href="https://github.com/extend/cowboy" target="_blank">cowboy</a></strong>: a fast and easy to use web server</li>
<li><a href="http://www.erlang.org/documentation/doc-5.7.4/lib/et-1.3.3/doc/html/et_intro.html" target="_blank"><strong>et</strong></a>: built-in and easy to use event tracer for Erlang: <a href="http://jlouisramblings.blogspot.com/2011/10/using-event-tracer-tool-set-in-erlang.html" rel="bookmark">Using the Event Tracer tool set in Erlang</a>, <a href="http://souja.net/2009/04/making-sense-of-erlangs-event-tracer" target="_blank">Making Sense of Erlang&#8217;s Event Tracer</a></li>
<li><strong><a href="http://yaws.hyber.org/" target="_blank">yaws</a></strong>: a high-performance web server primarily suited for dynamic content</li>
<li><a href="https://github.com/ferd/erlang-history" target="_blank"><strong>erlang-history</strong></a>: adds history to the erlang shell</li>
<li><strong><a href="https://github.com/ferd/vmstats">vmstats</a>: </strong>monitor Erlang VMs via<strong> <a href="https://github.com/lpgauth/statsderl">statsderl</a></strong></li>
<li><strong><a href="http://elixir-lang.org/" target="_blank">Elixir</a></strong>: a functional and meta-programming aware language that runs on the Erlang VM</li>
<li><strong><a href="http://lenary.co.uk/erlang/2011/08/erlang-web-libraries/" target="_blank">Web frameworks</a></strong>: a list of web frameworks for Erlang</li>
<li><strong><a href="https://github.com/flashingpumpkin/spooky" target="_blank">Spooky</a></strong>: a RESTful request handler for Erlang</li>
<li><a href="http://www.erlang.se/doc/programming_rules.shtml" target="_blank">Erlang Programming Rules</a></li>
</ul>
<p>I&#8217;ll write separate articles for each of the tools in the future, this post will just be a pointing in the right direction for lost Erlang developers <img src='http://thewebdev.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Please, if you know any other helpful tools, don&#8217;t hesitate to post it in the comments and I will add them to the list. I know that this is just a very small overview, but these are all tools that helped me get a better Erlang developer, either by using them and/or by reading their code.</p>
<p>Happy Erlang&#8217;ing <img src='http://thewebdev.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/R4-U-bSZ7xk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/the-erlang-stack/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://thewebdev.de/the-erlang-stack/</feedburner:origLink></item>
		<item>
		<title>Why don’t you put your dotfiles on Github?</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/nP88WKiCOec/</link>
		<comments>http://thewebdev.de/why-dont-you-put-your-dotfiles-on-github/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 17:10:52 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dotfiles]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=516</guid>
		<description><![CDATA[<p>What exactly are dotfiles some of you might ask? It&#8217;s those little settings file that swirl around in your $HOME directory (~) on your Linux or Mac OS X machine and sometime you have to change them to adjust your configuration with them.</p> What are dotfiles? <p>These might include settings for vim, screen, tmux, bash, [...]]]></description>
				<content:encoded><![CDATA[<p>What exactly are dotfiles some of you might ask? It&#8217;s those little settings file that swirl around in your $HOME directory (~) on your Linux or Mac OS X machine and sometime you have to change them to adjust your configuration with them.</p>
<h2>What are dotfiles?</h2>
<p>These might include settings for vim, screen, tmux, bash, <a title="zsh – a bash alternative that’s easily customizable with oh-my-zsh" href="http://thewebdev.de/zsh-a-bash-alternative-thats-easily-customizable-with-oh-my-zsh/" target="_blank">zsh</a> or aliases you use for your daily work on these systems. Or some tools you have written to automate tasks that would otherwise include a list of commands but is now down to a single command.</p>
<h2>How I came to put them there &#8230;</h2>
<p>I had a fairly big amount of these settings and tools that I carried with me. I used to copy them from machine to machine, whether new physical machines or VMs. It was hilarious! I often forgot some and some were lost &#8211; forever &#8211; till I packed them all in a git repository and put them on <a href="https://github.com/domnikl/.home" target="_blank">Github</a>. Needless to say I didn&#8217;t put any sensitive data up there &#8230;</p>
<p>Turned out I am not the only one doing this, in fact, there is already an unofficial guide about dotfiles on github out there: <a href="http://dotfiles.github.com" target="_blank">dotfiles.github.com</a>. And many software developers share their settings, aliases and small tools there, too. I advise you to look at their configurations and tools. You can learn a lot from them and of course get some of their tools and use it yourself. These are very interesting setups:</p>
<ul>
<li><a href="http://github.com/ryanb/dotfiles" target="_blank">ryanb/dotfiles</a></li>
<li><a href="http://github.com/rtomayko/dotfiles" target="_blank">rtomayko/dotfiles</a></li>
<li><a href="http://github.com/holman/dotfiles" target="_blank">holman/dotfiles</a></li>
<li><a href="http://github.com/mathiasbynens/dotfiles" target="_blank">mathiasbynens/dotfiles</a></li>
</ul>
<h2>Frameworks</h2>
<p>Many of those use frameworks to build upon for their configuration. I am using <a href="https://github.com/sorin-ionescu/prezto" target="_blank">prezto</a>, which is a fork of oh my zsh, but with better performance and some more features. It allows you to add plugins for git, syntax highlighting, tmux, screen and many, many others very easily and gets you going in no time.</p>
<h2>Sharing</h2>
<p>Github calls itself a social coding platform and I think it&#8217;s a very good aspect to share also some tools and settings we use for our daily work. My dotfile repository was to this date forked by five other people and everyone picked the things they liked and threw away the other stuff and added their configurations. And I love that, because I learned some new tools, too <img src='http://thewebdev.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I would love to see a link to your Github dotfiles repository in the comments. Come on, it&#8217;s easy and you will earn a lot from it!</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/nP88WKiCOec" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/why-dont-you-put-your-dotfiles-on-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://thewebdev.de/why-dont-you-put-your-dotfiles-on-github/</feedburner:origLink></item>
		<item>
		<title>Erlang Concurrent Program Template</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/7baipBqjbH8/</link>
		<comments>http://thewebdev.de/erlang-concurrent-program-template/#comments</comments>
		<pubDate>Sun, 16 Sep 2012 06:36:11 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[concurrent]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=490</guid>
		<description><![CDATA[<p>To start development on a new Erlang module that supports concurrent processing, I wrote myself a template, that is mostly inspired by the template from Joe Armstrong and his book <a title="Programming Erlang - Software for a Concurrent World" href="http://pragprog.com/book/jaerlang/programming-erlang" target="_blank">Programming Erlang &#8211; Software for a Concurrent World</a>.</p> <p></p> <p>I developed the template from the [...]]]></description>
				<content:encoded><![CDATA[<p>To start development on a new Erlang module that supports concurrent processing, I wrote myself a template, that is mostly inspired by the template from Joe Armstrong and his book <a title="Programming Erlang - Software for a Concurrent World" href="http://pragprog.com/book/jaerlang/programming-erlang" target="_blank">Programming Erlang &#8211; Software for a Concurrent World</a>.</p>
<p><code><script src="https://gist.github.com/3727470.js"></script><noscript><pre><code class="language-erlang erlang">-module(ctemplate).
-compile(export_all).

%% start
%%
%% @spec start() -&gt; pid()
start() -&gt;
	% explicit MFA (module, function, args list) enables dynamic code upgrades
	spawn(ctemplate, loop, [[]]).

%% remote call
%%
%% @spec rpc(pid(), any()) -&gt; any()
rpc(Pid, Request) -&gt;
	Pid ! {self(), Request},
	
	receive
		% Pid is in the pattern match to avoid grabbing messages from all 
		% processes ...
		{Pid, Response} -&gt;
			Response
	end.

%% receive loop handler
%%
%% @spec loop(any()) -&gt; none()
loop(X) -&gt;
	receive
		Any -&gt;
			io:format(&quot;Received:~p~n&quot;, [Any]),
			
			% tail recursion: this should be the last call, 
			% so it won't consume any stack space
			loop(X)
	end.</code></pre></noscript></code></p>
<p>I developed the template from the book a bit further and used <em>MFA</em> (Module, Function, Argument List) in the <em>spawn</em> call to enable dynamic code upgrades.</p>
<p>In the top you can see, that all functions will be exported (that means, callable from other modules or the shell). This is only for debugging purposes.</p>
<p>As a default, the loop will just print out, what has been received from the client process.</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/7baipBqjbH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/erlang-concurrent-program-template/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://thewebdev.de/erlang-concurrent-program-template/</feedburner:origLink></item>
		<item>
		<title>JS assessment: improve your JavaScript knowledge test-driven</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/qYBWj2fEzEA/</link>
		<comments>http://thewebdev.de/js-assessment-improve-your-javascript-knowledge-test-driven/#comments</comments>
		<pubDate>Sat, 01 Sep 2012 12:59:52 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=466</guid>
		<description><![CDATA[<p>I have never been a really good JavaScript developer and generally I&#8217;m more a backend-oriented type of developer. But I recently decided to change that fact and do a lot more frontend stuff. To help me gain the necessary knowledge, I found <a href="https://github.com/rmurphey/js-assessment" target="_blank">JS-assessment</a> developed by <a href="https://twitter.com/rmurphey" target="_blank">Rebecca Murphy</a> to be very helpful.</p> [...]]]></description>
				<content:encoded><![CDATA[<p>I have never been a really good JavaScript developer and generally I&#8217;m more a backend-oriented type of developer. But I recently decided to change that fact and do a lot more frontend stuff. To help me gain the necessary knowledge, I found <a href="https://github.com/rmurphey/js-assessment" target="_blank">JS-assessment</a> developed by <a href="https://twitter.com/rmurphey" target="_blank">Rebecca Murphy</a> to be very helpful.</p>
<p>JS-assessment is a test-driven approach to learn the basics and also some more advanced best practices in JavaScript. You can get it from <a href="https://github.com/rmurphey/js-assessment.git" target="_blank">Github</a>. It runs a small HTTP server on node.js that you will use to run the tests.</p>
<p>All you have to do now is to write some small lines of code, so that the tests will run successfully and show green. The approach will also work perfectly as a <a href="http://www.agiledesign.co.uk/2006/dojo-kata-or-randori" target="_blank">coding dojo kata</a>. Repeat it regularly and track your progress.</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/qYBWj2fEzEA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/js-assessment-improve-your-javascript-knowledge-test-driven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://thewebdev.de/js-assessment-improve-your-javascript-knowledge-test-driven/</feedburner:origLink></item>
		<item>
		<title>Think of APIs as Domain-specific languages (DSL)</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/quo47d2qBo8/</link>
		<comments>http://thewebdev.de/think-of-apis-as-domain-specific-languages-dsl/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 16:29:45 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[domain-specific languages]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[general-purpose programming languages]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[redis]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=441</guid>
		<description><![CDATA[<p>Today&#8217;s blog post is about why you should think of a DSL when building APIs. Don&#8217;t be afraid, I am going to explain what a DSLs is if you don&#8217;t know it by now and I will give you an overview of examples. You might already know them but most developers don&#8217;t recognize them as [...]]]></description>
				<content:encoded><![CDATA[<p>Today&#8217;s blog post is about why you should think of a DSL when building APIs. Don&#8217;t be afraid, I am going to explain what a DSLs is if you don&#8217;t know it by now and I will give you an overview of examples. You might already know them but most developers don&#8217;t recognize them as domain-specific, but just another language.</p>
<h2>Definition</h2>
<p>First of all, what exactly is a DSL, what does the term domain-specific language stand for? The best way to explain this is by naming the opposite of it, which you already know because you do use it everyday: <em>General-purpose programming languages</em>. Whether it&#8217;s PHP, Ruby, C(#), Java, &#8230; you can do just about anything with them, that may be developing applications for the web, mobile devices or whatever. But what if you have a specific problem, a problem that has been solved like a thousand times before? For many problems like these, programming languages have been invented that perfectly fit the problem&#8217;s domain and make it easy to solve it.</p>
<p><a href="http://martinfowler.com/dsl.html" target="_blank">Martin Fowler describes DSLs</a> like that:</p>
<blockquote><p>Domain-specific language: a computer programming language of limited expressiveness focused on a particular domain.</p></blockquote>
<p>He further names a distinction between internal and external languages which means:</p>
<ol>
<li>internal DSLs are built in a specific language and work only for that language</li>
<li>external languages which then need a full parser in the language you want the DSL to use in</li>
</ol>
<h2>Examples</h2>
<h3>external DSLs</h3>
<p>SQL is an external DSL and it&#8217;s domain should be clear to anyone that ever used it: (relational) data. Another example you all should know is Cascading Stylesheets and it&#8217;s domain is to style the representation of Markup, mostly used for HTML. Have you ever used a build system like make, rake or ant? These are all external Domain-specific languages which all define a set of commands. Redis (an in-memory database system) and the maintainer of the project, Salvatore Sanfilippo even defined the first of the project&#8217;s goals in the <a href="http://antirez.com/post/redis-manifesto.html " target="_blank">Redis manifesto</a> as follows:</p>
<blockquote><p>A DSL for Abstract Data Types. Redis is a DSL (Domain Specific Language) that manipulates abstract data types and implemented as a TCP daemon.</p></blockquote>
<h3>internal Domain-specific languages</h3>
<p>I am pretty shure you already used some of the above examples, but what about internal languages? Have you ever come across one? I am sure you have, here are some examples for you:</p>
<p>Sinatra is a Ruby micro HTTP framework (I already <a title="building tiny web apps with Sinatra Part 1" href="http://thewebdev.de/building-tiny-web-apps-with-sinatra-part1/" target="_blank">blogged a tutorial series about Sinatra</a>) that defines a set of commands that help you to build more or less simple web applications or REST services. It&#8217;s domain is HTTP and if you take a look at it, you will find that it&#8217;s pretty close to the HTTP specification. Have you ever heard of <a title="learning some Erlang" href="http://thewebdev.de/learning-some-erlang/" target="_blank">Erlang</a>?  It once was an internal DSL at Ericsson, where they used it to build highly concurrent telecommunication applications. Later they open sourced it and now you can use it to build just about anything. It evolved from an internal Domain-specific to a general-purpose language. And JavaScript once has been a DSL to develop interactive web application frontends, but node.js took it out of the browser and made it a general-purpose language.</p>
<h2>What can we learn from DSLs when building APIs?</h2>
<p>Have a look at the above examples and you&#8217;ll notice that they all share a few principles:</p>
<ul>
<li>define a rather small set of commands</li>
<li>ease of use</li>
<li>just fit the domain&#8217;s needs &#8211; no more, no less</li>
</ul>
<p>And I think this essence should also apply if you build an API, no matter if it&#8217;s external (say for example a REST interface) or internal. You should always keep it simple and easy to use and don&#8217;t confuse the user of your API with domain-unrelated things.</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/quo47d2qBo8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/think-of-apis-as-domain-specific-languages-dsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://thewebdev.de/think-of-apis-as-domain-specific-languages-dsl/</feedburner:origLink></item>
		<item>
		<title>PHP dependency and package management with Composer</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/fsWG6B3n8nw/</link>
		<comments>http://thewebdev.de/php-dependency-and-package-management-with-composer/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 13:13:12 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[composer]]></category>
		<category><![CDATA[package management]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=443</guid>
		<description><![CDATA[<p>Recently, I held a talk at <a href="http://www.mayflower.de" target="_blank">Mayflower GmbH</a> about Composer, a fresh and easy new way to manage the dependencies of a PHP project. Actually I did that talk twice, once in Würzburg and once in Munich. The Slides are in german, but I think you&#8217;ll get the point even if you&#8217;re not [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, I held a talk at <a href="http://www.mayflower.de" target="_blank">Mayflower GmbH</a> about Composer, a fresh and easy new way to manage the dependencies of a PHP project. Actually I did that talk twice, once in Würzburg and once in Munich. The Slides are in german, but I think you&#8217;ll get the point even if you&#8217;re not speaking german.</p>
<div style="width:425px" id="__ss_12203967"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/mayflowergmbh/php-dependency-und-paket-management-mit-composer" title="PHP Dependency und Paket Management mit Composer" target="_blank">PHP Dependency und Paket Management mit Composer</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/12203967" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/" target="_blank">presentations</a> from <a href="http://www.slideshare.net/mayflowergmbh" target="_blank">Mayflower GmbH</a> </div>
</p></div>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/fsWG6B3n8nw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/php-dependency-and-package-management-with-composer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://thewebdev.de/php-dependency-and-package-management-with-composer/</feedburner:origLink></item>
		<item>
		<title>test your Ruby app with various versions using rvm</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/URin58jAzd0/</link>
		<comments>http://thewebdev.de/test-your-ruby-app-with-various-versions-using-rvm/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 21:52:23 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=427</guid>
		<description><![CDATA[<p>Recently I started to test my <a title="highscore – a lightweight ruby library that finds and ranks keywords in a string" href="http://thewebdev.de/highscore-a-lightweight-ruby-library-that-finds-and-ranks-keywords-in-a-string/" target="_blank">highscore</a> library on <a href="http://travis-ci.org/#!/domnikl/highscore" target="_blank">Travis CI</a> and they&#8217;re using rvm on their test machines to easily switch the version and platforms. I only had <a title="Matz Ruby Interpreter" href="http://en.wikipedia.org/wiki/Ruby_MRI" target="_blank">MRI</a> 1.9.3 on my local [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I started to test my <a title="highscore – a lightweight ruby library that finds and ranks keywords in a string" href="http://thewebdev.de/highscore-a-lightweight-ruby-library-that-finds-and-ranks-keywords-in-a-string/" target="_blank">highscore</a> library on <a href="http://travis-ci.org/#!/domnikl/highscore" target="_blank">Travis CI</a> and they&#8217;re using rvm on their test machines to easily switch the version and platforms. I only had <a title="Matz Ruby Interpreter" href="http://en.wikipedia.org/wiki/Ruby_MRI" target="_blank">MRI</a> 1.9.3 on my local machine, but had some problems on 1.8.7. Removing 1.9.3 and installing 1.8.7 was no option, so I installed <a href="http://beginrescueend.com/" target="_blank">rvm</a> (Ruby Version Manager) on my machine and I love it! So I am going to talk about it today, the benefits, going through the (easy) installation process and what you should be aware of.</p>
<p>First of all if you don&#8217;t know it yet: there are several implementations of Ruby interpreters out there: the best known is MRI (Matz-Ruby-Interpreter), it&#8217;s the first implementation and written in C, then there&#8217;s <a href="http://www.rubyenterpriseedition.com/" title="REE" target="_blank">Ruby Enterprise Edition</a>, an improved version of the MRI. <a href="http://jruby.org/" title="JRuby" target="_blank">JRuby</a> runs on the Java Virtual Machine, <a href="http://rubini.us/" target="_blank">Rubinius</a> is also written in C, but younger implementation, <a href="http://ironruby.net/" target="_blank">IronRuby</a> runs on the .NET platform and <a href="http://www.macruby.org/" target="_blank">MacRuby</a> runs, well, only on Macs (who would&#8217;ve guessed it?).</p>
<h2>Setup rvm</h2>
<p>Installing rvm is a simple task, all you have to is that:</p>
<p><code>bash -s stable &lt; &lt;(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)</code></p>
<p>This will install rvm in your <code>$HOME</code> directory and you should add the following line to your <code>.bashrc</code> (or in your <code>.zshrc</code> if you use the awesome <a title="zsh – a bash alternative that’s easily customizable with oh-my-zsh" href="http://thewebdev.de/zsh-a-bash-alternative-thats-easily-customizable-with-oh-my-zsh/" target="_blank">zsh</a>)</p>
<p><code>source $HOME/.rvm/scripts/rvm</code></p>
<h2>Installing rubies</h2>
<p>Now you have rvm on your system, but you don&#8217;t have any Rubies in it. <code>rvm list known</code> will give you a list of all Rubies that are available. Start with installing the default Ruby, type <code>rvm install 1.9.3</code> followed by <code>rvm default 1.9.3</code>. Now if you do <code>ruby -v</code>, you should see the 1.9.3 version. If not, start a new shell session, the rvm script must be loaded for the session first.</p>
<p>To switch to another Version or platform, you need the <code>use</code> command: <code>rvm use jruby</code> will switch to the latest JRuby version that you installed.</p>
<h2>ruby gems</h2>
<p>You already may have noticed that all the Rubies are installed in your $HOME directory, in the folder <code>.rvm</code>. All gems that you install will be put in this directory, there&#8217;s a gems folder for every Ruby that you installed via rvm there. So you need to install gems for every version that you want to use.</p>
<p>Rvm has a lot of functions that go beyond the scope of the article, you could run rake tasks on multiple Ruby versions in one step, install a gem on multiple platforms, run your unit tests on 1.8.7 and 1.9.3 in one step (<code>rvm 1.8.7,1.9.3 do rake task</code>) and much more.<br />
You should definitely check out the <a href="http://beginrescueend.com/set/" target="_blank">documentation</a>. </p>
<p>Playing around with different interpreters and building libraries that run on many Ruby platforms is fun with that wonderful piece of software. Have fun!</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/URin58jAzd0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/test-your-ruby-app-with-various-versions-using-rvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://thewebdev.de/test-your-ruby-app-with-various-versions-using-rvm/</feedburner:origLink></item>
		<item>
		<title>Developing a daemon in PHP</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/eki6u5kLyjc/</link>
		<comments>http://thewebdev.de/developing-a-daemon-in-php/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 18:02:53 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=407</guid>
		<description><![CDATA[<p>I&#8217;ve already talked about Unix programming <a title="Unix programming using Ruby" href="http://thewebdev.de/unix-programming-using-ruby/">here</a>, but today I want to go a step   ahead an really implement a daemon, this time I am going to use PHP. You may have already heard of daemons here or there, but I&#8217;ll give you some facts about them anyway:</p> daemons [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve already talked about Unix programming <a title="Unix programming using Ruby" href="http://thewebdev.de/unix-programming-using-ruby/">here</a>, but today I want to go a step   ahead an really implement a daemon, this time I am going to use PHP. You may have already heard of daemons here or there, but I&#8217;ll give you some facts about them anyway:</p>
<ol>
<li>daemons are long running processes,</li>
<li>they run in the background,</li>
<li>you can&#8217;t interact with them via a TTY</li>
<li>originated from the Unix world</li>
<li>a common convention is to put a trailing &#8220;d&#8221; on their name, e.g. <em>http<strong>d</strong></em></li>
</ol>
<p>These are the more obvious attributes of a daemon, but there&#8217;s a little more to say especially about 2. Let&#8217;s start PHP in the terminal and put the process in the background:</p>
<pre class="brush: bash; title: ; notranslate">
php -a &amp;
</pre>
<p>Now if you look through the processes on your system with <code>ps -fax | grep php</code> you will see something like that:</p>
<script src="https://gist.github.com/1942496.js?file=psfax_php_a.sh"></script><noscript><pre><code class="language-shell shell">  502  8621   480   0  6:33pm ttys000    0:00.00 php -a</code></pre></noscript>
<p>The first number is of no interest for us, but the second and the third are. These are the process ID (pid) and the parent process ID (ppid) of our little PHP process. As you can see the parent process is (in my case) 480 and if you do another grep&#8217;ing for 480 you can see that this is the shell where you&#8217;ve typed <code>php -a &amp;</code> in. What happens if you log off the shell? All child processes of the shell will die, so will your PHP process.</p>
<p>But daemons should not die when a user logs off, they should run forever! If you go the tree of processes up on your system you might find a process that has the ppid 1. It&#8217;s the first process that is started when your OS starts and the last one to exit. So we should run our daemon as a child of that process.</p>
<h2>Preconditions</h2>
<p>Before we can implement our first daemon make sure you have the <em>pcntl</em> extension for PHP installed. Most Unix-based programming languages have the necessary functions implemented in the core, but not PHP. Just search for <em>pcntl</em> in your package manager and install the package.</p>
<h2>Our first daemon: mattd</h2>
<p>It does nothing, except printing dots to /dev/null, but that shouldn&#8217;t matter. It&#8217;s a demonstration daemon. Here&#8217;s the dump, I&#8217;ll go through it and explain what and why we need each line of code in it and what it does:</p>
<script src="https://gist.github.com/1942496.js?file=mattd.php"></script><noscript><pre><code class="language-php php">#!/usr/bin/env php
&lt;?php
$pid = pcntl_fork();

if ($pid === -1) {
	die('Could not fork!');
} elseif ($pid) {
	// this is the parent process
	exit;
} else {
	// this is the child process
	chdir(&quot;/&quot;);
	
	// reopen standard file descriptors
        // this is necessary to decouple the daemon from the TTY
	fclose(STDIN);
	fclose(STDOUT);
	fclose(STDERR);
	
	$STDIN = fopen('/dev/null', 'r');
	$STDOUT = fopen('/dev/null', 'wb');
	$STDERR = fopen('/dev/null', 'wb');
	
	// make it session leader
	posix_setsid();
	
	while(1) {
                // just print a dot to /dev/null (STDOUT)
		echo &quot;.&quot;;
                sleep(10);
	}
}</code></pre></noscript>
<p>These are the steps we need to do in the daemon:</p>
<p>&nbsp;</p>
<ol>
<li>fork a new child process</li>
<li><code>pcntl_fork()</code> returns two times, the PID of the parent process and with a 0 for the forked child process</li>
<li>so there are two ways the code runs from here, one is the parent, the other is the child process (if forking was possible)</li>
<li>the parent immediately exits (it&#8217;s ppid is the shell you started the daemon from)</li>
<li>the child goes in the else branch</li>
<li>a daemon has now working directory, so reset it to /</li>
<li>close all the file descriptors that are bound to the shell used, that is STDIN/OUT/ERR</li>
<li>start a forever-running loop that does something useful</li>
</ol>
<div><span style="font-size: small;"><span style="line-height: 24px;"><br />
</span></span></div>
<p>As I said before we need to run our daemon as a child of the pid 1. We can do this by forking and the exiting the parent process. The then new process runs as a child of our php process first but as this process exits, it has no parent anymore.<br />
But having no parent is not possible, so it will get the new ppid 1.</p>
<h2>Daemon != Cronjob</h2>
<p>Typically, PHP developers are more familiar with developing cronjobs than with daemons and although both are used for similar tasks, they don&#8217;t share a common idiom. The main difference is that cronjobs are mostly <strong>long</strong>-running processes whereas daemons are <strong>forever</strong>-running processes.</p>
<p>The other thing is that cronjobs are always started in the context of a shell. Daemons don&#8217;t run in any context, their parent process ID is always 1, the first process started on the system. You can easily test this: create a small PHP script that has an endless loop in it and put it in your crontab. Now wait until the script gets started and do <code>ps -fax | grep you_cronjob</code> and you&#8217;ll see that your cronjob has a PPID other than 1.</p>
<h2>That&#8217;s it for now &#8230;</h2>
<p>A short disclaimer to the end: I have not tested this daemon in production nor will I. I am just keen to learn what goes on in the background of Unix programs and I love to share my knowledge to my readers. If I am wrong and you know better, please leave a comment here, thanks <img src='http://thewebdev.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/eki6u5kLyjc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/developing-a-daemon-in-php/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://thewebdev.de/developing-a-daemon-in-php/</feedburner:origLink></item>
		<item>
		<title>practices of an agile developer</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/epLi9bTFcNE/</link>
		<comments>http://thewebdev.de/practices-of-an-agile-developer/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 18:30:58 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[pragmatic programmers]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=403</guid>
		<description><![CDATA[<p>I often ask myself: &#8220;What can I do to improve my daily work, to become more efficient and a better developer in the non-technical sense?&#8221; In the end, it&#8217;s all about being agile. But what does that mean? I assume you already know about the <a href="http://agilemanifesto.org/" target="_blank">agile manifesto</a>:</p> <p>Individuals and interactions over processes and tools<br [...]]]></description>
				<content:encoded><![CDATA[<p>I often ask myself: &#8220;What can I do to improve my daily work, to become more efficient and a better developer in the non-technical sense?&#8221; In the end, it&#8217;s all about being agile. But what does that mean? I assume you already know about the <a href="http://agilemanifesto.org/" target="_blank">agile manifesto</a>:</p>
<blockquote><p><span style="font-size: small;">Individuals and interactions </span><span style="font-size: x-small;">over processes and tools<br />
</span><span style="font-size: small;">Working software </span><span style="font-size: x-small;">over comprehensive documentation<br />
</span><span style="font-size: small;">Customer collaboration </span><span style="font-size: x-small;">over contract negotiation<br />
</span><span style="font-size: small;">Responding to change </span><span style="font-size: x-small;">over following a plan</span></p></blockquote>
<p>The book &#8220;Practices of an agile developer&#8221; gave me some good tips on getting <em>&#8216;more agile&#8217;.</em> It&#8217;s not one of these books that give you just a detailed text about what those four lines mean, it&#8217;s merely meant to be a guideline that will guide you through the day if you are working in an agile team.</p>
<p>Each section begins describing the non-agile way and then tells why this is bad and what you should do to get better results.</p>
<p>The best about the book is <a href="http://media.pragprog.com/titles/pad/PAD-pulloutcard.pdf" target="_blank">this</a>, a PDF that summarizes all guidelines from the book with a short description. If you want to read it, you can grab a copy <a href="http://pragprog.com/book/pad/practices-of-an-agile-developer" target="_blank">here</a>.</p>
<p>I don&#8217;t get money for this link, I just read this book and found it worthy to be mentioned here! In fact, I love the books from Pragmatic Programmers, I read Programming Ruby, Metaprogramming Ruby, The RSpec Book, Programming Erlang &#8211; Software for a concurrent world, Agile web development with Rails and I&#8217;m currently reading Pragmatic Thinking and Learning.</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/epLi9bTFcNE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/practices-of-an-agile-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://thewebdev.de/practices-of-an-agile-developer/</feedburner:origLink></item>
		<item>
		<title>Unix programming using Ruby</title>
		<link>http://feedproxy.google.com/~r/thewebdev/~3/PHm-zKksc34/</link>
		<comments>http://thewebdev.de/unix-programming-using-ruby/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 17:55:18 +0000</pubDate>
		<dc:creator>Dominik Liebler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://thewebdev.de/?p=396</guid>
		<description><![CDATA[<p>The other day I blogged about an alternative for bash, <a title="zsh – a bash alternative that’s easily customizable with oh-my-zsh" href="http://thewebdev.de/zsh-a-bash-alternative-thats-easily-customizable-with-oh-my-zsh/">zsh</a>. But what if you want to write your own shell that behaves exactly like you want it to?</p> <p><a href="http://jstorimer.com/" target="_blank">Jesse Storimer</a> (the author of the truly great <a href="http://workingwithunixprocesses.com" target="_blank">Working with Unix Processes</a> and [...]]]></description>
				<content:encoded><![CDATA[<p>The other day I blogged about an alternative for bash, <a title="zsh – a bash alternative that’s easily customizable with oh-my-zsh" href="http://thewebdev.de/zsh-a-bash-alternative-thats-easily-customizable-with-oh-my-zsh/">zsh</a>. But what if you want to write your own shell that behaves exactly like you want it to?</p>
<p><a href="http://jstorimer.com/" target="_blank">Jesse Storimer</a> (the author of the truly great <a href="http://workingwithunixprocesses.com" target="_blank">Working with Unix Processes</a> and already working on his Unix beard <img src='http://thewebdev.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) has just started a new <a href="http://jstorimer.com/2012/02/16/a-unix-shell-in-ruby.html" target="_blank">series of blog posts</a> in which he&#8217;ll explain how to write the quintessential of a Unix program &#8211; a basic shell in Ruby.</p>
<p>Today most of the web development or software development in general happens on Unix machines, whether it&#8217;s Linux, Mac OS or BSD. Personally I don&#8217;t use any other systems, so why don&#8217;t learn some of the basics and understand the big picture that&#8217;s behind those architectures?</p>
<p>Of course, this is just a little project for demonstration and learning purpose but there really is an interactive shell written in Ruby and it also uses Ruby as it&#8217;s input language. Say hello to <a href="http://rush.heroku.com" target="_blank">rush</a>.</p>
<img src="http://feeds.feedburner.com/~r/thewebdev/~4/PHm-zKksc34" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://thewebdev.de/unix-programming-using-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://thewebdev.de/unix-programming-using-ruby/</feedburner:origLink></item>
	</channel>
</rss>
