<?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>byte bohemian</title>
	<atom:link href="http://www.niclas-meier.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.niclas-meier.de</link>
	<description>Thechophile bogging</description>
	<lastBuildDate>Tue, 17 Apr 2012 19:24:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Suddenly somewhat famous</title>
		<link>http://www.niclas-meier.de/2012/04/suddenly-somewhat-famous/</link>
		<comments>http://www.niclas-meier.de/2012/04/suddenly-somewhat-famous/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 19:20:30 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Privat]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=152</guid>
		<description><![CDATA[Thanks to a former colleague, I received word that my post about my first 100 days of working with Clojure scored Number 3. on the Hacker News. I just wanted to thank all of you for the interest and I really hope my english is not that worse. Thanks to some attentive readers, I where [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2012/04/suddenly-somewhat-famous/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Thanks to a former colleague, I received word that my post about my first <a href="/2012/04/first-hundred-days-of-clojure/">100 days of working with Clojure</a> scored Number 3. on the <a href="http://news.ycombinator.com/">Hacker News</a>.</p>
<p>I just wanted to thank all of you for the interest and I really hope my english is not that worse. Thanks to some attentive readers, I where able to fix some glitches in some of the examples or the spelling.</p>
<p>Due to fortunate circumstances I had some time to setup <a href="/2011/04/nginxing-around-with-wordpress-2/">my blog on a new platform</a> almost exactly a year ago. Now using <a href="http://wiki.nginx.org">Nginx</a> with <a href="http://wordpress.org/">WordPress</a>. Witch performed remarkably well.<span id="more-152"></span>If your are interested here are some stats:</p>
<p><img style="margin-left: auto; margin-right: auto;" src="http://www.niclas-meier.de/wp-content/uploads/2012/04/localhost-nginx_status-day.png" alt="Localhost nginx status day" width="486" height="305" border="0" /></p>
<p>Starting with about 200 concurrent connections to the my Nging web server, which are 66 times the average over the last year. That&#8217;s nice because I saw some setups which would have died due to the load. Thanks to <a href="https://www.xing.com/profile/Lukas_Loesche2">the guy who introduced me into Nginx</a>. We were using it at <a href="www.scoyo.com">scoyo</a> and <a href="http://www.gamigo.com">gamigo</a> and this proved that it was a good decision &#8211; if I had any doubts left.</p>
<p>As a matter of fact, that worked so well, that it didn&#8217;t even had an impact on the CPU load:<br />
<img style="margin-left: auto; margin-right: auto;" src="http://www.niclas-meier.de/wp-content/uploads/2012/04/localhost-load-day.png" alt="Localhost load day" width="486" height="257" border="0" /><br />
<img style="margin-left: auto; margin-right: auto;" src="http://www.niclas-meier.de/wp-content/uploads/2012/04/localhost-load-month1.png" alt="Localhost load month" width="486" height="257" border="0" /></p>
<p>Or even the memory usage:</p>
<p><img style="margin-left: auto; margin-right: auto;" src="http://www.niclas-meier.de/wp-content/uploads/2012/04/localhost-memory-day.png" alt="Localhost memory day" width="486" height="401" border="0" /></p>
<p>I guess making all the content static using <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP SuperCache</a> and the <a href="http://wiki.nginx.org/HttpRewriteModule">HTTP rewrite module</a> was a good idea.</p>
<div class="shr-publisher-152"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2012/04/suddenly-somewhat-famous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First hundred days of Clojure</title>
		<link>http://www.niclas-meier.de/2012/04/first-hundred-days-of-clojure/</link>
		<comments>http://www.niclas-meier.de/2012/04/first-hundred-days-of-clojure/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 21:05:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Clojure]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=139</guid>
		<description><![CDATA[In politics you have a one hundred days period of grace. In December I started to work with Clojure, so I guess it&#8217;s time to have a clojure look. In the last couple of years I encountered a couple of different languages. At scoyo it was ActionScript and Flex from Adobe. I had the honor [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2012/04/first-hundred-days-of-clojure/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>In politics you have a one hundred days period of grace. In December I started to work with <a href="http://www.clojure.org">Clojure</a>, so I guess it&#8217;s time to have a clojure look. </p>
<p>In the last couple of years I encountered a couple of different languages. At <a href="http://www.scoyo.de">scoyo</a> it was <a href="http://www.adobe.com/devnet/actionscript.html">ActionScript</a> and <a href="http://flex.org/">Flex</a> from Adobe. I had the honor to lead a team of great engineers, but with good people you don&#8217;t get close enough to the real stuff. At <a href="http://www.gamigo.de">gamigo</a> the new technology was <a href="http://www.php.net">PHP</a>. But for the last thirteen years <a href="http://www.java.com/">Java</a> was always a big part of my career&#8230;<span id="more-139"></span>At my new <a href="http://www.herolabs.com">job</a> the new kid on the block is <a href="http://www.clojure.org">Clojure</a> &#8211; a LISP dialect based on Java VM. Clojure was created by <a href="http://twitter.com/#!/richhickey">Rich Hickey</a> and first appeared in 2007.</p>
<p>When we started to work on our new product I said to my boss and my colleagues: In Java I know how a state of the art application has to look like, but I have no clue how to build a Clojure application. Fortunately a colleague had some Common LISP experience and already a closer look on the stack we should use. At the moment our application uses this tools and libraries. I guess I will come back to some of them later on.</p>
<ul>
<li><a href="https://github.com/technomancy/leiningen">Leiningen</a> (aka <a href="https://github.com/technomancy/leiningen">lein</a>) &#8211; The build and dependency managmement tool for Clojure.</li>
<li><a href="http://webnoir.org/">Noir &#8211; A nice library to build websites/-services in Clojure.</a></li>
<li><a href="https://github.com/aboekhoff/congomongo">CongoMongo</a> and <a href="http://www.mongodb.org/">mongoDB</a> &#8211; The database driver and the database we use.</li>
</ul>
<p><strong>My first days with Clojure</strong><br />
When you are coming from a language like Java you are used to some things like:<br />
<em>Structure everything</em> &#8211; Static typing is your friend, so smack every data you have into a class. I guess most Java Enterprise application use a significant part of their computing time with copying references from one bean to another. When you use Clojure you simply don&#8217;t do this and sometimes is still hard for me not to worry about it. But this gives you a whole new level of freedom, you may use e.g. <code>(merge …)</code> to simply combine two of you entities into one larger one.</p>
<p><em>Lots of ceremony</em> &#8211; When you work in Java you create a huge amount of classes. The longer you work with Java the more inner and anonymous classes you tend to use. From these classes ninety percent are stupid bean classes with some attributes plus a setter and a getter per attribute and if you work with experts a <code>hashCode</code> and <code>equals</code> method. The remaining ten (or so) percent of you classes are services or stuff like that, who transform beans in different beans or XML, JSON, String, stuff like that. In clojure you put your structured data in maps &#8211; that&#8217;s it. Due to the fact that all of closures datatypes are immutable you build some functions who do the same like the services and you are done. But instead of shuffling data from one bean to another you may use <code>(assoc …)</code>, <code>(dissoc …)</code>, <code>(select-keys …)</code> or <code>(merge …)</code> to efficiently create modified or new entities for the business logic or output generation.</p>
<p>But I can say, you&#8217;ll get used to this really fast and so I had programmed my first JSON web service very fast. But as always stuff get a little more complex …</p>
<p>The first hurdle I had to climb where collections. Unlike the good old <code>for (…;…;…) {…}</code> loop in Java the <code>(for …)</code> list comprehension in Clojure is a beast. The first thing to do, is to realize that despite the name these two guys are totally different. Staring with the fact that the Clojure <code>(for …)</code> will be evaluated lazily, so if you want a similar evaluation behavior that the Java version you should try <code>(doseq …)</code>.<br />
A standard pattern in Java is to define some nice result variables and then iterate with <code>for</code> through the collection changing your variables. After the loop your result is in the variable ready for further action. But you cannot do this in Clojure because you don&#8217;t have variables. You have <code>let</code> bindings which look somewhat similar but they are not mutable like your datatypes.<br />
So the <code>(for …)</code> list comprehension works a little bit different. It takes a collection and returns a collection of same or shorter length. In the function body you can compute the new value of the new collection <code>for</code> returns. You even may skip values with the <code>:when &lt;val&gt;</code> option. A very similar function is the <code>(map …)</code> function which also maps a value to a new value and returns a lazy collection of these new values.</p>
<p><strong>The first pitfalls</strong><br />
Don&#8217;t get me wrong, the Clojure collection library is great, but you need some time to get used to it. A nasty side effect was, that shortly after I though: &#8220;Yes, I am king of all collections!&#8221; you stumble over oddities like the different behavior in the <code>(conj …)</code> function. In Clojure you have these functions <code>(cons …) </code> which adds an element in front of a sequence and <code>(conj …)</code> which append an element at the end of a sequence. At least this is what I though. In fact it does append an element if the sequence is a vector, if it is a list it behaves like <code>(cons …)</code>. You can spend some hours before you find this in the doc.</p>
<p>Another nice one &#8211; showing the power and danger &#8211; was related to Facebook and Mongo DB. We query some data from Facebook and store them into the a Mongo DB. The process only does some restructuring of the data but doesn&#8217;t touch the values before we insert them into the database. To optimize the Facebook querying we switched from a hundered calls of the Facebook <a href="http://developers.facebook.com/docs/reference/api/">graph API</a> to three <a href="http://developers.facebook.com/docs/reference/fql/">FQL</a> queries. This worked really well. But Facebook has a minor difference in the results. In the graph API the IDs are strings in the FQL result set IDs are numbers. The whole process worked percieved well for a while but the I  noticed that the queries on the Mongo DB delivered not enough results. What happened? The <a href="https://github.com/mmcgrana/clj-json">Clojure JSON library</a> we used started to deliver numbers instead of strings and we where storing them into the Mongo DB. This worked without changing a line of code, which is nice if you want it. But the queries on the Mongo DB where still looking for strings …</p>
<p><strong>Thinking more, coding less</strong><br />
I guess this says it all. The first weeks of Clojure where unsatisfying. When coded in Java I had lots of code: Classes, XML files, etc. But in Clojure the result of the day were sometimes two functions and a macro.<br />
First that occurred very strange to me but I realized that I had to code less to get the same result. And these two functions and the macro where very lean and elegant and solved problems worth a couple of Java classes. This was the first time I really realized the power of Clojure and the different approach.</p>
<p><strong>Homoiconic or code is data</strong><br />
If you start with Clojure you soon stumble about this whole code is data stuff. This is was homoiconic in the end means, that the syntax of your language can be written in data structures of your language. If you look at:</p>
<pre>
(for [i (range 1 100)] (println i))
</pre>
<p>You can read it as list with the first element <code>for</code> as symbol, a vector of further forms as second element and another list as third elements. The term for this is forms.</p>
<p>So doing this all LISPs have an extremely small syntax. At least that is what they are telling you. But I believe that the LISP/Clojure gurus (e.g. <a href="http://groups.csail.mit.edu/mac/users/gjs/">Gerald Jay Sussman</a> or <a href="http://twitter.com/#!/richhickey">Rich Hickey</a>) are cheating us a little bit.</p>
<p>I guess I have to agree that the languages it self has very little syntax, but the language is shifting the complexity into the libraries. If you have a look at the <code>(for …)</code> comprehension. You saw the simple variant a few lines ago but you can also du this: </p>
<pre>
(for [i (range 1 100) :let [f (format "%03d" i)] :when (odd? i)] (println f))
</pre>
<p>This nice little feller prints all odd numbers from 1 to 100 formatted with leading zeros. But instead of using <code>(let …)</code> or filtering the range collection I used some not so well documented options of the binding vector of the <code>(for …)</code>. So how does it work? First <code>for</code> works internally different because it is a Clojure special form, but there are several macros &#8211; yes and I also wrote some &#8211; who do the same. If you are interested you may look at the <code>(defpage …)</code> macro, which does also some black magic.<br />
You usually use macros to do this type of things but you also may use functions (to a certain degree). So what there macros is to analyze the vector on the first position of the parameter list. In the <code>for</code> case you would iterate through the list and if you encounter a keyword (the things with <code>:</code> like <code>:let</code>) instead of a symbol you do some extra special stuff.</p>
<p>Usually you use this to define your own <a href="http://en.wikipedia.org/wiki/Domain-specific_language">domain specific language (DSL)</a> in Clojure. This is what makes the solution of your problems very elegant because you make your problem related language where you can model and solve the problem very easily.</p>
<p>But also the Clojure standard functions are using this heavily and are so hinding a lot of implicit syntax form the user who depends on documentation and examples to discover how this works. For me this was sometimes very frustrating because very helpful options (e.g. <code>:when &lt;val&gt;</code>) are sometimes hard to find.</p>
<p><strong>Java interoperability or it&#8217;s safe as long as you are in object land</strong><br />
Clojure lives (at least in the version we use) on the Java VM &#8211; there is a .NET variant and also with <a href="https://github.com/clojure/clojurescript">ClojureScript</a> a variant which runs as Java-Script. So if you are on the JVM you want to use some the great libraries already exist in the Java ecosystem. If you e.g. look at <a href="https://github.com/mmcgrana/clj-json">clj-json</a> a very fast JSON library for Clojure. It depends on the <a href="http://jackson.codehaus.org/">Jackson</a> library and provides only a thin layer upon it.</p>
<p>To use Java objects and libraries in Clojure is very simple, the messy part only begins if you want to use primitive types. These are supported but its no fun anymore. A word of warning on working with Java objects. You are leaving the zone of immutability when you work with java objects. If you get yourself a <code>java.util.Date</code> you can mutate the date like you can do it in Java and mess up big time.</p>
<p>A very nice interop feature are <code>(deftype …)</code>, <code>(proxy …)</code> or <code>(reify …)</code>. You can use this macros to create or extend java Objects. Have a look at this:</p>
<pre>
(proxy [com.rabbitmq.client.DefaultConsumer] [(channel connection)]
       (handleDelivery [tag envelope prop body] (println body))
       )
</pre>
<p>This tiny piece of code extends the <code>DefaultConsumer</code> and overrides the <code>handleDelivery</code> method. You can hand over the received object to a channel as a consumer and integrate directly into the Rabbit MQ Java driver.</p>
<p><strong>Some words to the ecosystem</strong><br />
Finally I want to have some word about some nice tools, library and stuff on Clojure ecosystem.</p>
<p><em>Leiningen</em> &#8211; A very popular build tool which also offers dependency resolution. My experience with Leiningen is, that it works out of the box in most cases. Unfortunately it tends to hang once or twice a day, I guess it tries to figure out if it must update some dependencies when it&#8217;s gone.</p>
<p><em><a href="https://github.com/marick/Midje">Midje</a></em> &#8211; A very powerful Clojure testing framework which includes facilities to easily mock every function. This makes writing even complex tests very easy.</p>
<p><em><a href="http://avout.io/">avout</a></em> &#8211; This one is nice. It integrates tools like Clojure atoms and refs into Zookeeper (or some other coordination engines). It also offers distributed locks. Very easy to use and to build distributed<br />
cluster coordination.</p>
<p><em><a href="http://palletops.com/">pallet</a></em> &#8211; A library who offers infrastructure management (e.g. for Amazon EC2) in clojure. You also may remotely install stuff or start and stop services. Great for dev-ops, but the documentation could be better and at the moment only Clojure 1.2 is supported. It took me some effort to get it working but when you know how to use it very powerful.</p>
<p><strong>What suc**s?</strong><br />
In this post I told you various thing about the power and beauty of Clojure but where are some things that I don&#8217;t like:</p>
<p><em>No informations on data structures</em> &#8211; I already told you that in Java you write a lot of classes to structure you data. On one hand side this is a lot of overhead, but on the other hand side its also a kind of always correct and available documentation. If you have to get into some foreign code that fetches data from a database it&#8217;s very hard to discover what is the right data structure and which type are the right ones. This also makes changes very difficult.</p>
<p><em>Dynamic invocation</em> &#8211; Functions are compiled and invoked when whey are invoked. You don&#8217;t have any chance of previous checking if the function call is possible or not. This is extremely annoying when you change the signature of a function e.g. you remove a parameter. If you miss a spot where the function is called you get an error. This gets even worse if you use restructuring and variable parameter lists. You can do something like this:</p>
<pre>
(defn fetch [database &#038; {:keys [:where]}] …)
</pre>
<p>You can call this function with or without the <code>:where</code> parameter. This looks like this:</p>
<pre>
(let [all (fetch my-database)
      some (fetch my-database :where {:height {:$gt 42}})]
	…
)
</pre>
<p>This is every powerful when you are creating flexible functions for DSLs but can cause very nasty side effects when you refactor these functions and change the signature.</p>
<p><em>No bootstrapping</em> &#8211; In the Java world you have dependency injection frameworks like <a href="http://code.google.com/p/google-guice/">Google Guice</a> or the <a href="http://www.springsource.org/">Spring framework</a>. These frameworks are very helpful when you want to invert the control flow. The services you write do not have to be aware how to find the suitable services and resources. You are centralizing the bootstrapping process in one location (e.g. classes in Guice or XML in Spring).<br />
Clojure does not offer this facilities &#8211; you don&#8217;t have objects to store state, not even configuration state. The solution we choose is like a typical <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html">pattern</a>. One namespace provides functions to access the resources (e.g. database connections, etc.) and there functions can be called from every where.<br />
But this has also the same drawbacks than the classical service locator. You don&#8217;t have control about timing and the class is like a spider in the web called from every where.</p>
<p><em>Clojure 1.2</em> &#8211; The current stable release is Clojure 1.3. Unfortunately some libraries we wanted to use where still based on Clojure 1.2. In general this could work but be had some strange effects on some libraries which took us a while to discover that it was a Cojure 1.2/1.3 problem. A clear strategy how to deal with this isn&#8217;t there yet, so all you can do is try and error.</p>
<p><strong>Loose ends</strong><br />
I didn&#8217;t talk about stuff like STM (software transactional memory), Agents, Refs or Atoms. Mostly because they worked in the first place for me, or never even tried them. There are also a couple of nice library in the Clojure eco system which make your life as developer very easy. I recommend, that you have closer look yourself.</p>
<p><strong>… and in the end</strong><br />
To be honest, I had a tough couple of days in the last days. We are are in a stage where our prototype application  grows into a real world application and we want to establish structures which makes maintenance easier. Unfortunately this is not so easy as we expected.</p>
<p>So my conclusions right now:</p>
<ul>
<li>Clojure is fun &#8211; I really like it to write two line functions that kick ass.</li>
<li>Clojure does not need to hide &#8211; The eco system is growing fast and has some interesting libraries</li>
<li>The lack of tooling is sometimes a pain. There are times where <code>clojure.tools.logging/spy</code> or <code>println</code> are not enough. The absence of a debugger is sometimes a real productivity black hole.</li>
<li>Due to the dynamic nature you&#8217;ll have to write a lot of tests to be able to perform refactorings. Only with a lot of tests you can make sure that the code will work afterwards.</li>
<li>Document your data structures to make sure that other developers have a chance to work in your code. I made some good experiences with a namespace that containes accessor functions. You can validate there functions with unit tests and the other guys in your team can easily see which values the can expect.</li>
</ul>
<p>Nobody can say right now, how our little adventure with Clojure will end. But for the first release of out product our backend services will be based on Clojure. The time will tell how the maintainability and the performance of the backend will develop.</p>
<p>Right now I am not that confident that the solution will be good enough to be in service for a long time. But maybe Clojure surprises me … again … </p>
<p><code></code></p>
<div class="shr-publisher-139"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2012/04/first-hundred-days-of-clojure/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>The curl cheat sheet to myself</title>
		<link>http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/</link>
		<comments>http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 14:11:53 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=109</guid>
		<description><![CDATA[It has been not even a full week building REST style interfaces for the Playmaker Studio mobile platform and I am very annoyed of all the curl guides how to access your REST API with curl. So here is my cheat sheet on this topic. Be aware that the I will update this frequently. Common [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It has been not even a full week building REST style interfaces for the <a href="http://www.playmakerstudio.com/">Playmaker Studio</a> mobile platform and I am very annoyed of all the <code>curl</code> guides how to access your REST API with <code>curl</code>. So here is my cheat sheet on this topic. Be aware that the I will update this frequently.<br />
<span id="more-109"></span></p>
<h2>Common use cases</h2>
<h3>GETting data from a URL</h3>
<p>This is a very simple use case just use:</p>
<pre class="brush:bash">
curl https://graph.facebook.com/740999649
{"id":"740999649","name":"Niclas Meier"}
</pre>
<p><code>curl</code> will automatically use the HTTP method <code>GET</code>.</p>
<h3>POSTting updates</h3>
<p>In the REST dictionary the HTTP method <code>POST</code> represents the verb &#8216;update&#8217;. So updating data implies a <code>POST</code> request to an URL.</p>
<h4>Basic</h4>
<p>Let&#8217;s have a look at the basics, I added some (revised / half the original) debugging output by supplying the <code>-v</code> option.</p>
<pre class="brush:bash">
curl -v -X POST http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d 'name=Niclas'

&gt; POST /1/stuff/23f96c6bd4c87910c.json HTTP/1.1
&gt; Host: localhost:8080
&gt; Accept: */*
&gt; Content-Length: 11
&gt; Content-Type: application/x-www-form-urlencoded
&gt;
&lt; HTTP/1.1 200 OK
&lt; Content-Type: text/plain; charset=utf-8
&lt; Content-Length: 25
&lt;
Stuff: 23f96c6bd4c87910c
</pre>
<p>There are some options involved:</p>
<ul>
<li><code>-v</code> added the request/response header for debugging</li>
<li><code>-X</code> specified the request method (<code>POST</code>) to use.</li>
<li><code>-d</code> added some data in the request (<code>POST</code>) body.</li>
</ul>
<p>So the <code>'name=Niclas'</code> was sent to the server using the request body, but <code>curl</code> does not display the request body using the <code>-v</code> option.</p>
<h4>Using a JSON body</h4>
<p>So this is nice, when you want to post key-value pairs to your server, but many applications (e.g. <a href="http://couchdb.apache.org/">CouchDB</a> want to post JSON objects to the server. The initial guess</p>
<pre class="brush:bash">
curl -v -X POST http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d '{"name":"Niclas"}'

Stuff: 23f96c6bd4c87910c, JSON body:
</pre>
<p>does not work. That&#8217;s where the content type comes in. If you post the JSON whiteout supplying the proper content type <code>curl</code> and/or the server will try to use  <code>application/x-www-form-urlencoded</code><a href="http://www.w3.org/TR/html4/interact/forms.html"><sup>*</sup></a> content type. This is the same content type your browser uses when submitting a form to a web server. Doesn&#8217;t sound bad, does it?</p>
<p>But it&#8217;s bad because the JSON will be ignored/dropped/whatever and the server is unable to understand the request. To solve the problem use:</p>
<pre class="brush:bash">
curl -H "Content-Type: application/json" -X POST  http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d '{"name":"Niclas"}'

Stuff: 23f96c6bd4c87910c, JSON body: {"name":"Niclas"}
</pre>
<p>So these options are involved</p>
<ul>
<li><code>-X</code> specified the request method (<code>POST</code>) to use.</li>
<li><code>-H</code> added the header <code>Content-Type: application/json</code> to the request.</li>
<li><code>-d</code> defined the data used for the request body (<code>{"name":"Niclas"}</code>).</li>
</ul>
<h4>A JSON file as body</h4>
<p>So far so good. But if you have huge JSON requests, you don&#8217;t want to type all the JSON into the console. You may use the <code>@</code> symbol in conjunction with the <code>-d</code> option so <code>curl</code> will read the request body contents from a file. This may look like this.</p>
<pre class="brush:bash">
curl -H "Content-Type: application/json" -X POST  http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d @some-huge-request.json

Stuff: 23f96c6bd4c87910c, JSON body: {"name":"Niclas", ..., "foo":"Bar"}
</pre>
<p>A nice trick is, that if you use the <code>-d</code> with <code>@-</code>. <code>curl</code> will read the request body from the standard input. So you can do stuff like this:</p>
<pre class="brush:bash">
cat some-huge-request.json | curl -H "Content-Type: application/json" -X POST  http://localhost:8080/1/stuff/23f96c6bd4c87910c.json -d @-

Stuff: 23f96c6bd4c87910c, JSON body: {"name":"Niclas", ..., "foo":"Bar"}
</pre>
<h3>PUTting stuff</h3>
<p>Is much like <code>POST</code>, so if you can <code>POST</code> you can <code>PUT</code>. One nasty little difference is, that you don&#8217;t have to supply a <code>Content-Type</code> HTTP header for <code>PUT</code>. <code>curl</code> does not use <code>application/x-www-form-urlencoded</code> as content type for <code>PUT</code>. Lost an hour (or so), because I did some <code>PUT</code> stuff before switching to  <code>POST</code>.</p>
<h2>Debugging</h2>
<h4>Detailed information</h4>
<p>The key to get almost every information by supplying the <code>-v</code> option to curl.</p>
<pre class="brush:bash">
curl -v https://graph.facebook.com/740999649

* About to connect() to graph.facebook.com port 443 (#0)
*   Trying 66.220.147.38... connected
* Connected to graph.facebook.com (66.220.147.38) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-MD5
* Server certificate:
* 	 subject: C=US; ST=California; L=Palo Alto; O=Facebook, Inc.; CN=*.facebook.com
* 	 start date: 2010-01-13 00:00:00 GMT
* 	 expire date: 2013-04-11 23:59:59 GMT
* 	 common name: *.facebook.com (matched)
* 	 issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance CA-3
* 	 SSL certificate verify ok.
&gt; GET /740999649 HTTP/1.1
&gt; User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
&gt; Host: graph.facebook.com
&gt; Accept: */*
&gt;
&lt; HTTP/1.1 200 OK
&lt; Access-Control-Allow-Origin: *
&lt; Cache-Control: private, no-cache, no-store, must-revalidate
&lt; Content-Type: text/javascript; charset=UTF-8
&lt; ETag: "f89bfe40c87e487ae641d427c96746b226a91f3c"
&lt; Expires: Sat, 01 Jan 2000 00:00:00 GMT
&lt; Pragma: no-cache
&lt; X-FB-Rev: 482216
&lt; X-FB-Server: 10.36.50.102
&lt; X-Cnection: close
&lt; Date: Wed, 07 Dec 2011 13:14:19 GMT
&lt; Content-Length: 183
&lt;
* Connection #0 to host graph.facebook.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
{"id":"740999649","name":"Niclas Meier","first_name":"Niclas","last_name":"Meier","link":"http:\/\/www.facebook.com\/people\/Niclas-Meier\/740999649","gender":"male","locale":"de_DE"}</pre>
<p>But for may occasions that is simply too much, so check out the <code>-i</code> option.</p>
<h4>Header information</h4>
<p>Often it&#8217;s enough to get only the response headers for debugging. To get only these headers just use the <code>-i</code> option in <code>curl</code>.</p>
<pre class="brush:bash">
curl -i https://graph.facebook.com/740999649
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: text/javascript; charset=UTF-8
ETag: "f89bfe40c87e487ae641d427c96746b226a91f3c"
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
X-FB-Rev: 482216
X-FB-Server: 10.42.67.29
X-Cnection: close
Date: Wed, 07 Dec 2011 13:18:24 GMT
Content-Length: 183

{"id":"740999649","name":"Niclas Meier","first_name":"Niclas","last_name":"Meier","link":"http:\/\/www.facebook.com\/people\/Niclas-Meier\/740999649","gender":"male","locale":"de_DE"}</pre>
<div class="shr-publisher-109"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/12/the-curl-cheat-sheet-to-myself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a new move &#8211; again</title>
		<link>http://www.niclas-meier.de/2011/12/making-a-new-move-again/</link>
		<comments>http://www.niclas-meier.de/2011/12/making-a-new-move-again/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 12:33:24 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Privat]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=107</guid>
		<description><![CDATA[After been almost 10 years at SinnerSchrader it&#8217;s very confusing for me to be on the move again. On the 1st of December I joined Playmaker Studio after being at gamigo for 18 month.You now may ask why? I don&#8217;t want to explain every thought that led to the decision, but I can say I [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/12/making-a-new-move-again/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>After been almost 10 years at <a href="http://www.sinnerschrader.de/">SinnerSchrader</a> it&#8217;s very confusing for me to be on the move again. On the 1<sup>st</sup> of December I joined <a href="http://www.playmakerstudio.com/">Playmaker Studio</a> after being at <a href="http://www.gamigo.de">gamigo</a> for 18 month.<span id="more-107"></span>You now may ask why? I don&#8217;t want to explain every thought that led to the decision, but I can say I enjoyed my job at gamigo. I learned damn much, especially stuff I never anticipated (I am not saying that I didn&#8217;t wanted to learn most of it <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). I had a great team making a giant leap in the software development processes, nice colleagues and we brought the company a huge step ahead.</p>
<p>But it was more than about time to get a new direction in working life. At gamigo my job drifted to a pure management position and I was  nudging around <a href="http://www.atlassian.com/de/software/jira/overview">JIRA tickets</a> and <a href="http://office.microsoft.com/de-de/excel/">Excel files</a> (okay some of them where <a href="https://docs.google.com/">Google Docs</a> <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) the whole day. But now I joined the Ranks of technicians again <code>&lt;cheer /&gt;</code>!</p>
<p>Hopefully I will have some time for reviving this blog. For now I am trying to learn some new stuff &#8211; like <a href="http://clojure.org/">Clo<i>j</i>ure</a>, <a href="http://webnoir.org/">Noir</a>, <a href="http://www.heroku.com/">Heroku</a> or <a href="http://www.mongodb.org/">mongoDB</a>for my new job. For me, this sounds like lots of fun!</p>
<div class="shr-publisher-107"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/12/making-a-new-move-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing around with Scala</title>
		<link>http://www.niclas-meier.de/2011/05/playing-around-with-scala/</link>
		<comments>http://www.niclas-meier.de/2011/05/playing-around-with-scala/#comments</comments>
		<pubDate>Sun, 29 May 2011 15:39:20 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=100</guid>
		<description><![CDATA[After some inspiration the last few weeks, I decided to scrape together some spare time and have a closer look at the Scala programming language. This was kind of overdue because I am trying to have a look at new technologies at least once a year. One major challenge is always finding an interesting topic [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/05/playing-around-with-scala/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>After some inspiration the last few weeks, I decided to scrape together some spare time and have a closer look at the <a href="http://www.scala-lang.org">Scala</a> programming language. This was kind of overdue because I am trying to have a look at new technologies at least once a year. </p>
<p>One major challenge is always finding an interesting topic which also has an appropriate level of difficulty. For my venture into  <a href="http://www.scala-lang.org">Scala</a> I choose a small open source project which I initiated two years ago called <a href="http://code.google.com/p/jaev/"></a>. This small framework validates an e-mail address and also checks the domain (via the DNS). This project seemed to have the right size and so I decided to build a scala variant called <a href="https://github.com/niclasmeier/saev">saev</a>.</p>
<p>This turned out to be a very demanding venture which challenges a lot of knowledge and beliefs which I have from my activities in the Java environment.<span id="more-100"></span>I would be lying if wouldn&#8217;t tell you, that I already head some doubts on the proceedings in the Java community. Things like having no update on the JDK for about two years now, including the unfortunate discussions on lambda expressions in Java, are paralyzing the development on the language basis. On the other hand side I have no idea how to judge the acquisition of Sun Microsystems by Oracle.</p>
<p>I first stumbled over Scala when I still was working at <a href="http://www-de.scoyo.com">scoyo</a>, when my former boss was building a small script which was converting localized text into an XML format. I found the language it self quite interesting but when you are in the middle of a Java team it was not easy to get started with it and had other things occupying me more.</p>
<p>Beginning this year I was willing to give <a href="http://www.scala-lang.org">Scala</a> a new chance after having a quick look at <a href="http://www.php.net">PHP</a> and <a href="http://www.ruby-lang.org/de">Ruby</a>. Both of PHP and Ruby didn&#8217;t convince me so I bought a <a href="http://www.amazon.com/Programming-Scala-Comprehensive-Step---Step/dp/0981531644/ref=sr_1_1?ie=UTF8&amp;qid=1306680866&amp;sr=8-1">Scala book</a> and read it. But I must confess after this lecture I still was interested but nothing more. But after attending the <a href="http://www.devcon-hamburg.de/">Developer Conference Hamburg 2011</a> I decided to give Scala a real try.  So I bought another <a href="http://www.amazon.de/Scala-für-Umsteiger-Friedrich-Esser/dp/3486596934/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1306681065&amp;sr=8-1">book</a> especially written by <a href="http://www.informatik.haw-hamburg.de/esser.html">Prof. Dr. Friedrich Esser</a> for guys who want to change form e.g. Java to Scala. I just want to take the take the time to recommend this <a href="http://www.amazon.de/Scala-für-Umsteiger-Friedrich-Esser/dp/3486596934/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1306681065&amp;sr=8-1">book</a> &#8220;<a href="http://www.amazon.de/Scala-für-Umsteiger-Friedrich-Esser/dp/3486596934/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1306681065&amp;sr=8-1">Scala für Umsteiger</a>&#8220;. Very well written book which shows you in the first chapter (approx. 100 pages) how to write the stuff you do in Java in the Scala language. An then fasten your seat belts <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I am playing around with Scala for about a week right now, but I have to confess that I am somehow impressed and also a little bit scared. Let me explain why:<br />
Fist of all the syntactical power of this &#8220;post functional&#8221; language is impressive for someone who did Java for over ten years. You can describe many of your problem solution in a very simple way. But when you want/need you can always fall back into Java because Scala uses the Java VM as foundation. On the other hand side I met a couple of programmers which are nice people, but who would be overstrained by this. And to be honest there are always situations where I take both of my books and google to figure out what some code is doing and why it&#8217;s working.<br />
Don&#8217;t get me wrong I am pretty good programmer and I am using even complex concepts like AOP (aspect oriented programming) or dependency injection for a couple of years now. And I know the can cause lots of trouble and I am not sure if I should like <code>@Transactional</code> or not.</p>
<p>For my personal development I am quite sure, that I will continue to investigate Scala a little further. On the business side I am not sure if Scala will find a place in my development team. I said already ten years ago that you can use a bunch of trained apes to finish you Java project. It will take some time but the apes will figure it out. And that robustness is what you want on enterprise projects. Maybe for innovative companies or startups Scala is the language of choice or for companies which are willing to have polyglot development environment.</p>
<div class="shr-publisher-100"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/05/playing-around-with-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mind the gap</title>
		<link>http://www.niclas-meier.de/2011/05/mind-the-gap/</link>
		<comments>http://www.niclas-meier.de/2011/05/mind-the-gap/#comments</comments>
		<pubDate>Sun, 22 May 2011 19:35:22 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[Software development]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=96</guid>
		<description><![CDATA[It&#8217;s sunday and I am fed up, sitting lazy behind my computer and taking a review of the last week. I attended two conferences this week so I am full of new ideas (don&#8217;t know if they are good yet) and wan&#8217;t to take a closer look on so many topics. The first conference was [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/05/mind-the-gap/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It&#8217;s sunday and I am fed up, sitting lazy behind my computer and taking a review of the last week. I attended two conferences this week so I am full of new ideas (don&#8217;t know if they are good yet) and wan&#8217;t to take a closer look on so many topics.</p>
<p>The first conference was the <a href="http://nextconf.eu">next conference</a> in Berlin which was initiated some years a go by my former employer <a href="http://www.sinnerschrader.de">SinnerSchrader</a>. So the focus of the <a href="http://nextconf.eu">next conference</a> was mixture of brand, media, entrepreneurship and technology. Due to the fact that I meet a couple of former colleagues &#8211; some of them still working for <a href="http://www.sinnerschrader.de">SinnerSchrader</a>.</p>
<p>The second conference was the <a href="http://www.devcon-hamburg.de/">Developer Conference Hamburg 2011</a> which had a sole technology focus.<span id="more-96"></span>I heard couple of very good talks on both conferences. My highlight was the the keynote of <a href="http://www.cardcloud.com/werner">Werner Vogels</a> the CTO of Amazon which spoke about the analysis of big dataset which are regularly produced by modern IT infrastructures. If you generate a couple of gigabytes of data every day you should get the information out of them.</p>
<p>Another highlight of both conferences where the <a href="http://couchdb.apache.org/">Couch DB</a> talks. Both held by <a href="http://twitter.com/#!/janl">Jan Lehnhardt</a>, one of the <a href="http://couchdb.apache.org/">Couch DB</a> core commiters who works for <a href="http://www.couchbase.com/">Couchbase</a>. Jan can talk very fast in his talks, especially when he had some coffee <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . But there is no bull*** and he definitely knows what he is talking about. Because I attended the <a href="http://nextconf.eu">next</a> and the <a href="http://www.devcon-hamburg.de/">devcon</a> I was able to get a 10.000m overview and a 100m close look on the <a href="http://couchdb.apache.org/">Couch DB</a>. I am very fascinated by this topic, but I have at the moment no idea where to use it.</p>
<p>A dilemma what <a href="http://couchdb.apache.org/">Couch DB</a> shares with <a href="http://nodejs.org/">node.js</a>. I heard of <a href="http://nodejs.org/">node</a> on both conference too. On the next <a href="http://nodejs.org/">node.js</a> was presented by <a href="http://blog.izs.me/">Isaac Z. Schlueter</a>. The topic was how <a href="http://nodejs.org/">node.js</a> performs on DIRT (<u>d</u>ata <u>i</u>ntensive <u>r</u>eal <u>t</u>ime) applications. At <a href="http://www.devcon-hamburg.de/">devcon</a> <a href="http://nodejs.org/">node.js</a> was presented by <a href="http://twitter.com/#!/felixge">Felix Geisendörfer</a> which gave a more wide range overview on the capabilites of <a href="http://nodejs.org/">node.js</a>. Unfortunately my <a href="http://www.gamigo.de">current employer</a> does at the moment some kind of &#8220;boring&#8221; <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  e-commerce stuff, so no real use for node here. Some <a href="http://www.sinnerschrader.de">SinnerSchrader</a> guys had a very innovative idea using node building the <a href="http://digitalfoosball.com/">The World’s First Digital Foosball Table</a> &#8211; nice one!</p>
<p>But the most influencing talks where from <a href="http://www.informatik.haw-hamburg.de/esser.html">Prof. Dr. Friedrich Esser</a> from the <a href="http://www.haw-hamburg.de/">HAW Hamburg</a> about <a href="http://www.scala-lang.org/">Scala</a>. The talk and the workshops where full of snappy remarks on <a href="http://www.java.com/">Java</a> programming language. I am doing Java for over ten years now. And I am confident that I am pretty good at <a href="http://www.java.com/">Java</a> and it was my favorite language the last ten years. But in the recent time I am feeling bored by <a href="http://www.java.com/">Java</a> and it&#8217;s very tight restrictions. We&#8217;ll see where the journey goes with this  <a href="http://www.scala-lang.org/">Scala</a> stuff.</p>
<p>On the other hand side there were also some talks &#8211; which we presented brilliantly &#8211; that where about stuff that I am doing for a couple of year now. One of these was the &#8220;Abstract monitoring&#8221; talk from <a href="https://www.xing.com/profile/Johannes_Mainusch">Dr. Johannes Mainusch</a> from Xing. Very nice talk, I agree 100% but I was also doing this since 2005. Good to see that other developers are cooking with water too <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>But the last week reminded me of the gap what we have at the moment and what I am supposed to close as soon as possible. But now I am armed with some new ideas &#8230;</p>
<div class="shr-publisher-96"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/05/mind-the-gap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nginxing around with WordPress</title>
		<link>http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/</link>
		<comments>http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 19:30:24 +0000</pubDate>
		<dc:creator>Niclas Meier</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[Webserver]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=91</guid>
		<description><![CDATA[Some of you may already have noticed, that this blog uses WordPress as blog software. Nothing special about that I guess. As I mentioned before in January/February I moved my website from my old provide to a new one making some significant changes to the blog and it&#8217;s infrastructure. I am in the web business [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Some of you may already have noticed, that this blog uses <a href="http://www.wordpress.com">WordPress</a> as blog software. Nothing special about that I guess. As I mentioned before in January/February I moved my website from my old provide to a new one making some significant changes to the blog and it&#8217;s infrastructure.</p>
<p>I am in the web business since a couple of years and I already worked with a couple of servers. Like most of the others I worked most with the <a href="http://httpd.apache.org">Apache web server</a>. Which is still the work horse of the internet. But recently the <a href="http://nginx.org/">nginx</a> web server which is a lean, mean web serving machine. To get a little more experience with this product I decided to use it for my blog.<span id="more-91"></span>The <a href="http://nginx.org/">nginx</a> web server already matured already 9 years and reached recently (12. April 2011) the version 1.0.0 (congratulations on this by the way <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ). But there are still some major differences between the <a href="http://httpd.apache.org">Apache</a> and the <a href="http://nginx.org/">nginx</a> web servers.<!--more-->For me this started when I wanted to use <a href="http://www.wordpress.com">WordPress</a> which is build upon <a href="http://www.php.net">PHP</a>. <a href="http://www.php.net">PHP</a> itself depends on the <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">common gateway interface</a> (a.k.a. <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a>) which is a <a href="http://httpd.apache.org/docs/2.0/mod/mod_cgi.html">long time component</a> of the Apache web server. Unfortunately the nginx server does not support <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> so you&#8217;ll have cover some more basics.</p>
<p>nginx itself supports CGI using the <a href="http://en.wikipedia.org/wiki/FastCGI">fast CGI</a> standard. Which does actually a little bit more the plan CGI. To serve fast CGI you may use the <a href="http://wiki.nginx.org/HttpFcgiModule">nginx fast CGI module</a>, so you still have access to all the scripting languages you like. But be aware that the nginx web server is known for it&#8217;s fabulous capabilities serving static content.</p>
<p>After installing nginx, a fast CGI wrapper app to execute the PHP scripts and configuring the fast CGI module, the setup of the WordPress blog was pretty basic. I&#8217;m using a standard <a href="http://www.mysql.com">MySQL</a> database backing the WordPress. The whole system runs on a <a href="http://www.centos.org/">CentOS</a> linux. The choice of the linux distribution was also inspired by the preferred system I use at my job for almost two years. Some times it&#8217;s good to stick to things you know <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>This was the status on which the whole system ran since February. But as a few &#8211; regarding to google analytics &#8211; of you may have noticed that the whole system was very slow. This is a direct result of my stinginess, because I don&#8217;t want to pay more money for my root server <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So today I invested some spare time to look for other optimizations and I would like to say, that I was successful. My first search lead to a WordPress plugin to cache the pre-rendered WordPress pages. I have not this much posting and commenting traffic, so pre-rendering the pages seemed to be a good idea. The plugin of my choice is <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> which provides a very easy to configure caching of WordPress pages.<br />
But I wanted to go one step further: The <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> plugin offer the possibility to bypass WordPress and PHP completely by using compressed pre-rendered pages via <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a>. I guess most of you noticed the problem: <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a> is an Apache module, which does not work with the nginx server, but nginx provides a powerful <a href="http://wiki.nginx.org/HttpRewriteModule">rewriting module</a> too. A very helpful <a href="http://ocaoimh.ie/2009/11/23/wordpress-nginx-wp-super-cache/">blog post</a> from the WP Super Cache author helped to configure the web server. And now &#8211; at least for any anonymous user &#8211; the site is fast.</p>
<p>It do no longer take about two seconds to return the the first bytes to the user and the page itself is compressed only approximately five kilobytes large. To speed up the perceived loading time of the page, I am using the <a href="http://wordpress.org/extend/plugins/use-google-libraries/">Use Google Libraries</a> plugin pass the delivery of standard Java Script libraries to google. So the libraries can participate on sharing between different pages and the long time expiry which is used by <a href="http://www.google.com">google</a>. The plugin <a href="http://wordpress.org/extend/plugins/wp-minify/">WP Minify</a> joins and compresses the JS and CSS used by the theme and other plugins I use, so the browser does download only a few minimized files instead of dozens of CSS and JS files.</p>
<p>I can say, that the experiment was quite successful and after getting familiar with some peculiarities the setup process was quite easy.</p>
<div class="shr-publisher-91"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/04/nginxing-around-with-wordpress-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A new home</title>
		<link>http://www.niclas-meier.de/2011/02/a-new-home/</link>
		<comments>http://www.niclas-meier.de/2011/02/a-new-home/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 21:33:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.niclas-meier.de/?p=74</guid>
		<description><![CDATA[I just wanted to say, that I am back &#8211; at least a kind of The last couple of month I was buried under a sh****** of work since I joined my new employer, but on the other hand side I a lot of fun and it is a very challenging job. The last couple [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2011/02/a-new-home/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I just wanted to say, that I am back &#8211; at least a kind of <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>The last couple of month I was buried under a sh****** of work since I joined my new <a href="http://www.gamigo.com">employer</a>, but on the other hand side I a lot of fun and it is a <i>very</i> challenging job.</p>
<p>The last couple of weeks I used some spare time to move my infrastructure to a new home, including this blog. I will shut down my private blog soon, I guess my live is not exciting enough or may be I am not exhibitionistic enough to write over every breath I take. But now this blog is almost completely migrated and got a shiny new theme too &#8211; I hope you like it!</p>
<p>The good news are, that I want to take up my technophile blogging activities. I learned very much in the last couple of month about writing good software and what to do to prevent it.</p>
<div class="shr-publisher-74"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2011/02/a-new-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contemporary Software Development: Building</title>
		<link>http://www.niclas-meier.de/2010/05/contemporary-software-development-building/</link>
		<comments>http://www.niclas-meier.de/2010/05/contemporary-software-development-building/#comments</comments>
		<pubDate>Sat, 15 May 2010 20:51:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[Buildr]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=68</guid>
		<description><![CDATA[The subject of my first post of the series &#8220;Contemporary Software Development&#8221; will be building. How to build your software project is a decision which is made quite early when you start developing. Unfortunately in a lot of projects this very important topic does not get the appreciation it deserves. On one hand side it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2010/05/contemporary-software-development-building/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>The subject of my first post of the series &#8220;Contemporary Software Development&#8221; will be building. How to build your software project is a decision which is made quite early when you start developing.</p>
<p>Unfortunately in a lot of projects this very important topic does not get the appreciation it deserves. On one hand side it&#8217;s a very sad story of suffering and endurance. On the other hand side we are talking about a lot of wasted money.<span id="more-68"></span>In my career as software engineer I experienced some different approaches to the project setup and the build process.</p>
<p>It started with something like <code>find . -name '*.java' | xargs javac</code>, which worked quite well for the first weeks of my professional career. But with a couple of software developer working on a project <em>you want something more standardized.</em></p>
<p>So we went on with <code>make</code><a href="http://www.gnu.org/software/make/">(*)</a>. I guess most of the software engineers will know this build tool which still is a standard tool in the Unix/Linux world. <code>make</code> is a very powerful tools but has its peculiarities also. The <code>make</code> grammar is very delicate when it comes to white spaces. I quess quite a few people sat over a broken <code>make</code> build when a <code>TAB</code> char wasted your build script.</p>
<p>In the Java world <a href="http://ant.apache.org/">Apache Ant</a> was the successor to <code>make</code> in my career. The problem with <code>make</code> and the Java world is, that make is not really platform independent. There are <code>make</code> ports for Microsoft Windows but (at least when I made the jump from <code>make</code> to Ant) it does not work very well. So if you have a heterogeneous environment e.g. you develop on Microsoft Windows and you deploy into a Linux based cloud, <em>you want your build to to be platform independent.</em></p>
<p>A nice story about platform independence. I did some consulting in a project for the Deutsche Bank Italy and a very large (and expensive) consulting company provided the BEA Weblogic build and setup. I am not 100% sure but I guess it was an <a href="http://ant.apache.org/">Apache Ant</a> based build. One major issue was the application server integration integration. To solve it, the complete project was placed and build in the application server which was committed in to the CVS source control management system. The delivery artifact was &#8211; of course &#8211; delivered without the application server. But this leads to another wish I have when I am using a build. <em>You want the build to credit the current  environment.</em> If you are building for your local development environment you may have different requirements concerning the built artifact as when you are creating an artifact that will be deployed on staging or productive environment.</p>
<p>Back on memory lane: <a href="http://ant.apache.org/">Apache Ant</a> worked pretty well for some years and a couple of projects. But one thing that started to annoy me. Every project was using a slightly build setup so in the daily business there were always searching for artifacts or checking library versions.</p>
<p>Some former colleagues introduced me to <a href="http://maven.apache.org/">Apache Maven</a>. I started with <a href="http://maven.apache.org/maven-1.x/index.html">Maven 1</a> which is a quite interesting mixture of <a href="http://ant.apache.org/">Ant</a> with a framework that offered the possibility to manipulate the Ant build file during the runtime. But <a href="http://maven.apache.org/">Apache Maven</a> had some features which I hat to get used to.<br />
An example is the rigid directory structure defined in a Maven build: Why do I have to follow them? I want my special directory names! But nowadays I love this structure which is equal in every project. You find your files so fast now and even in foreign project. That&#8217;s another thing that you want: <em>You want your builds to follow standards, so you can get familiar with the project in very short time.</em> If you are working in the software business a couple of years, may have already realized that you will see very much projects during a professional career and standard projects and processes will make your life much more easy.</p>
<p>Let&#8217;s talk about some goodies now which modern build system offer. I will use <a href="http://maven.apache.org/">Apache Maven</a> as example but other systems like <a href="http://rake.rubyforge.org/">rake</a> or <a hef="http://buildr.apache.org/">buildr</a> offer similar functions.</p>
<p>One thing I love/hate is dependency management. When I started with make or ant, we where committing all libraries into our CVS. Which worked quite well, in most cases you could check our the project, performed the initial build and started to work. But there where lots of minor but very nasty problems. Starting from which library version is really used to incompatibilities of the build tool version.</p>
<p>With the <a href="http://maven.apache.org/">Apache Maven</a> dependency resolution mechanism a new area begun. If you are having one independent project the mechanism is pretty easy to use. You define the libraries you want to use in your <code>pom.xml</code> and maven takes care of the rest. Okay if you want to use libraries which are not in the maven central repository it&#8217;s a little more complicated <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>If you are having a multi module/project environment things will get messy pretty easy, but: They would also if you don&#8217;t use the dependency management mechanism. You ask why? When you don&#8217;t use this mechanism you&#8217;ll normally have a huge monolithic project in your SCM system which will get even more difficult to manage or build. So you <em>want to have a transparent dependency management in your build system</em>. With <a href="http://ant.apache.org/ivy/">Ivy</a> for example you&#8217;ll have an add-on which offers the possibility to have an dependency management when you are using <a href="http://ant.apache.org/">Ant</a>.</p>
<p>Another goodie is release management. It&#8217;s very handy if you start a build to create your release artifact and your tag (or something similar) in the SCM system of your choice. <em>You want your release process embedded in your build system, so you can perform the build when you are creating your release.</em></p>
<p>Another important topic is testing. You <em>really want your build tool to support your testing facilities.</em> At least when you create your release or deployment artifact you want your build to automatically run your test suite.</p>
<p>I have only one topic left in this post, that is IDE support. Unfortunately most modern IDE like <a href="http://www.eclipse.org/">Eclipe</a>, <a href="http://netbeans.org/">Netbeans</a> or <a href="http://www.jetbrains.com/idea/">Intellij IDEA</a> offer a IDE specific build. This this very comfortable if you have a small project and what to deal only with your IDE. But you&#8217;ll grow really beyond this (my experience). But integration into other build tools is sometimes really poor. So you have to check how you can bridge the gap between your IDE and the build tool. E.g. the maven directory structure troubles some IDE<br />
standard configurations. Fortunatly more and more projects provide solutions for this.</p>
<p>So let&#8217;s have a quick resume. This is what you should want in your build system:</p>
<ul>
<li>standardized process</li>
<li>platform indipendence (if your need it)</li>
<li>credit current environment</li>
<li>standardized structures</li>
<li>dependency management</li>
<li>embeddable release process (including SCM support)</li>
<li>support of your test tools</li>
<li>IDE support</li>
</ul>
<p>I think this list is not too lang and offers some major improvements for your daily work. So if your build process is missing some items from this list, you maybe should think about your build process. And remember: Your development resources are far to valuable to be wasted in an inefficient build process <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-68"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2010/05/contemporary-software-development-building/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Announcing: Contemporary Software Development</title>
		<link>http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/</link>
		<comments>http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/#comments</comments>
		<pubDate>Tue, 11 May 2010 19:26:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Allgemein]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=66</guid>
		<description><![CDATA[It has been some time since my last blog post. But I promise to do better. I am planning a series ob blog post in which I am trying to explain how you should want to develop software nowadays &#8211; at least in my opinon. I will try to cover topics like: How to build [...]]]></description>
			<content:encoded><![CDATA[<div class="none"><g:plusone href="http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/" size="medium" count="true"></g:plusone></div><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It has been some time since my last blog post. But I promise to do better. I am planning a series ob blog post in which I am trying to explain how you should want to develop software nowadays &#8211; at least in my opinon.</p>
<p>I will try to cover topics like: How to build your system? How to manage you source code and you versions? Or what do do with your deployment data?</p>
<p>But I don&#8217;t want you to tell you which frameworks to use in fact I want to discuss what you should want to do not how you are going to do it.</p>
<p>I am excited, it will be a lot of work, but I am excited <img src='http://www.niclas-meier.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-66"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.niclas-meier.de/2010/05/announcing-contemporary-software-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

