<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">

  <title><![CDATA[Geekbeing]]></title>
  
  <link href="http://www.geekbeing.com/" />
  <updated>2013-03-10T18:23:16-04:00</updated>
  <id>http://www.geekbeing.com/</id>
  <author>
    <name><![CDATA[Geekbeing]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/GeekbeingsRants" /><feedburner:info uri="geekbeingsrants" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title type="html"><![CDATA[Setting up Octopress on Windows 7 a.k.a. - Ruby gems involved? Run from Windows!]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/7GYX6GYV0dw/" />
    <updated>2013-03-10T23:11:00-04:00</updated>
    <id>http://www.geekbeing.com/2013/03/10/setting-up-octopress-on-windows-7</id>
    <content type="html">&lt;p&gt;Short version - &lt;strong&gt;don&amp;#8217;t&lt;/strong&gt;. Sooner or later - shit won&amp;#8217;t work. Windows and Ruby and Gems are just not meant to be together (unless it&amp;#8217;s Windows running VM running Linux) [instructions below].&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve bought a MacBook Pro circa 2 years ago and I&amp;#8217;ve been very happy with it in the beginning. I started learning *ix operating system, felt the power of the command line, used plenty of nifty little tools, tried Ruby, done some Rails and it&amp;#8217;s been great every step on the way. No problems installing new software, no bloat-ware weighting hundreds and hundreds of megabytes. I&amp;#8217;ve proudly run my blog on &lt;a href="http://octopress.org/"&gt;Octopress&lt;/a&gt; and been thinking it&amp;#8217;s awesome.&lt;/p&gt;

&lt;p&gt;But recently I&amp;#8217;ve noticed something really funny (can&amp;#8217;t believe took me that long to realize) - I&amp;#8217;m using Windows on my Mac, booting to Mac OS X only when I need to write a post for my blog (which in turn is stupid as I mostly blog about C# when writing about code). Separate post coming up on Mac vs Windows PC from the perspective of (mostly) .NET developer. So, here&amp;#8217;s how to setup Octopress to work on your Windows 7 machine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download &lt;a href="http://www.vmware.com/products/player/"&gt;VMWare Player&lt;/a&gt;, it&amp;#8217;s free&lt;/li&gt;
&lt;li&gt;Download &lt;a href="http://www.traffictool.net/vmware/ubuntu1204t.html"&gt;Ubuntu 12.04 LTE&lt;/a&gt;, also free&lt;/li&gt;
&lt;li&gt;Unzip file downloaded in step 2, In VMWare Player - open Virtual Machine from the location where you unzipped into&lt;/li&gt;
&lt;li&gt;Boot the machine and install VMWare Tools (Ubuntu will ask about that upon first boot)&lt;/li&gt;
&lt;li&gt;Go to Settings -&gt; Displays - and change the resolution (most likely on your machine by default Ubuntu runs in funny small window)&lt;/li&gt;
&lt;li&gt;Open &amp;#8216;Terminal&amp;#8217; and switch to &amp;#8216;admin&amp;#8217; user, default password is &amp;#8216;password&amp;#8217; (assuming you&amp;#8217;ve downloaded image recommended in step 2)&lt;/li&gt;
&lt;li&gt;run&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;apt-get install git&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;run&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;apt-get install ruby1.9.3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;run (last &amp;#8216;octopress&amp;#8217; can be changed to your liking)&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;git clone git://github.com/imathis/octopress.git octopress&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;Enter the folder where you have cloned octopress&lt;/li&gt;
&lt;li&gt;run&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;gem install bundler&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;run&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;bundle install&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;run&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;rake watch&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;open another terminal window and run&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;rake preview&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;go to&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;http://localhost:4000&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Voila! PS. This post has been created on Ubuntu Linux running as a virtual machine under Windows 7 x64 and has just been deployed on Heroku (more on this in the next posts).&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/7GYX6GYV0dw" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2013/03/10/setting-up-octopress-on-windows-7/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Lumia 920 review]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/83BWtBqLL1U/" />
    <updated>2013-02-11T22:54:00-05:00</updated>
    <id>http://www.geekbeing.com/2013/02/11/lumia-920-review</id>
    <content type="html">&lt;p&gt;For a few weeks I have been using a white Nokia Lumia 920 as my main phone. TL;DR version is I didn&amp;#8217;t like it.&lt;/p&gt;

&lt;p&gt;I am really picky about the smartphones I choose to use on daily basis and I have used quite a few, starting with original iPhone just a week or so after its debut and ending up with Samsung Galaxy S III (which btw I think I&amp;#8217;m going to replace with my old iPhone 4S). To give you the context for what was important to me and what I took into account when rating Lumia 920, here&amp;#8217;s a list of what I need from my mobile phone (both hardware and software):&lt;/p&gt;

&lt;!--more--&gt;


&lt;ul&gt;
&lt;li&gt;It needs to have good battery life. In case of smartphone this means - circa 20 text messages a day, lots of Twitter, Facebook, 3G usage, streaming music on Spotify, watching a little bit of YouTube videos, taking lots of pictures, some video and last but not least - circa 15-20 minutes of talking over the phone. Push for e-mail is enabled all the time. And lots of web browsing - of course. With this kind of usage I need the battery to last from 100% at 7:00 in the morning until at least 19:00, ideally with more than 10% of juice left - so I wouldn&amp;#8217;t need to worry about charging my phone during the day.&lt;/li&gt;
&lt;li&gt;It needs to have high resolution display (with ppi circa of iPhone&amp;#8217;s &amp;#8220;Retina&amp;#8221;). I&amp;#8217;m not mentioning the screen size here, because I&amp;#8217;m kind of on the edge here. I used to believe 3.5&amp;#8221; of iPhone screen estate is an ideal size, especially since I used to use the phone with one hand only during most time of the day and each bigger phone I&amp;#8217;ve used - I simply couldn&amp;#8217;t do that. However - I changed my mind a little bit and now it rarely bothers me being forced to operate the screen with both hands. So - size does not matter that much, but resolution does. A lot. (I just can&amp;#8217;t stand ugly rendered fonts, pixelized images, etc&amp;#8230;)&lt;/li&gt;
&lt;li&gt;Notifications - easily accessible toggles - for wifi, airplane, mute, etc&amp;#8230;, nice non-intrusive (or reasonably intrusive) status bar notifications and statuses for signal strength - cellular network, data, wifi, battery, etc&amp;#8230;&lt;/li&gt;
&lt;li&gt;The browser - it needs to be stellar. Omnibar, or similar implementation, incognito mode, unlimited number of tabs, automatic form fill, fast. Ideally synchronized with my searches/preferences/bookmarks from the desktop browser. The closest any browser got to meet those expectations - is Chrome for Android. However - Chrome is pretty unstable, crashing a few times per each 15 minutes of browsing so&amp;#8230; Really a shame, it could have been perfect.&lt;/li&gt;
&lt;li&gt;Camera - able to shoot awesome pictures, great movies, easy to use, not necessarily loaded with options, I&amp;#8217;d rather go for happy-defaults, with possibility of doing some minor tricks. YouTube uploads for videos are super important. Sharing via e-mail, Facebook, etc&amp;#8230; The usual drill.&lt;/li&gt;
&lt;li&gt;Applications - This is the topic about which most discussions I see are funny or stupid. People arguing about the number of apps per each application store in particular. The most ridiculous discussions/argumentations I could hear. I&amp;#8217;ve been using both - Apple&amp;#8217;s App Store and Android&amp;#8217;s Play for quite a long time and I must say - I really don&amp;#8217;t give a shit whether you have 100, 100k, 500k, million or gazillion apps in your store. Truth being told - 95% of those are just fucking useless. Farts, pukes, beer bottles, what the fuck not. I might be a little bit off here, comparing to the average user, but really - I haven&amp;#8217;t met one single person who would have more than 50 apps installed on the smartphone that actually are of any use. So - if your app store offers 50 apps, assuming all of them would have a great quality - to me - you&amp;#8217;re all setup and have amazing ecosystem. To me, I need to have: Twitter, Facebook, Pocket (formerly Read It Later), Spotify, Dropbox, awesome Maps, awesome browser, reasonable file manager, reasonable backup tool, Flashlight, maybe circa 5 small utilities and a few games. And that&amp;#8217;s it. I assume some folks could add Instagram, Foursquare and what not, but still, I really doubt it you could make it more than fifty, when coming up with a list of absolutely necessary apps.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;With those criteria in mind, here&amp;#8217;s my experience with Lumia 920 and Windows Phone 8:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;battery life sucks. I couldn&amp;#8217;t get too much past lunch, with the usage described&lt;/li&gt;
&lt;li&gt;cellular network status, wifi, battery, etc&amp;#8230; are not always visible. You need to swipe from the top of the screen. This brings some basic info (e.g. battery does not show percentage). Or it doesn&amp;#8217;t, cause to me this gesture worked like once in 3 attempts&lt;/li&gt;
&lt;li&gt;screen resolution is fine. In general - hardware-wise I would say Nokia did a pretty good job. Phone is big and feels heavy, but to me that&amp;#8217;s fine. I like feeling what I hold, I like the fact it feels sturdy. Plastic doesn&amp;#8217;t seem cheap. Camera is fine. So - hardware is pretty good (besides battery), really a shame Microsoft has fucked almost everything else up (mind my criteria!)&lt;/li&gt;
&lt;li&gt;browser. IE. Why the fuck won&amp;#8217;t it die already. Doomed browser on desktop, even worse on mobile. I really don&amp;#8217;t give a shit whether it shares the rendering engine with the desktop version of IE. Nor whether it is super fast in Microsoft&amp;#8217;s benchmarks. Cause it sucks big time in real life I must tell you. There are plenty of pages that simply won&amp;#8217;t display. With some retarded message. Or some won&amp;#8217;t display with simple and plain message &amp;#8220;Update to a modern browser&amp;#8221;. I know, I know, Google didn&amp;#8217;t play it pretty (e.g. blocking Google Maps on Windows Phone), but really - I couldn&amp;#8217;t care less about the reasons. Then there&amp;#8217;s the fact YouTube videos very often won&amp;#8217;t simply play, complaining about not being able to be viewed on mobile (but at the same time work perfectly fine on S III and iPhone). When you start typing url in the navigation bar - it takes noticeably almost a second to load the list of completion suggestions. On Chrome, Safari, FF it is instant. Really, piece of crap.&lt;/li&gt;
&lt;li&gt;Applications - nothing good to say really. Even Twitter client is crappy. Like e.g. each time when you refresh the list of tweets it jumps to the top of it. Maybe it&amp;#8217;s how Twitter is meant to be read, but really - it does not work this way on any other platform and sure is annoying as hell. Facebook client is slow. There was no Spotify for a very long time (recently they&amp;#8217;ve released new version). I know it&amp;#8217;s not (entirely) Microsoft&amp;#8217;s fault, but again - I don&amp;#8217;t really care whose fault is that.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So, all in all - if you feel like power user and expect the best out of software and hardware - Nokia Lumia 920 is most definitely NOT your choice. Go for an iPhone or Galaxy Nexus, or Samsung&amp;#8217;s S III. Way better phones overall (mind my criteria!).&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/83BWtBqLL1U" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2013/02/11/lumia-920-review/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Setup Mono for Android on Windows - tutorial]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/nhBcQwnGHE8/" />
    <updated>2013-01-01T22:52:00-05:00</updated>
    <id>http://www.geekbeing.com/2013/01/01/setup-mono-for-android-on-windows</id>
    <content type="html">&lt;p&gt;After a short (3 weeks) adventure with Windows 8 I&amp;#8217;ve decided I don&amp;#8217;t want to struggle with the system (nor constantly switch back to &amp;#8216;Desktop&amp;#8217; mode after another accidental switch to &amp;#8216;no-longer-called-Metro-UI&amp;#8217;) and so I came back to well known, liked, cozy Windows 7 x64. This is the system I&amp;#8217;ve been using at work for a little more than last 3 years (basically since day one it RTM-ed) and the one I split time when developing at home - 50/50 with Mac OS X. I&amp;#8217;m a convert from iOS church to the Android - the mobile OS that brought me to my knees with Samsung&amp;#8217;s Galaxy S III (I&amp;#8217;ll post about it on another occasion). And so I wanted to get at least a little bit familiar with developing for Android, however I wasn&amp;#8217;t that much enthusiastic when I thought about a perspective of switching development environment to Eclipse and programming language I use on daily basis to Java. Fortunately &lt;a href="http://xamarin.com/"&gt;Xamarin&lt;/a&gt; offers the tooling that allows developers to develop for Android (as well as iOS and Mac) using C# and Visual Studio (as an option).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: The best thing you can do is to head over to &lt;a href="http://xamarin.com/trial"&gt;Xamarin - trials&lt;/a&gt; and after registering - run the setup. Mono for Android installer should automatically detect which of the prerequisites are missing from your system. However in my case (and as Google search results show I&amp;#8217;m not the only one) - this didn&amp;#8217;t work. Also - you need to have a paid version of Visual Studio (Express edition won&amp;#8217;t suffice as it does not support 3rd party extensions). I also think - following step-by-step guide gives you a better understanding of the pieces of the puzzles involved, than clicking &amp;#8216;next&amp;#8217; a few times in the installer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So here are the steps required to configure Mono for Android on Windows, with Visual Studio, to enable developing for Android mobile devices in C#:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download Java Software Development Kit 6 &lt;a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk6u38-downloads-1877406.html"&gt;Java SDK 6&lt;/a&gt; - do NOT pick x64 version (even if you are on x64 version of Windows), go for x86 version. Also for Mono for Android 4.2.5 - that&amp;#8217;s the one I&amp;#8217;ve been using - Java SDK 6 is required (it won&amp;#8217;t work with JDK 7 - although you can have both installed on your system side-by-side)&lt;/li&gt;
&lt;li&gt;Download &lt;a href="http://developer.android.com/sdk/index.html"&gt;Android SDK&lt;/a&gt; - click on the &amp;#8216;Download SDK Tools for Windows&amp;#8217; (ADT Bundle includes Eclipse, which is not the option I wanted to go for)&lt;/li&gt;
&lt;li&gt;After Android SDK is installed Android SDK Manager will run. This allows installing different APIs (these depend on the Android version you would like to target). In my case I went for API 16 (Android 4.1.2), SDK tools, Android device emulator. Pick what you see fit.&lt;/li&gt;
&lt;li&gt;Now it&amp;#8217;s time to configure your AVD (Android Virtual Device)
&lt;img src="http://content.screencast.com/users/o3tker/folders/Jing/media/32527848-afdc-422f-97b5-d5955127fcc4/2012-12-26_2246.png" alt="Choosing AVD option from Android SDK Manager menu" /&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This is the emulator that will simulate a real physical device, when you will be testing your application written in C#, with Mono for Android (to deploy to real device you need to buy a licensed version from Xamarin). There are many different Android devices in the wild, differing in screen size, screen resolution, hardware capabilities, memory size, etc&amp;#8230; The best way to setup AVD as so its configuration would reassemble a real device is to do a Google Search e.g. for &amp;#8216;Android AVD configuration for Galaxy S III&amp;#8217;. One thing to note here is that what is important is screen&amp;#8217;s resolution, API version - which may vary, depending on which Android version you have installed on your handset. So for example for Galaxy S III bought in Poland in 2012 - 90% you&amp;#8217;d get a 4.0 (Android Ice Cream Sandwich). However my handset has a custom ROM installed, which is based on the latest 4.1.2 (Android Jelly-Bean) and so I&amp;#8217;d pick API16 rather than API15. You can check the version of the ROM (Android) installed on your phone by going to Settings-&gt;About device and checking value on &amp;#8216;Android version&amp;#8217;. So - the information Googled + info about your phone will tell you everything you need to know to successfully setup your AVD. First, switch to &amp;#8216;Device definitions&amp;#8217; tab and then click &amp;#8216;New device&amp;#8217; button. Set it up like so:
&lt;img src="http://content.screencast.com/users/o3tker/folders/Jing/media/9e3c6687-96da-4334-9e70-2d0f0357646d/2012-12-26_2313.png" alt="Geekbeing's new device - Galaxy S III" /&gt;
Next, based on this device - create your AVD, mine looks like that (&lt;strong&gt;Note: if later on, when trying to run your application on AVD - when it fails - change RAM size from 1024MB to 512MB - I haven&amp;#8217;t figured out why, but it seems like AVD is unable to boot when setup with more memory than 512MB - and Visual Studio fails silently - waiting forever for Virtual Device to boot up&lt;/strong&gt;):&lt;/p&gt;

&lt;p&gt;&lt;img src="http://content.screencast.com/users/o3tker/folders/Jing/media/50c5e525-ed70-4ecf-8188-e4b392b9884b/2012-12-26_2315.png" alt="Geekbeing's choice for Galaxy S III AVD" /&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="http://xamarin.com/trial"&gt;Xamarin&amp;#8217;s page for downloading trials&lt;/a&gt;, pick Mono for Android, provide information about yourself and hit download. Run the installer.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;After everything has been installed, you can now run Visual Studio and verify whether everything&amp;#8217;s setup properly. Begin your adventure by
clicking File -&gt; New Project and configure it like so:
&lt;img src="http://content.screencast.com/users/o3tker/folders/Jing/media/46ac354a-a25e-4191-adee-0f84cb66e9f0/2012-12-27_0042.png" alt="Geekbeing - new project, new adventure" /&gt;
After the project has been created hit ctrl+shift+b to build the solution. If everything is installed and properly configured, you should end up with an output log similar to this one:
&lt;img src="http://content.screencast.com/users/o3tker/folders/Jing/media/063f5f73-c54e-4a56-b215-12606297b2cc/2012-12-27_0048.png" alt="Geekbeing - merry output log" /&gt;&lt;/p&gt;

&lt;p&gt;Here are some materials to get you started: &lt;a href="http://docs.xamarin.com/android/guides"&gt;Mono for Android Tutorials and Guides&lt;/a&gt; for free, or should you prefer the book and have some dime to spend - &lt;a href="http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-Programming-with-Mono-for-Android-and-NET-C-.productCd-1118026438.html"&gt;Professional Android Programming with Mono for Android and .NET/C#&lt;/a&gt;, happy coding!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/nhBcQwnGHE8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2013/01/01/setup-mono-for-android-on-windows/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript Tutorial, Part 3 - Dev setup, tooling, learning resources]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/ufOPMEyUcfU/" />
    <updated>2012-12-20T16:57:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/12/20/javascript-tutorial-part-3</id>
    <content type="html">&lt;p&gt;&lt;strong&gt;Note: next three paragraphs are mainly targeted at the less experienced programmers/software engineers. And a few things here and there in the next paragraphs too.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Market for software tools (both paid and free) is huge nowadays and so there are plenty of options to go for. In my mind picking a tool is like picking a dish in a restaurant - unless you&amp;#8217;re going for something super-exotic in a cuisine you&amp;#8217;re entirely not familiar with and advice from someone experienced might be an option to consider - it should be entirely up to you what you&amp;#8217;re going to pick from the menu (and decide how you would like to have it done). And so it may take a few trials, errors and course corrections before you pick something. I believe this step is very important and although you should go and do your research (reading the posts/reviews/comparing features) - there is no better way to find out what suits you and your style than checking out a few options, gaining hands-on experience.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Having said that I also must admit there are many experienced programmers who believe that especially when you&amp;#8217;re just starting your journey with programming (in general or with a new language) - tooling is something that might actually get in a way of learning new things. It might skew your perspective (hiding important details/abstractions), may suggest code improvements which you likely accept, but without understanding or might simply confuse you - providing too many options to pick from. &lt;a href="http://pragprog.com/book/tpp/the-pragmatic-programmer"&gt;The Pragmatic Programmer: From Journeyman to Master&lt;/a&gt; is a must-read book, all time classic, you should read (more than touches on the tooling). The advice from this book is to pick the simplest tool, one that looks like it might be ok on the surface and then sticking to mastering it, getting to know all of the functions, to basically know it inside out.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m on the fence here. On the one hand I think it&amp;#8217;s a pretty good, solid advice, on the other I don&amp;#8217;t really see the point of making things harder than they actually are. I&amp;#8217;ll give you a one example - code snippets for the boilerplate. When HTML 4 and XHTML were ruling the world, you needed to type in this arcane, crazy ‘doctypes’ in the beginning of your HTML code. I would bet Champagne against nuts there is no more than a handful of developers out there who actually know this tag by heart. And even for those who do - I don&amp;#8217;t really think there&amp;#8217;s a point. So I think it&amp;#8217;s much better to just type html:4 and press tab to have it automagically inserted than to copy &amp;amp; paste (or rewrite by hand from somewhere else). The bottom line for you to take out of this is to go, read, download, install, try out and figure out on your own.&lt;/p&gt;

&lt;p&gt;After this longish introduction, I&amp;#8217;ll share with you what are the books, sites and tools I am using and can recommend, when working with JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning resources (books, blogs, sites)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Books&lt;/em&gt; I&amp;#8217;ve read (or at least quickly scanned) multiple books on JavaScript, out of which I would strongly recommend &lt;a href="http://shop.oreilly.com/product/9780596805531.do"&gt;JavaScript: The Definitive Guide, 6th Edition&lt;/a&gt;, &lt;a href="http://shop.oreilly.com/product/9780596517748.do"&gt;JavaScript: The Good Parts&lt;/a&gt; and &lt;a href="http://www.wrox.com/WileyCDA/WroxTitle/Professional-JavaScript-for-Web-Developers-3rd-Edition.productCd-1118222199.html"&gt;Professional JavaScript for Web Developers, 3rd Edition&lt;/a&gt;. &amp;#8216;The Good Parts&amp;#8217; is a little more advanced, so for the most of the people it&amp;#8217;s not the best suited to be the very first book on JavaScript to read. Remaining two cover more or less the same areas - so it&amp;#8217;s a matter of taste/price tag - which one should you choose.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Sites&lt;/em&gt; - &lt;a href="http://stackoverflow.com/"&gt;stackoverflow&lt;/a&gt; has plenty of answered questions regarding JavaScript. Should you get stuck somewhere on your JavaScript journey - it&amp;#8217;s very likely someone already asked about this issue and that some of the good willed people already answered in detail. This is an ultimate source of knowledge. When you&amp;#8217;ll get advanced enough, it&amp;#8217;s also very informative to take a look at the code of the JavaScript libraries out there (although be warned - it&amp;#8217;s not for the faint of heart), like &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Blogs&lt;/em&gt; - To not repeat what&amp;#8217;s already been said - take a look at the answers in this Quora thread &lt;a href="http://www.quora.com/Tech-Blogs-and-Websites/What-are-the-best-developer-blogs-about-JavaScript-development"&gt;The best JS blogs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Videos&lt;/em&gt; - One of the things I&amp;#8217;ve recently discovered is sites with video tutorials for programmers. Thanks to my employer I now have access to Pluralsight&amp;#8217;s and Tekpub&amp;#8217;s annual subscriptions. These sites provide phenomenal content (as a technical aside note - I prefer the player Pluralsight is using as it allows me to set the playback speed without hassle - I usually watch video materials at 1.7x - 1.8x pace). &lt;a href="http://www.pluralsight.com/training/"&gt;Pluralsight&lt;/a&gt; offers 10 days trial which allows you to watch up to 200 minutes of material (any course from their library), &lt;a href="http://tekpub.com/"&gt;Tekpub&lt;/a&gt; offers some of the courses for free although there is no free trial per se.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Editors to work with JavaScript code&lt;/em&gt; - Should you need adventurous you can go for the simplest (and free) thing possible - &lt;a href="http://notepad-plus-plus.org/"&gt;Notepad++&lt;/a&gt;. Or you could use &lt;a href="http://macromates.com/"&gt;TextMate&lt;/a&gt; (Mac OS) or &lt;a href="http://www.sublimetext.com/2"&gt;Sublime Text 2&lt;/a&gt; (all OSes). Depending on the configuration and plugins installed - those can give you syntax coloring for JavaScript, offer suggestions as you type (e.g. names of the functions you can invoke on a given object, completing variable names for you, etc&amp;#8230;). This is something I would recommend you at least trying (trying means using it for a more or less 40 hours, trying to get as productive as possible and get to know most of the functionality). Only if you find the tool limiting/annoying look for the alternatives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Fully fledged IDEs&lt;/em&gt; There are many options, both online and &amp;#8216;offline&amp;#8217;, paid and free. I&amp;#8217;ll just drop you a hint about a few I&amp;#8217;ve used and been quite happy with. For pure HTML/CSS/JS I am strongly recommending JetBrains tooling - &lt;a href="http://www.jetbrains.com/webstorm/"&gt;WebStorm&lt;/a&gt;. If you would also like to do some Ruby, they have something in the market too - &lt;a href="http://www.jetbrains.com/ruby/"&gt;RubyMine&lt;/a&gt; - it offers all of the functionality WebStorm has, plus support for Ruby and Rails. Out of the free and online ones - I really like &lt;a href="http://jsfiddle.net/"&gt;jsFiddle&lt;/a&gt; - it allows you to enter your HTML, CSS and JavaScript, each one in the separate windows, and then by clicking &amp;#8216;Run&amp;#8217; you get to see the results in the &amp;#8216;Result&amp;#8217; windows. Brilliant.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Firebug&lt;/em&gt; - Should Firefox be your favorite weapon (tool) for browsing web/working - Firebug is a must-have addition for all web developers. Check out awesome tutorials by &lt;a href="http://michaelsync.net/category/firebug"&gt;Michael Sync&lt;/a&gt; and &lt;a href="http://www.w3resource.com/web-development-tools/firebug-tutorials.php"&gt;w3resource&lt;/a&gt;. There&amp;#8217;s even a book dedicated to working with Firebug, it&amp;#8217;s also worth your time &lt;a href="http://www.packtpub.com/firebug-1-5-editing-debugging-and-monitoring-web-pages/book"&gt;Firebug 1.5: Editing, Debugging and Monitoring Web Pages&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Google Chrome Developer Tools&lt;/em&gt; - Firefox used to be a must have, now since Google Chrome&amp;#8217;s developer tools have caught up, looking at my workflow and that of my collegues - ratio of devs using Firefox VS Chrome for development went from 5:1 year ago to 3:3 today (with more folks mentioning moving to Chrome as the main development tool). It provides virtually the same set of tools, so rather than having some specific advantages over Firebug, it very much depends on which browser you feel the most comfortable working with.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Development machine&lt;/em&gt; - as you can see, based on the example of jsFiddle, you don&amp;#8217;t need to much should you choose your career path as a web developer, even if you would like to learn JavaScript. So for the client side development it really does not matter that much what you will choose. However, should you would like to go further (start node.js, Rails, etc&amp;#8230;) I&amp;#8217;ve found out that actually Macs (it&amp;#8217;s more about operating system than hardware, although hardware on my MacBook Pro is just awesome to me) usually worked better for me. By better I mean it&amp;#8217;s more seamless when working with aforementioned technologies plus - if you would like to work on Windows + Visual Studio + let&amp;#8217;s say ASP .NET MVC - you can still do that. Setting up dual boot is really easy - and you get the best out of both worlds. I will post more about it in the future. For almost last two years I&amp;#8217;ve been using MacBook Pro 13&amp;#8221; with Intel&amp;#8217;s i5 processor, 8GB RAM and OCZ&amp;#8217;s Agility 3 256GB SSD drive + huge external monitor. I couldn&amp;#8217;t be happier. More on why getting a Mac might be a good idea for you - take a look at this post &lt;a href="http://wekeroad.com/2011/09/14/fanboy-mac-post"&gt;The Mac Is a Great Dev Box&lt;/a&gt;. And this is coming from the guy who used to work on ASP .NET team. Go figure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;That&amp;#8217;s all folks, for now. I&amp;#8217;ve promised writing a little bit about JavaScript libraries too, but during what I&amp;#8217;ve learned today I&amp;#8217;ve figured this topic requires a whole post dedicated to them. See you next time!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/ufOPMEyUcfU" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/12/20/javascript-tutorial-part-3/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript Tutorial, part 2 - functions and closures]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/AEtPUk-Bpl8/" />
    <updated>2012-12-18T08:57:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/12/18/javascript-tutorial-part-2</id>
    <content type="html">&lt;p&gt;As famous Douglas Crockford (JavaScript guru) noticed functions in JavaScript are the best thing in JavaScript language. In the beginning of your JavaScript journey you will be most likely using functions not to repeat the same code over and over again - so basically to encapsulate a behavior.
For example:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Multiplying function&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;multiply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;A few things to notice here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function &lt;em&gt;multiply&lt;/em&gt; does not have a name, such function is called anonymous. However it can be invoked, because we have a handle to it - variable &lt;em&gt;multiply&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Function can be assigned to a variable, just like any of the objects in JavaScript&lt;/li&gt;
&lt;li&gt;There is no type declaration for the parameters &lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt;. What is more - there is no type checking when you&amp;#8217;re invoking the function. Of course - depending on the body of the method (everything between curly brackets) it might or might not work depending on the type of the parameter passed&lt;/li&gt;
&lt;li&gt;If during function invocation you pass less parameters than it is stated in the definition, like so:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Multiplying function&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;it&amp;#8217;s not going to end with an error. Parameter &lt;em&gt;b&lt;/em&gt; will be assigned value of &lt;em&gt;undefined&lt;/em&gt; and whole result will also be &lt;em&gt;undefined&lt;/em&gt;.&lt;/p&gt;

&lt;!--more--&gt;


&lt;ul&gt;
&lt;li&gt;If you pass more parameters, any redundant (every parameter but first - assigned to &lt;em&gt;a&lt;/em&gt; and second, assigned to &lt;em&gt;b&lt;/em&gt;) ones will simply be ignored&lt;/li&gt;
&lt;li&gt;If function does not return any value, returned value will be &lt;em&gt;undefined&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Besides using named arguments (&lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt; in this example), inside of your function you can always use two additional ones - &amp;#8216;this&amp;#8217; (depending on the context it might take different values, we will discuss this further in the tutorial) and &amp;#8216;arguments&amp;#8217; - which is an array containing all of the parameters passed to the function during invocation. This means we could read the values of all of the parameters, even if someone would invoke our &lt;em&gt;multiply&lt;/em&gt; function like so:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Invoking the function with plethora of parameters&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;you still would be able to get hold on of this value, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Invoking the function with plethora of parameters&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;multiply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;//equals 1&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;//equals 2&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;//equals 3&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;//equals 4&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Of course function &lt;em&gt;multiply&lt;/em&gt; does not look like it would save a lot of effort. In fact, it would be much easier to simply write&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;rather than&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;So for a little more useful example:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Function calculating n to the power of k&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;power&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nx"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;power&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;power&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;power&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;power&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;&lt;strong&gt;The &lt;em&gt;this&lt;/em&gt; keyword&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As I&amp;#8217;ve already mentioned in this post, &lt;em&gt;this&lt;/em&gt; might mean different things, depending on the context (who &amp;#8216;owns&amp;#8217; given function) and so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;this&lt;/em&gt; may refer to Window object, when we define and call function like this:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;When *this* means Window&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// returns object Window&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;&lt;em&gt;this&lt;/em&gt; may refer to the &amp;#8216;parent&amp;#8217; object where function is defined, take a look at the next example, with object initialization:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;When *this* means current object&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myCar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Porshe&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;noise&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;wroooom&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;makeNoise&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; makes &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;noise&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;    
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;myCar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;makeNoise&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// prints &amp;#39;Porshe makes wroooom&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;&lt;em&gt;this&lt;/em&gt; can change its context when we use &lt;em&gt;bind&lt;/em&gt; method, like so:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Changing meaning of *this* by using *bind*&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;myFunction&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;myObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//will print Object to the console&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;bound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;bound&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//now it will print Window to the console&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Last topic I wanted to cover in this post is a feature called &lt;strong&gt;closures&lt;/strong&gt;. There are  multiple posts, StackOverflow questions, books, etc&amp;#8230; covering the topic, however those are coming from a different angles and it&amp;#8217;s hard to get a straight answer. However, concept of closures is one of the cornerstones of JavaScript as a language (together with functions and objects). The simplest example of the closure would be the following code:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;The simplest closure example in the world&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;outerSpace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;I&amp;#39;m in the outmost scope!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;functionUsingClosure&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;innerScope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;I&amp;#39;m inside of the scope of the function&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;I can see both: &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;outerSpace&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot; and &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;innerScope&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;functionUsingClosure&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;If your thought after seeing this code was &amp;#8220;Huh? What the hell, this isn&amp;#8217;t very impressive&amp;#8221; - well, in this case I&amp;#8217;m not impressed too, as it seems obvious to me - outerspace was defined on the global (Window object) level - it is not surprising it could be accessed from the scope of the function &lt;em&gt;functionUsingClosure&lt;/em&gt;. But the fact this example representes a clousre in action means you&amp;#8217;ve most likely already been using closures, you just didn&amp;#8217;t know you were.&lt;/p&gt;

&lt;p&gt;To end on the high note, let&amp;#8217;s take a look at a little more impressive example of how closures work in JavaScript. Consider the following code:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;More sophisticated closure example&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;span class='line-number'&gt;16&lt;/span&gt;
&lt;span class='line-number'&gt;17&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;globalValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;global value&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;letsSaveGoodForLater&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;outerFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;functionScopeDeclared&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;inner value (declared in function\&amp;#39;s lexical scope)&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;innerFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;globalValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;functionScopeDeclared&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tooLateMate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;letsSaveGoodForLater&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;innerFunction&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;tooLateMate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A little bit too late, mate!? But NO!&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;outerFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;letsSaveGoodForLater&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Let&amp;#8217;s take a moment, let this code sink&amp;#8230; Now - what do you think will happen after this code runs? Let me dissect this code for you - first function that is executed is &lt;em&gt;outerFunction&lt;/em&gt; and there&amp;#8217;s nothing surprising here. &lt;em&gt;functionScopeDeclared&lt;/em&gt; will get a string value assigned, &lt;em&gt;innerFunction&lt;/em&gt; function will be declared and defined and then assigned to a &lt;em&gt;letsSaveGoodForLater&lt;/em&gt; variable, declared in the global scope. So - no magic at all. What is interesting however - is the answer to question - what will happen when &lt;em&gt;letsSaveGoodForLater();&lt;/em&gt; is executed?&lt;/p&gt;

&lt;p&gt;Without knowing the answer my answer would be the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;since &lt;em&gt;innerFunction&lt;/em&gt; have been assigned to a global variable, it will be visible, so invoking &lt;em&gt;letsSaveGoodForLater();&lt;/em&gt; will execute (rather then throwing exception or giving an error message)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;console.log(globalValue);&lt;/em&gt; will log &lt;em&gt;&amp;#8216;global value&amp;#8217;&lt;/em&gt; to the console as this was a global variable&lt;/li&gt;
&lt;li&gt;&lt;em&gt;console.log(functionScopeDeclared);&lt;/em&gt; I would be on the fence here, but gravitating towards &lt;em&gt;undefined&lt;/em&gt; being logged to the console. When I&amp;#8217;m calling &lt;em&gt;letsSaveGoodForLater();&lt;/em&gt; I only have a referrence to &lt;em&gt;innerFunction&lt;/em&gt; dangling somewhere in the air, but how the hell would JavaScript know about the assignment in the outer scope?&lt;/li&gt;
&lt;li&gt;&lt;em&gt;console.log(tooLateMate);&lt;/em&gt; This one would NOT work for sure. How could it?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I obviously know the answers at this point, in case you were thinking in similar manner as I did - I&amp;#8217;ve posted my gut feelings here, so you wouldn&amp;#8217;t feel like you&amp;#8217;re the only stupid person in the world, there&amp;#8217;s really plenty of us. Because as it turns out, the output of this program actually is:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Output of the more sophisticated closure example&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='text'&gt;&lt;span class='line'&gt;global value
&lt;/span&gt;&lt;span class='line'&gt;inner value (declared in function&amp;#39;s lexical scope)
&lt;/span&gt;&lt;span class='line'&gt;A little bit too late, mate!? But NO!
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Turns out, when function is invoked it runs in the context of the variables with values assigned at the point of the declaration of the function. &lt;em&gt;And this is the beauty of closures&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Next time we will focus on the JavaScript libraries and IDEs (the tooling) as well as the setup (developer machine) I&amp;#8217;ve been using when working on the code for this post.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/AEtPUk-Bpl8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/12/18/javascript-tutorial-part-2/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript Tutorial, part 1 - the basics]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/ze-aTY5mA3Y/" />
    <updated>2012-12-15T23:53:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/12/15/javascript-tutorial-part-1</id>
    <content type="html">&lt;p&gt;&lt;strong&gt; Note: I wanted to be brief, first and foremost - presenting &amp;#8216;must have&amp;#8217; knowledge to get you started. Should you dig deep enough - to almost every statement made - you could find a corner case or exception to the rule. We will be building more knowledge in the next parts of my JavaScript tutorial, slowly getting deeper into the language and its possibilities. Bare with me. &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript is awesome. And currently, for any web-related development it&amp;#8217;s also mandatory. There are some topics you don&amp;#8217;t know jack about and get away with it, JavaScript - is not one of those things. DOM manipulation, using libraries like jQuery, now even on the server side with nodejs - JavaScript is everywhere and as much as one can be sure of something - it&amp;#8217;s here to stay (for the foreseeable future anyways).&lt;/p&gt;

&lt;p&gt;Hence the idea for the whole series of posts about JavaScript. Language, good practices, importance of functions; running and debugging JavaScript applications, the tooling around the language, etc&amp;#8230; Without further due - let&amp;#8217;s kick off!&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;I won&amp;#8217;t be getting into explanations on whether it is a strongly or a weakly typed language or whether it&amp;#8217;s statically or dynamically typed, etc. Due to the fact definitions in technical literature vary and the fact discussions on this topic would be meaningless anyway - I just strongly recommend you reading Eric Lippert&amp;#8217;s piece on the topic - &lt;a href="http://blogs.msdn.com/b/ericlippert/archive/2012/10/15/is-c-a-strongly-typed-or-a-weakly-typed-language.aspx"&gt;Is C# a strongly typed or a weakly typed language?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Functions in JavaScript are the most important concept one needs to get a a really good understanding of in order to produce efficient, working code and avoid frustration. Functions are so important, I am in fact going to dedicate an entire post focusing solely on functions. Let&amp;#8217;s quickly go through the basics which will be our baseline for the forthcoming posts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.JavaScript&amp;#8217;s running environment&lt;/strong&gt; - In the beginning I will be purely focused on JavaScript running in the context of the browser. It is also possible to run JavaScript server side (as with wildly popular &lt;a href="http://nodejs.org"&gt;nodejs&lt;/a&gt;), but we will save those topics for later. For now let&amp;#8217;s assume we&amp;#8217;re in the browser context.
In order for your JavaScript code to be executed we will put it either in the head or body of your HTML, and in &lt;script&gt;&lt;/script&gt; HTML tag, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;JavaScript embedded in the HTML&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;//your code goes here...&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;/script&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;or it will be in the separate JavaScript file, with extension .js, then referenced in the &lt;head&gt; tag of your HTML, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Referenced .js file in HTML:&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;text/javascript&amp;#39;&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;http://hostname//javascript_file_name.js&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;/script&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;&lt;strong&gt;2.Declaring and defining variables&lt;/strong&gt; - you can split declaration and definition as so it spans across more than one line, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Declaration and definition separately&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;my_number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;my_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;If you don&amp;#8217;t explicitly use &amp;#8216;var&amp;#8217; (a keyword denoting variable) - declared instance will be defined in global scope (on &amp;#8216;window&amp;#8217; object), accessible to all the JavaScript code running on this web page. This is really bad, as when you are using JavaScripts coming from many different sources (libraries, developers, etc&amp;#8230;) you&amp;#8217;re making name collisions that much more possible - and those might be extremely hard to pin-point when your code misbehaves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Data types&lt;/strong&gt; - there are 6 basic types of data in JavaScript. We have&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Number&lt;/em&gt; - there is no difference to JavaScript between double, float, int, etc&amp;#8230; as there is in other languages. In JavaScript number is simply a number. All numbers in JavaScript are represented as 64-bit floating point values&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Text&lt;/em&gt; - string in JavaScript is represented by an immutable, ordered sequence of 16-bit values, typically each of those values represents a single &lt;a href="http://www.joelonsoftware.com/articles/Unicode.html"&gt;Unicode&lt;/a&gt; character. You can use either single or double quotes to denote your string in JavaScript. There are many operations you can perform on strings (concatenation, slicing, finding index of a given letter, etc&amp;#8230;), if you&amp;#8217;re curious at this point take a look at &lt;a href="http://www.quirksmode.org/js/strings.html"&gt;strings in JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Boolean&lt;/em&gt; - there are only two possible values for a variable of this type - &amp;#8216;true&amp;#8217; or &amp;#8216;false&amp;#8217;. The real fun begins where JavaScript due to its coalescing nature converts variables passed for evaluation according to many different rules (we&amp;#8217;ll discuss in future posts), you might be surprised by the result. So, for example:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;This evaluates to true!&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;false&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;&lt;em&gt;null and undefined&lt;/em&gt; - even though &lt;pre&gt;typeof null is Object, 'null' is very often regarded as a special type, indicated given object or string does not exist. 'undefined' on the other hand, indicates the variable that has not been initialized with a value.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;object&lt;/em&gt; - objects may have defined properties or functions (function declared on the object is called a method), so for example, one of the methods of defining an object is:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;This is how you can create an object (... meaning "and so on")&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;object_of_my_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;volkswagen&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;mileage&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;red&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Each of those properties (name, mileage, age, color) can then be accessed either via its name using . notation, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;This is how you can create an object (&amp;#8230; meaning &amp;#8220;and so on&amp;#8221;)&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;object_of_my_type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;or via so-called indexing index:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;This is how you can create an object (&amp;#8230; meaning &amp;#8220;and so on&amp;#8221;)&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;object_of_my_type&lt;/span&gt;&lt;span class="p"&gt;.[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;    
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;It is also possible for properties to contain &amp;#8216;space&amp;#8217; character, but then they need to be accessed by using quotes notation (and in general this is not recommended), like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Accessing properties containing space&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;object_of_my_type&lt;/span&gt;&lt;span class="p"&gt;.[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;property with a space&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Properties like this can also be nested (you could e.g. have &amp;#8216;address&amp;#8217; property, which in turn would have &amp;#8216;street&amp;#8217;, &amp;#8216;number&amp;#8217;, &amp;#8216;ZIP code&amp;#8217;, etc&amp;#8230; properties)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;functions&lt;/em&gt; - by far the most important and characteristic part of JavaScript language specification. Whole next post will be dedicated to functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/ze-aTY5mA3Y" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/12/15/javascript-tutorial-part-1/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Adventures with node.js, Geddy and node.js hosting on Windows Azure]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/qwlxyHxjiy4/" />
    <updated>2012-08-21T10:27:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/08/21/hosting-geddy-powered-node-dot-js-application-with-windows-azure</id>
    <content type="html">&lt;p&gt;Note: For short summary of the things covered in this post fast forward to the bottom of it.&lt;/p&gt;

&lt;p&gt;Despite focusing mainly on C# (and occasionally some Ruby) I&amp;#8217;ve kept coming back to &lt;a href="http://nodejs.org/"&gt;node.js&lt;/a&gt; over and over again. There just is something about node.js that keeps dragging me in. It&amp;#8217;s relatively easy to start working with node by exploring the http and tcp server functionality, especially that those two are code samples on the node&amp;#8217;s home page. Usually the next step is to check out how easy it is to implement a live chat in node.js (it is really easy). One of the most impressive examples of node.js in action would be &lt;a href="http://wordsquared.com/"&gt;Wordsquared&lt;/a&gt; - a Scrabble alike game which as legend has it - was originally developed during a one weekend long hackaton. In this post I didn&amp;#8217;t want to push much in terms of namespaces used in the project nor have a working application, just a few things to check out - whether there are some web frameworks available for node, what about HTML template systems, how to create a form, how to loop in the syntax template is using, etc&amp;#8230; And then see how easy it is to get it deployed to Windows Azure.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Node.js solution I&amp;#8217;ve developed using Sublime Text 2 has been created on OS X 10.8, with v0.8.4 of node (so not the latest release although pretty close) so it might turn out it doesn&amp;#8217;t go as smooth as expected but hey - that&amp;#8217;s the exciting part. One more thing before I begin - this post is inspired by another one I started first but hasn&amp;#8217;t been published yet - it will be a comparison between node.js and ASP.NET MVC 4 in terms of comparing how easy it is to implement simple scenarios/usages of a web framework and then how easy it is to host it in the cloud and then finally to compare the performance. But to have something to test I actually needed some really simple sites implemented in both technologies and returning preferably the same HTML and in similar fashion. Then node.js part got a little bigger than planned for so I decided - it&amp;#8217;s a good candidate for separate post. The one with comparison will follow shortly after the one you&amp;#8217;re reading.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s get to it! First you need to install &lt;a href="http://nodejs.org/"&gt;node.js&lt;/a&gt; if you haven&amp;#8217;t already. Try using it for a while, read a few tutorials, browse materials available on the node&amp;#8217;s homepage. Knowing JavaScript helps a lot, but even not being master of disaster in terms of JS skills you still should be able to write some (definitely not good) code with node.js, I think in many cases just enough to get you excited. May sound funny but to me, nevertheless, node.js is the most fun technology I&amp;#8217;ve used in a long time. Then I wanted to have something to quickly get me up and running, something providing clean way to structure my (even though simple) project/solution, preferably some MVC flavored framework. And a bootstrap for HTML/CSS wouldn&amp;#8217;t hurt also, as even for simple experiments I like having something not 100% raw/spartan. With some googling I&amp;#8217;ve quickly ran into &lt;a href="http://geddyjs.org/"&gt;Geddy.js&lt;/a&gt; giving me all of that. You can find a pretty good tutorial on how to install and begin with Geddy &lt;a href="http://geddyjs.org/tutorial.html/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So after creating an application with simple&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Creating Geddy application&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;geddy&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="n"&gt;my_application_name&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;I was ready to modify the views a little bit so they would contain all of the elements I&amp;#8217;ve mentioned in the beginning of this post (btw - if you&amp;#8217;re having problems installing node or Geddy - just let me know in the comments - I&amp;#8217;ll help you out). You can find ready solution I&amp;#8217;m about deploying and running from &lt;a href="https://www.windowsazure.com/en-us/"&gt;Windows Azure&lt;/a&gt; in this GitHub repository: &lt;a href="https://github.com/geekbeing/cloudy-geddy/"&gt;cloudy-geddy&lt;/a&gt; - you can take a look at the changes I&amp;#8217;ve done to the standard Geddy application that&amp;#8217;s automatically generated for you by looking at these two files:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;I&amp;#8217;ve modified these two guys:&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;layouts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ejs&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ejs&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt; Now on to the setting this all up for Azure! I&amp;#8217;ve checked the node.js section of the Azure Developers portal &lt;a href="https://www.windowsazure.com/en-us/develop/nodejs/"&gt;Node.js Azure Dev Portal&lt;/a&gt; and it turns out it should be simple as 1-2-3 which in this case means running this commands:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;This is all that is required to host node.js on Windows Azure&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;azure&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;My node.js application&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;push&lt;/span&gt; &lt;span class="nx"&gt;azure&lt;/span&gt; &lt;span class="nx"&gt;master&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;And everything was going great except that&amp;#8230; this didn&amp;#8217;t work. Instead of getting the page I was receiving locally upon visiting url &lt;a href="http://cloudy-geddy.azurewebsites.net/"&gt;http://cloudy-geddy.azurewebsites.net/&lt;/a&gt; I was welcomed with &amp;#8220;You do not have permission to view this directory or page.&amp;#8221; message. I&amp;#8217;ve spent an hour and a bit trying to find a reason online and fixed, but wasn&amp;#8217;t able to. I suspected I might have something to do with Geddy app not having &amp;#8216;server.js&amp;#8217; file by default but I saw no easy fix to get around that. So then I thought I&amp;#8217;d try the simplest application, http server sample, without any modifications, using http module only and deploy that. This one also didn&amp;#8217;t succeeded, this time with cryptic error message from iisnode (more or that option of hosting node.js app on Windows later). You can take a look at this one also: &lt;a href="http://dirty-cloudy-geddy.azurewebsites.net/"&gt;http://dirty-cloudy-geddy.azurewebsites.net/&lt;/a&gt;. Normally I would enable debugging/logging and get to the bottom of what&amp;#8217;s going on in order to fix the issue. But not this time. Since the post was supposed to show how easy/hard it is to get it up and running I want to follow the happy path only. And so I decided to go with a different option this time - create new node.js application, and just simply for each response build the HTML in pure node.js, without any frameworks, hoping this can be easily deployed to Azure.&lt;/p&gt;

&lt;p&gt;With that in mind I&amp;#8217;ve quickly changed the implementation. I simply did &amp;#8216;view source&amp;#8217; on the Giddy based page running locally, then pasted this into the code of node.js server and then recorded macro in Sublime Text 2 which basically consisted of few simple operations - go to the beginning of the line, write&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;beginning of the line&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;go to the end of the line and close the double quote and the bracket&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;closing the line&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="err"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;so I was able to very quickly have this up and running. Another part was to return proper response for the JavaScript and CSS files used in the example (from the bootstrapper) so I&amp;#8217;ve added some code to handle this situation. Also added code to support serving .txt file, as this I will need for load testing the application with blitz.io (it requires either a route or a .txt file with unique name to return &amp;#8216;42&amp;#8217; as a response - this is to prove you own the domain you&amp;#8217;re trying to load test with blitz.io) - you can take a look at complete code at &lt;a href="https://github.com/geekbeing/node-azure"&gt;node-azure&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So now I had a pure node.js web server and way of building HTML. So in the end, at this point, I went with the option of not using Geddy at all. And I decided I&amp;#8217;m fed up struggling with Web Sites on Azure, so I&amp;#8217;ll just create a Virtual Machine, install node.js there and be done with it. (Of course at this point I could have just used original code, using Geddy - but since I know this scenario would work and I already have the code for the solution not using Geddy I decided this is a way to go). And so I did. One needs to sign-up for having access to Virtual Machines on Azure as it is pre-release software. After you&amp;#8217;re done with it you can order yourself a VM, the easiest way if you&amp;#8217;re not having fun clicking around (I&amp;#8217;m amazed if you don&amp;#8217;t also because you&amp;#8217;ve gotten so far reading my post) - just follow the instructions in &lt;a href="https://www.windowsazure.com/en-us/manage/windows/tutorials/virtual-machine-from-gallery/"&gt;this&lt;/a&gt; step-by-step tutorial. It nicely describes how to create a VM using platform (Windows, Unix, etc&amp;#8230;) images from Image Gallery.&lt;/p&gt;

&lt;p&gt;With VM alive and kicking I connected to it with Remote Desktop - on my Mac (it&amp;#8217;s where I do most of my coding/experimenting) I&amp;#8217;m using &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=18140"&gt;Microsoft Remote Desktop Connection Client for Mac 2.1.1&lt;/a&gt;. System requirements read &amp;#8216;is not intended for use with Mac OS X v10.7&amp;#8217; but it worked for me just fine (on OS X 10.8 - Mountain Lion it also works fine at least in my experience), so never mind the warnings (until things blow up in your face - just don&amp;#8217;t blame me). I downloaded node.js installer, installed it, told node application to listen on port 80, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Goddamn line that lost me at least an hour of my time&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;127.0.0.1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Dear God! What was I smoking? It of course worked locally but how could I expect this to work when accessing the page by virtual machine&amp;#8217;s DNS name? With ip address removed and node.js app listening on port 80 for all of the incoming requests I finally got it up and running.&lt;/p&gt;

&lt;p&gt;To summarize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I wasn&amp;#8217;t able to run node.js site with Geddy on Azure&amp;#8217;s Web Sites&lt;/li&gt;
&lt;li&gt;I managed to deploy and run node.js page on Azure&amp;#8217;s VM &lt;a href="http://geeknodejs.cloudapp.net/"&gt;http://geeknodejs.cloudapp.net/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;I haven&amp;#8217;t used templating language nor any other syntax than HTML/Javascript/CSS (will do in future post)&lt;/li&gt;
&lt;li&gt;I found out Azure&amp;#8217;s Web Sites use &lt;a href="https://github.com/tjanczuk/iisnode"&gt;iisnode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;I successfully created and configured Virtual Machine running on Azure&lt;/li&gt;
&lt;li&gt;I installed latest node.js on the machine&lt;/li&gt;
&lt;li&gt;I explained simple scenario of using macros in Sublime Text 2&lt;/li&gt;
&lt;li&gt;I configured endpoints on the Virtual Machine to be able to access it via RDC&lt;/li&gt;
&lt;li&gt;I created node.js application so it would run in without dependencies and return HTML&lt;/li&gt;
&lt;li&gt;I configured and load tested application with blitz.io (results will be shared in future post I&amp;#8217;m working on)&lt;/li&gt;
&lt;/ul&gt;

&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/qwlxyHxjiy4" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/08/21/hosting-geddy-powered-node-dot-js-application-with-windows-azure/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Implement 'Apply with LinkedIn' in your HR application]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/7HjDKuoswu4/" />
    <updated>2012-08-14T08:12:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/08/14/implement-apply-with-linkedin-in-your-hr-application</id>
    <content type="html">&lt;p&gt;There are over 100 million professionals who registered for the account on &lt;a href="http://www.linkedin.com/"&gt;LinkedIn&lt;/a&gt;. From time to time one can hear voices this service is sending out a lot of spam e-mails and people with fake accounts or claiming there&amp;#8217;s not much value in services LinkedIn provides. I call &amp;#8216;bullshit&amp;#8217; as I know plenty of folks who take care of updating their profiles so these would be up to date and also a few people looking for employees who use LinkedIn often. Since there&amp;#8217;s a really small chance these are the only ones with serious approach to what LinkedIn is offering - I think the service is great for it&amp;#8217;s purpose. Which is to briefly find out what potential employees (or old friends) have been up to professionally. The people potential candidate knows also tell a lot about any given person. And so do recommendations (especially if from industry-wide known individuals). Also - it&amp;#8217;s easier to recognize the talent when we hired someone who happens to have a LinkedIn profile and has friends with profiles matching well the positions we&amp;#8217;re looking forward to hiring for.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;One thing I&amp;#8217;ve discovered recently about LinkedIn is the other services they provide - so-called &lt;a href="https://developer.linkedin.com/plugins/"&gt;plugins&lt;/a&gt;. I was particularly interested in &amp;#8220;Apply with LinkedIn&amp;#8221; and so I decided to implement it on my sample site - one would be acting as an web page with a job offer - other web site - would be a target site (some HR system&amp;#8217;s endpoint) - where we could pass the data from the applicant’s profile on LinkedIn. There are a few things took me a while to figure out, so I wanted to describe the ride to potentially save you some time, as I think this particular plug-in will gain its momentum when people realize how easy it makes applying for the job (which also might not be as good as it seems at first - more on that later).&lt;/p&gt;

&lt;p&gt;First thing you need to do is to head over to go to &lt;a href="https://developer.linkedin.com/plugins/apply/"&gt;Build an Apply with LinkedIn button&lt;/a&gt; page, provide the details about the job offer, your company, provide logo, change theme color, etc&amp;#8230; After you&amp;#8217;re done setting things up you click &amp;#8216;Get Code&amp;#8217; button and you receive something similar to the following code:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;&amp;#8216;Apply with LinkedIn code snippet&amp;#8217;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;//platform.linkedin.com/in.js&amp;quot;&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;YOUR_API_KEY&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;/script&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IN/Apply&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;companyname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Geekbeing&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;jobtitle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;CEO&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;http://www.geekbeing.com/images/head.png&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;piotr.kwapin@gmail.com&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;/script&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;YOUR_API_KEY needs to be changed to the API key LinkedIn assigned to your account. &amp;#8216;data-jobtitle&amp;#8217; attribute&amp;#8217;s value is the position one will be applying for, &amp;#8216;data-logo&amp;#8217; value is an url for the picture that will be used as company&amp;#8217;s logo in the offer, setting &amp;#8216;data-phone=&amp;#8221;required&amp;#8221;&amp;#8217; adds a field user needs to fill in during applying, should this information not be available on the candidate&amp;#8217;s LinkedIn profile. Now, there are other details you may want display when offering the job, although these are not available via the builder interface, but rather need to be added by hand. You can also add custom field, let candidate include cover letter, or to answer some customized question required by HR processes in your company. You can find more detailed description here: &lt;a href="https://developer.linkedin.com/apply-functional-options/"&gt;Apply with LinkedIn functional options&lt;/a&gt;. Also - when using the builder (for the &amp;#8216;Apply with LinkedIn&amp;#8217; button) you can always click on the button in &amp;#8220;preview&amp;#8221; window on right hand side - it will bring the pop-up on screen and will make testing the functionality and what you&amp;#8217;ve prepared easier for you.&lt;/p&gt;

&lt;p&gt;This seemed fairly simple and I generated the code, signed up for the API key, pasted JavaScript from the builder in my HTML (beware, first gotcha, sometimes contains more brackets than needed), referenced needed in.js file and visited this local (currently developed) page on my machine to check out whether it worked. It did but only partially. It&amp;#8217;s easy when you want to just e-mail HR in your company that this and that person has applied for a such and such job offer in your company. I have no hard data to back it up, but I think more often than not it is really rare situation where plan e-mail send to the company is enough to apply and be considered. Usually companies require some kind of authentication verification (be it solely based on e-mail address), but usually they have their own HR machinery behind the scenes and there are at least a few things they would like potential candidates to provide as an information via some kind of a sign-up form.&lt;/p&gt;

&lt;p&gt;Fortunately LinkedIn provides such functionality, you can see a running example on AppHarbor - go to &lt;a href="http://linkedin-apply-with-asp-net.apphb.com/"&gt;Apply with LinkedIn in ASP.NET&lt;/a&gt; to check this out in action. Once you click &amp;#8220;Apply with LinkedIn&amp;#8221;, authenticate with your LinkedIn account and click &amp;#8220;Submit&amp;#8221;, you can then go to &lt;a href="http://linkedin-apply-with-asp-net.apphb.com/Resume.aspx"&gt;Resume page&lt;/a&gt; and see what kind of information has been posted to site (which in real life application would be an endpoint on your HR system). This can be achieved by adding:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;&amp;#8216;Apply with LinkedIn and post data to your HR system&amp;#8217;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;http://linkedin-apply-with-asp-net.apphb.com/Resume.aspx&amp;quot;&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;urlFormat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;json&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;attributes to your &amp;#8220;Apply with LinkedIn&amp;#8221; button code. If you&amp;#8217;re planning to implement the functionality yourself - just have in mind this won&amp;#8217;t work if the data-url is not a public hostname (which means DNS servers need to know what&amp;#8217;s the address of your host in order for LinkedIn to be able to POST this information to your target HR site). There are multiple ways to achieve it - as you can see I&amp;#8217;m hosting this sample application on AppHarbor - besides being really easy to configure, supporting ASP .NET technologies and being free (if you&amp;#8217;re using just some), providing git-push based deployments it also offers publicly available address in the apphb.com domain. The other option would be to use e.g Heroku as a hosting environment - they support node.js, Rails, Python and some other technologies - then you&amp;#8217;re hosted in heroku.com domain. Microsoft Azure gives you the same for node.js, Java, PHP, .NET of course - you can sign-up for free 90 days tier, that allows you hosting up to 10 sites, which also will receive publicly visible addresses.&lt;/p&gt;

&lt;p&gt;Should you run into problems using this functionality on your own web site &lt;a href="https://developer.linkedin.com/forum/apply-linkedin-having-issues-check-here-first/"&gt;Apply with LinkedIn: having issues? check here first&lt;/a&gt; is a great place to begin troubleshooting your application. It gives you a step-by-step checklist of things you should check, things that might have gone wrong and prevent LinkedIn functionality from working inside your app. Of course - should you feel lost and need assistance - feel free leaving the comment to this post and I&amp;#8217;ll be happy to help you out. Last but not least - the code is available at my &lt;a href="https://github.com/geekbeing/linkedin-apply-with-asp-net/"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/7HjDKuoswu4" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/08/14/implement-apply-with-linkedin-in-your-hr-application/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Beginning Windows Azure - Azure's new offering]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/vuiGlxcYy5w/" />
    <updated>2012-08-09T09:29:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/08/09/azures-new-offering</id>
    <content type="html">&lt;p&gt;I must admit I wasn&amp;#8217;t a great Azure fan the very day it got released. I thought it&amp;#8217;s another attempt on Microsoft&amp;#8217;s pair to play &amp;#8216;catch up&amp;#8217; game only this time, the game really is for big boys. Not that Microsoft has lacked money or talent, it&amp;#8217;s just that to me coming up with an truly amazing experience in cloud offering (be it PaaS, IaaS, SaaS maybe just a little less) company needs to have in its blood and it can&amp;#8217;t just be a fruit of &amp;#8220;me too&amp;#8221; approach. And so I wasn&amp;#8217;t convinced, especially that in the beginning it was mostly (or even only, not sure if I remember correctly) PaaS - and what is worse it required platform dependent code to be run in the cloud. Just a year back I&amp;#8217;ve tried using IaaS, with Azure&amp;#8217;s VM offering (beta at that time) and I must admit it was plain awful. I know I can&amp;#8217;t exactly expect a smooth sailing using beta products (although in many cases it turns out to me it&amp;#8217;s &amp;#8216;beta&amp;#8217; only because the label says so or if I just dig around and use features that most likely will be used by circa 5% of the customers of a given product) but really, I was utterly disappointed with VM offering. First they made me go through a long process of crafting the VHD image so I could later on upload it to Azure, via command line utilities (don&amp;#8217;t get me wrong, I&amp;#8217;m a fan of CLI) only, with obscure error messages, process failing multiple times, just plain crap.&lt;/p&gt;

&lt;p&gt;Now, with latest release (7th of June 2012) - I can only say&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Impressive - Azure is awesome&lt;/code&gt;&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt; and admit - I can&amp;#8217;t believe how far Microsoft went after such a short time. Even if you have a lot of faith in Scott Gu and he is the wizard he seems to be, it still needs to awe the shit out of you when one thinks deeply about the amazing amount of work and innovation Microsoft pulled of with this one. I have a quite few series started on this blog - RavenDB, redesigning my blog, ASP .NET MVC4 + pusher.com live chat application yet still - starting with this post I&amp;#8217;d like to begin new series - developing with Windows Azure. There are plenty resources online for Azure, many of them outdated, so I wanted to share with you the interesting links and books I&amp;#8217;ll be using during my adventures with Azure.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First sign up for Azure services. You need to provide a credit card (basically to verify identity if not for payments) but also you can set a spending limit to 0 (zero) money in currency you&amp;#8217;re using. Even if you start using Azure like crazy - you don&amp;#8217;t need to be afraid - you won&amp;#8217;t be charged for a dime. Go to &lt;a href="http://www.windowsazure.com/en-us/"&gt;Windows Azure&lt;/a&gt; portal and follow &amp;#8216;Free trial link&amp;#8217;, you will be able to either sign-up for 90-days testing period or should you have a MSDN Subscription, BizSpark, WebSpark or you are a MPN member - you can sign up for more generous free tiers by visiting &lt;a href="http://www.windowsazure.com/en-us/pricing/member-offers/"&gt;member offers page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The most up to date development resources can be found at &lt;a href="http://www.windowsazure.com/en-us/develop/overview/"&gt;Windows Azure Developer Center&lt;/a&gt;. I love the application of &amp;#8216;Metro&amp;#8217; (now Microsoft is withdrawing from using this name due to legal issues and the fact MS didn&amp;#8217;t secure rights to use the term - doh! - I don&amp;#8217;t care, to me it&amp;#8217;s always been and always will be &amp;#8216;Metro&amp;#8217;) visual style here, it&amp;#8217;s clean, simple, intuitive, with no clutter Microsoft used to be famous for, especially with their products packaging. Just take a look, isn&amp;#8217;t it beautiful?
&lt;img class="center" src="https://img.skitch.com/20120809-pxungq8rc8ru7t9xmwwerettf1.jpg" title="New Azure Dev Portal" alt="Azure FTW!"&gt;&lt;/li&gt;
&lt;li&gt;Should you prefer video material over text - take a look at &lt;a href="http://www.meetwindowsazure.com/Conversations#ScottGuthrieMeet"&gt;Conversations section of Azure&lt;/a&gt; where you can find plenty of videos introducing you to development with Azure. I especially recommend watching Scott Gu&amp;#8217;s keynote from this page - it really nicely sums up new features and shows Scott actually interacting with Azure during the presentation, so you can see for yourself how everything is easy and straightforward to setup.&lt;/li&gt;
&lt;li&gt;I haven&amp;#8217;t read this book yet, but this is by far the most up to date offering about Azure in the market - so if you have a few bucks to spare and you&amp;#8217;ve already consumed everything Azure Dev portal had to offer - might be worth your consideration - &lt;a href="http://www.amazon.com/Programming-Microsofts-Clouds-Windows-ebook/dp/B0081RL4T0/ref=sr_1_2?ie=UTF8&amp;amp;qid=1344502044&amp;amp;sr=8-2&amp;amp;keywords=azure+365"&gt;Programming Microsoft Clouds&lt;/a&gt;. I&amp;#8217;ll update this post with short review as soon as I&amp;#8217;m done reading it.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt; Ok, that&amp;#8217;s it for now, stay tuned as in future posts we dive deeper in Azure.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/vuiGlxcYy5w" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/08/09/azures-new-offering/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Redesigning my blog, part 2 - working with professional designer]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/YzHAuiaYVxs/" />
    <updated>2012-06-27T01:18:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/06/27/redesigning-my-blog-part-2</id>
    <content type="html">&lt;p&gt;First time we met - me and &lt;a href="http://www.gabimalacha.com/"&gt;Gabi Małacha&lt;/a&gt; we weren&amp;#8217;t sure if we would work together. Gabi is extremely busy (first of all really talented and second - busy), so when we got together she had her hands full. I, on the other hand, am very picky in terms of selecting people to work with, not to mention me being infinitely and utterly picky when it comes to design (in this context - web, but any other kind would apply). Very quickly though, during our first meeting I realized she&amp;#8217;s really cool, knowledgeable, energetic person, so it was basically up to her, whether the task seemed interesting to her and if she could find a gap in a busy schedule to work on the new design for my blog. Looking at her portfolio, then discussing her motivation for why she would even consider engaging in work I instantly realized she was a perfect match to get this work done. Somehow she didn&amp;#8217;t think I was lame and so the adventure began.&lt;/p&gt;

&lt;p&gt;In order to establish common ground for further work I knew I needed to show Gabi the direction I wanted this heading towards to - I&amp;#8217;ve sent a few links leading to my favorite designs, namely: &lt;a href="http://www.sushimonstr.com/"&gt;Sushimonstr&lt;/a&gt;, &lt;a href="http://inmotionmassage.co.uk/"&gt;In Motion London Mobile Massage&lt;/a&gt;, &lt;a href="http://carsonified.com/"&gt;Carsonified&lt;/a&gt;, &lt;a href="http://www.amazeelabs.com/"&gt;Amazee Labs&lt;/a&gt;, &lt;a href="http://www.giftrocket.com/"&gt;GiftRocket&lt;/a&gt; and many more. Some of these creations are blogs others - just cool looking web sites. This was more for the purpose to let Gabi know what I like and then likely what could possibly work for my blog. I really wanted this design to stand out from the crowd. Besides our first meeting there were tens of e-mails sent both ways, plenty of time spent separately, thinking about what we&amp;#8217;ve discussed what I wanted (my part) and how to deliver the result (Gabi).&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Not many days ago we&amp;#8217;ve met for the first time and had a pretty interesting conversation about what we&amp;#8217;ve agreed upon so far, what are the next steps, on history of the design and tendency (both of us) to surround ourselves with beautiful creations. Thanks to this meeting I&amp;#8217;ve started reading (and I am almost done) &lt;a href="http://www.amazon.com/Design-Everyday-Things-Donald-Norman/dp/0465067107/ref=sr_1_1?ie=UTF8&amp;amp;qid=1340747102&amp;amp;sr=8-1&amp;amp;keywords=the+design+of+everyday+things/"&gt;The Design of Everyday Things&lt;/a&gt; by Donald A. Norman, watched &lt;a href="http://www.youtube.com/watch?v=S9E2D2PaIcI/"&gt;Objectified&lt;/a&gt; and in general started giving more thought to why things (objects we use in everyday life) were designed in this way and not the other. Why does one fell instant, intimate relation with some of the objects, while other take years of getting used to and yet after all of these years of usage still don&amp;#8217;t feel right. So genuinely - doing stuff may have interesting implications we might not be aware of when first dipping our toes in this river. I guess it&amp;#8217;s a general lesson in life - do more. Go out. Create. Play with stuff. Break stuff. Fix stuff. Read, think, then apply. Think some more. Then re-apply. Truly inspiring I must tell you and it was worth doing it solely for the purpose of this realization.&lt;/p&gt;

&lt;p&gt;First visual thing I saw were the mood boards. This was the first time when I would realize something like this even existed but instantly it snapped and I realized how much of a value these little patchworks provide. Once it&amp;#8217;s settled (between you and designer) I don&amp;#8217;t see how things could go wrong from there. Well, of course anything&amp;#8217;s possible but chances are you&amp;#8217;re at least not beating around the bush. So here are the three I&amp;#8217;ve received:&lt;/p&gt;

&lt;div id="moodboards"&gt;
&lt;span class="imageCaption"&gt;Old school is back!&lt;/span&gt;

&lt;img class="center" src="http://img.skitch.com/20120626-pqr1f4hiyhs7hju5w7n11hchnw.jpg" title="Mood board 1 - Old school" alt="Old school is back!"&gt;

&lt;span class="imageCaption"&gt;Folk!!&lt;/span&gt;

&lt;img class="center" src="http://img.skitch.com/20120626-msy24icb78njskh1qt67kk8e2.jpg" title="Mood board 2 - Folk" alt="Folk is aaaigh"&gt;

&lt;span class="imageCaption"&gt;Typography&lt;/span&gt;

&lt;img class="center" src="http://img.skitch.com/20120626-cwahabrm7syhd7w7pf2fi9xi78.jpg" title="Mood board 3 - Typography" alt="Type-O-Negative"&gt;
&lt;/div&gt;


&lt;p&gt;These three propositions left me unsettled for a few days of constant thinking about which way to go, carefully weighting in pros and cons and really hoping I would pick the right one as to be honest - since the beginning I liked all three&amp;#8230; As with many matters in life - whether important or less - it turned out to better cut the thinking and feel instead. Although all were visually pleasing one of them felt right in the context of myself - old school. I was born and raised in the very old building, tenement house near the Wawel Castle. Old, damaged staircase, really high ceilings, tiled stoves, slightly musty smell, melancholy of the surroundings - this all is me, at my very core. It&amp;#8217;s raw, dirty, primal at the same time (ok, maybe I&amp;#8217;m loosening my imagination too much here). I have a few ideas on how we might use the other mood boards for future work though (I&amp;#8217;ll post about it if/when it&amp;#8217;s time). Here is the first proposition from Gabi, which came shortly after we&amp;#8217;ve agreed upon the mood for the blog:&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="http://img.skitch.com/20120627-xsya2f4i841rmxx5g4g53h1ffp.jpg" title="Vintage - various" alt="Yeah, let us work with these"&gt;&lt;/p&gt;

&lt;p&gt;and also a few variations on something I&amp;#8217;ve dreamt of (having a picture of me, right profile, staring at the sun, having shiny rays behind my face, sort of like in the old communist propaganda posters) and although not entirely convinced Gabi started working on these, coming up with (this is one picked out of many, in general - story presented here is only a short version, so you could peek into the process - and btw - if you are really interested you can check out the pictures Gabi has worked with to better reflect my crappy face - &lt;a href="https://picasaweb.google.com/113346656937384715427/GeekbeingForBlog?authkey=Gv1sRgCO2d8-yvuZf6Ww#"&gt;Geekbeing&amp;#8217;s half-baked stupid goddamn faces - mine that is - my wife is cool&lt;/a&gt;):&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="http://img.skitch.com/20120627-m414i5kuxsp7tnmx82je9c3ejc.jpg" width="372" height="372" title="Communist One" alt="Communist One"&gt;&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s worth mentioning I also was in a desperate need for a new tagline. In the picture above you can see an early version (we were working on the tagline separately, all the time, during the aforementioned events). The one I had before read &amp;#8220;Geekbeing&amp;#8217;s Rants&amp;#8221;. It&amp;#8217;s been inspired by &lt;a href="http://steve-yegge.blogspot.com/"&gt;Steve Yegge&amp;#8217;s blog&lt;/a&gt; (btw - there&amp;#8217;s some intense, high-resolution, super-deep thought out content here - go, browse, read, then read some more, absolute fest). Then, however, I realized my rants more often take place on Twitter whilst on my blog I&amp;#8217;m really well-behaved. So &amp;#8216;rants&amp;#8217; definitely needed to go. Coming up with a catch-phrase was a separate activity stream, something we both didn&amp;#8217;t want to push too much, hoping good idea will come. And this time I had a creative vision which clicked right away. Paraphrasing &amp;#8220;Veni, Vidi, Vici&amp;#8221; and nicely summing up what I do, &amp;#8220;I hack, I break, I fix&amp;#8221; was born and just felt right straight away.&lt;/p&gt;

&lt;p&gt;Ok, stage is setup for the show. We got the mood, the slogan, we got the elements of the targeted old school design, a lot was done, a lot still ahead and so the e-mails kept flying back and forth.We were both mad at each other, constantly fighting and we both felt like we should quit at this point. No, just kidding really. It was awesome and almost a smooth sailing, skipping some part of the process which lead to this:&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="http://img.skitch.com/20120627-1wm37y86s32y21itd7y1tc57rw.medium.jpg" title="We are almost there" alt="This for sure looks familiar"&gt;&lt;/p&gt;

&lt;p&gt;As you most likely recognize, this is pretty close to what I currently have on my blog and actually the first one of many we thought of as somewhat &amp;#8216;complete&amp;#8217;. However - this is a very rough estimate. I think you&amp;#8217;ve seen almost enough (as for the single blog post), but just to shortly enumerate differences between this version and the one that is live: different background, different logo, different menu, different fonts everywhere, different footer. Getting those right also took its time, believe me.&lt;/p&gt;

&lt;p&gt;And then I&amp;#8217;ve sent Gabi this photo:&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="http://img.skitch.com/20120627-8qhsby28raysjcy194n53ppx42.jpg" width="372" height="372" title="What a geek!" alt="What a freak!"&gt;&lt;/p&gt;

&lt;p&gt;More than two weeks later Gabi replied to my e-mail dropping the bomb:&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="http://img.skitch.com/20120627-fqj8k7my6y81hn62h7i7pfxyr8.medium.jpg" title="Geekbeing!" alt="Wow he is really hot!"&gt;&lt;/p&gt;

&lt;p&gt;and the rest is history (plus again - more work on ironing out the details). Huge thanks to Gabi for making this happen and working with me. It was an honor and real pleasure. And the result is goddamn hot! In the upcoming post I&amp;#8217;ll tell you all the gory details about implementation, tools I&amp;#8217;ve used, what worked and what not and why there is still shitload of work ahead of me. See you soon!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/YzHAuiaYVxs" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/06/27/redesigning-my-blog-part-2/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Redesigning my blog, part 1 - each journey starts with a thousands of teeny-tiny steps]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/2O8cxSlcIM8/" />
    <updated>2012-06-17T22:25:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/06/17/redesigning-my-blog-part-1</id>
    <content type="html">&lt;p&gt;It&amp;#8217;s been a really long ride and it&amp;#8217;s still far from being over. I&amp;#8217;ve started thinking about redesigning the blog when I was still blogging really infrequently, once per 3 months or even less often. At the time it seemed to me like redesign might be a fresh start, a more lively kick-off so I&amp;#8217;d really get into blogging. As I&amp;#8217;ve mentioned before - I enjoy writing a lot, it&amp;#8217;s just quality/quantity of ideas I&amp;#8217;m having (or at least my perception of these) seems to still be keeping me from habitual posting. You see, dear reader, to me when something is super simple or I know already has been written - it&amp;#8217;s not worth my time (and yours when latter is the case). On the other hand if matter is fairly complex then either I&amp;#8217;d have to work on a single post long enough that the topic might already be outdated by the time I&amp;#8217;m done, or I could split it into a series of posts. But there are a few downsides to such approach - first of all, series of long posts are definitely more scary for the reader than one monster-post. And second - by the time post number &amp;#8216;n&amp;#8217; is finished I most likely have run into hundreds of new, interesting things to blog about. And committed as I am to the subject - I might not let it go, to the point it gets boring.&lt;/p&gt;

&lt;p&gt;So now, to prove me and what I&amp;#8217;ve just written wrong - I&amp;#8217;m starting a new series, on work still in progress, about why I&amp;#8217;ve decided to redesign my blog, what I&amp;#8217;ve learned during the process - and this is both - technically and as a human being.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Idea of redesign has been bubbling in my head for at least last two years. You might not know this about me, but I really love beautiful things/items/productions - call these as you may. This is not to say I have a good taste when it comes to creating things, but most definitely I can spot gorgeous design when I see it (and according to my market research, 96,7% of leading designers of the world agree). So each time I&amp;#8217;d ran into an amazingly designed and implemented web page, a real state of art, it would obsessively make me think about the person behind this creation, imaging how cool the author must be that he was able to pull this off and end up with such design, how many days/weeks/months of work went into what now lies in front of my eyes and so on. This may go for weeks (of course not constantly, but these thoughts pop in a few times a day). These feelings would also bring up jealousy. The good kind - sort of - I wish I had done/experienced something like this. And so I did, I believe and I&amp;#8217;d love to share the journey with you, dear reader.&lt;/p&gt;

&lt;p&gt;More or less year ago (when I have finally made up my mind and wanted to finally do it, no excuses) I started looking for a talented person who would design my blog from scratch. I wasn&amp;#8217;t sure at the beginning what should that be other than that it had to look stunning. And be distinct, different from anything else out there (totally opposite end of the spectrum of standard WordPress theme and then some. I wanted my design to run circles around those mass templates). You might or might not know such things cost. And it can really be a shitload of money. SHIT-LOAD, believe me. I usually approach tasks at hand with &amp;#8216;can-do&amp;#8217; attitude. When I believe the subject of the action makes sense that is (have no money and eat breakfast in Paris tomorrow - sure, why not; heal the world - just three of us - of course, will do, why not? Write a letter to the Queen of England hoping she writes back - I&amp;#8217;m on it. No opposite examples this time, sorry). And so I&amp;#8217;ve thought - ok, who&amp;#8217;s cool designer and has this hipster vibe about him and would be awesome as a dude who designs my blog? &lt;a href="http://www.zeldman.com/"&gt;Jeffrey Zeldman&lt;/a&gt; of course, who else might that be? Which actually means - his agency - &lt;a href="http://happycog.com/"&gt;Happy Cog&lt;/a&gt;. Unfortunately I wasn&amp;#8217;t a happy cog for too long, turns out I couldn&amp;#8217;t pass by the questionnaire form to fill in at the time - one can only apply for a quote/starting a discussion if one has 100,000$ to spend. Maybe not a huge let-down, I was prepared for almost that kind of money but since I&amp;#8217;m man of principles I decided I won&amp;#8217;t go circa 15% over my budget just to have Jeffrey. The second close on my list was &lt;a href="http://simplebits.com/"&gt;Dan Cederholm&lt;/a&gt;, I won&amp;#8217;t bore you with the details but that didn&amp;#8217;t go that well too.&lt;/p&gt;

&lt;p&gt;And there&amp;#8217;s the other end of the spectrum - lots of creative agencies, youngsters/hipsters, inspired designers, weed abusers, etc&amp;#8230; who in theory know their shit, but then when you look at their portfolios it&amp;#8217;s either secondary or just simply not good. And there are agencies that had done work for gazillions of companies, Fortune 500 what not, but this is obviously beyond my reach. And also - I tend to think they don&amp;#8217;t care that much either. When you really sit and dig deep to go through their work - they usually have some huge international star. Or one awesome project that allowed them to create hype around the company and get a few minutes of fame. And then suddenly good people want to work with you and then you create more and more projects and then after all it&amp;#8217;s all the same. I&amp;#8217;m talking web design ONLY! So don&amp;#8217;t take it the wrong way. And so a few months later and a few desperate (yet, from today&amp;#8217;s perspective really hilarious) attempts of creating the design myself (what a moron) I&amp;#8217;ve slowly started getting into a mind track - given a situation - this shit can&amp;#8217;t be done in current circumstances and I need to let it go for now, shelve it and maybe come back to this in most likely distant future.&lt;/p&gt;

&lt;p&gt;And then a few more things have happened, may universe help doubtful. (Or stupid. Or &amp;#8216;and stupid&amp;#8217;) - a few events have occurred I didn&amp;#8217;t notice at that time - have led to what I&amp;#8217;m enjoying currently (awesome design for my blog that is). So it was a few people (meeting with them, talking to them, being with them) - some of them really close and hanging around a few years, some whom I&amp;#8217;ve just met and some whom I know only remotely. In no particular order - &lt;a href="https://twitter.com/#!/nedzynski/"&gt;@nedzynski&lt;/a&gt; - volcano of ideas - always having a good word, proposing solutions, getting in touch with people - he has suggested a person, who later on worked with me on making my dream a reality. And he always believed most of the shit I do - actually makes sense - which helped me a lot in being persistent at what I do. Guys from &lt;a href="http://www.futuresimple.com/"&gt;Future Simple&lt;/a&gt; - young, fresh, smart, focused, very well prepared to take over the world (which I&amp;#8217;m sure they will), &lt;a href="https://twitter.com/#!/elamadej/"&gt;Ela Madej&lt;/a&gt; - woman, institution, IT wiz, Chief Enthusiasm Officer in &lt;a href="http://applicake.com/"&gt;applicake&lt;/a&gt; - her I don&amp;#8217;t know personally, but I&amp;#8217;ve heard a lot about her and also, I have been following her work and accidentally she has just recently met a very good friends of mine whom I have in the US (This is a really, really small World we live in). I could throw in a few additional names, but not to bore you - these are the folks who have such amazing amount of passion, so many great ideas they put into life, so many ventures they actively participate in, make happen, just real volcanos of creativity and positive attitude - they touch your life, sometimes being very close, other times - from far, far away.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve mentioned all of these people to show you the old truth&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;No man is an island,&lt;/p&gt;

&lt;p&gt;Entire of itself.&lt;/p&gt;

&lt;p&gt;Each is a piece of the continent,&lt;/p&gt;

&lt;p&gt;A part of the main.&lt;/p&gt;

&lt;p&gt;If a clod be washed away by the sea,&lt;/p&gt;

&lt;p&gt;Europe is the less.&lt;/p&gt;

&lt;p&gt;As well as if a promontory were.&lt;/p&gt;

&lt;p&gt;As well as if a manor of thine own&lt;/p&gt;

&lt;p&gt;Or of thine friend&amp;#8217;s were.&lt;/p&gt;

&lt;p&gt;Each man&amp;#8217;s death diminishes me,&lt;/p&gt;

&lt;p&gt;For I am involved in mankind.&lt;/p&gt;

&lt;p&gt;Therefore, send not to know&lt;/p&gt;

&lt;p&gt;For whom the bell tolls,&lt;/p&gt;

&lt;p&gt;It tolls for thee.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;To me - it means - we&amp;#8217;re all deeply influenced by the people surrounding us. We all stamp influence on each other, so we can write, post, create, be active and just get wiser as life goes on. We need and complement each other. It may sound a little too pompous as for the post about redesign of a blog, but I promise - it will all make sense when we get to the last post in this series. So all of this positive energy and support, from one thing to another - led to me meeting &lt;a href="http://www.gabimalacha.com/"&gt;Gabi Małacha&lt;/a&gt; and that&amp;#8217;s how the journey started&amp;#8230;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/2O8cxSlcIM8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/06/17/redesigning-my-blog-part-1/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Implement live web chat with ASP.NET MVC 4, Pusher and jQuery]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/zKL19bmThuI/" />
    <updated>2012-05-18T23:31:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/05/18/implement-live-web-chat-part-1</id>
    <content type="html">&lt;p&gt;Web is evolving. Fast. And so is the technology behind the scenes, driving the innovation we all witness. No doubt about it. It has all started with static HTML mixed up with inlined styles to be served as markup soup then CSS came along cleaning some of this mess up. Then Firefox came up to the stage, like a breeze of fresh air, then Chrome, slowly but stubbornly putting IE to its not well deserved rest, allowing standard compliant, rich in user interface enhancements web applications. Somewhere on the timeline between those events Gmail has been brought to life, showing people what can be achieved with JavaScript and AJAX. Google Maps. I still have shivers down my spine when I first saw it. Madness. I think it was a biggest break-through in contemporary history of web technologies. It made way for great followers (in the sense of technology) - Facebook, Twitter. As importance of the so-called &amp;#8216;social features&amp;#8217; increased recently (I understand this term in its broader sense - it&amp;#8217;s everything making human to human interactions on the web simpler - be it real-time updates on page, possibility to rate, share, work on the same content, whether it&amp;#8217;s document, picture or what not) - some technologies are clearly leading the pack. Live web application updates, instant messaging systems, responsive web-based applications. So today I&amp;#8217;ve decided to give &lt;a href="http://pusher.com/"&gt;Pusher&lt;/a&gt; a try and create a live web chat.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Pusher is a service allowing creation of the real-time web applications. It provides API, both client and server side to create so-called channels. By using channels you can send messages Pusher pushes (well duh) to all of the other subscribers of a given channel. I smell live chat. And so we&amp;#8217;ll implement it. We&amp;#8217;ll have &lt;a href="http://www.asp.net/mvc/mvc4/"&gt;ASP MVC 4&lt;/a&gt; application serving as a back end. It will also contain client side code, so whoever will open a page from the app in a browser will be able to send and receive messages with all of the other clients. It&amp;#8217;s a chat, I said it before, didn&amp;#8217;t I? Let&amp;#8217;s go step by step, I&amp;#8217;ll be explaining all of the important steps on the way, to finally give you a link to a &lt;a href="https://github.com/"&gt;Github&lt;/a&gt; repository so you could download the code and run it locally. Let&amp;#8217;s do some push-ups!&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s start by looking into what Pusher itself says about what it does and how it&amp;#8217;s done. Since picture is worth a thousand words, let&amp;#8217;s start with that:&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="https://img.skitch.com/20120513-r95j7t412wycbrfijuabf28pwr.jpg/" title="How Pusher works" alt="High level overview of how Pusher works"&gt;&lt;/p&gt;

&lt;p&gt;So basically Pusher allows for easy sending of the messages between server and clients, using WebSockets (according to Wikipedia definition of WebSocket is a technology providing for bi-directional, full-duplex communication channels, over a single TCP socket) for communication. There are some really easy to understand examples on Pusher&amp;#8217;s site, if you still don&amp;#8217;t think you&amp;#8217;re getting the concept - take a look at&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://pusher.com/docs/"&gt;Pusher docs&lt;/a&gt; and click &amp;#8220;Test it out&amp;#8221; button, it will provide you with curl command you need to run in order to see notification (a message pushed to your client) for yourself.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pusher.com/docs/javascript_quick_start/"&gt;JavaScript Quick Start Guide&lt;/a&gt; - which takes you step-by step through the scenario of implementing&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Let me now take you step by step by what I&amp;#8217;ve done:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create new ASP MVC 4 project in Visual Studio, pick &amp;#8216;Single Page Application&amp;#8217;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let&amp;#8217;s modify connection strings and setup the Web Project to use &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=17876"&gt;SQL CE 4.0&lt;/a&gt; as a data location for storing registered users for our Live Chat application - so as a next step I&amp;#8217;ve changed the default &amp;#8216;DefaultConnection&amp;#8217; to the one below&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Setting up connection string for users database&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;UsersConnection&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;connectionString&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="s"&gt;&amp;quot;Data Source=|DataDirectory|Geekbeing.Pusher.Chat.Web.mdf&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;providerName&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;System.Data.SqlServerCe.4.0&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;and updated 4 places where this connection string is used. Now run the application and verify whether you can create new users, logon, logout and other functionalities related to registration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Next, I&amp;#8217;ve updated all of the packages in the solution. This step is not required but then I can&amp;#8217;t guarantee everything will work as described in this post, so if you expect smooth sailing - just do the same. With NuGet it&amp;#8217;s really simple. If you feel it&amp;#8217;s a waste of time - at least update jQuery, since we will be using Pusher&amp;#8217;s JavaScript library, which is using the latest version of jQuery. In older versions of ASP .NET MVC updating e.g. jQuery, where version of the release is embedded in the JavaScript file name - you had to manually update script tag, to correct the file name, but with new MVC 4 feature - &lt;a href="http://weblogs.asp.net/scottgu/archive/2011/11/27/new-bundling-and-minification-support-asp-net-4-5-series.aspx/"&gt;Bundling and minification&lt;/a&gt; it&amp;#8217;s automagically taken care of. After updating - verify everything regarding registration still works.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we need to configure Pusher - both the service and its usage in our solution. Head to &lt;a href="http://pusher.com/"&gt;Pusher.com&lt;/a&gt; and create an account. Next go to your profile page and click &amp;#8216;Add new app&amp;#8217; button in order to create application in Pusher service. Name it anything you want (I&amp;#8217;ve called mine &amp;#8216;asp-mvc-4-chat&amp;#8217;). When application is created, you can go to &amp;#8216;API access&amp;#8217; tab in order to see the information about the app_id, key and a secret (these three values will be need to the server-side code, so your application would be authorized to use Pusher).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To make c# code easier on our application&amp;#8217;s side - I&amp;#8217;ve used excellent library - called &lt;a href="https://github.com/grahamscott/pusherrestdotnet/"&gt;pusherrestdotnet&lt;/a&gt;, created by &lt;a href="http://grahamscott.net/"&gt;Graham Scott&lt;/a&gt;. It&amp;#8217;s available on NuGet - so you can install it via Package Manager in Visual Studio. Once it&amp;#8217;s installed we will need aforementioned values for the keys to initialize the constructor for PusherProvider class which will allow us to trigger notifications to connected clients via Pusher. I&amp;#8217;ve added this three keys with values to web.config (in &lt;appSettings&gt; section - please, do not use my values, register for your own account and application. I will link to a full application code on GitHub and don&amp;#8217;t want to remove those values from the code before pushing, but really - please - use your own):&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Setting up Pusher in web.config&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;pusher_app_id&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;20408&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;pusher_key&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0b7eeff567653e170094&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;pusher_secret&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;57d967bc56b5b16d8e93&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;Initialization code for the PusherProvider can go anywhere in the app, very often it&amp;#8217;s seen such global objects are initialized in global.asax and initialization code is invoked from the Application_Start() method. Later on such object is made available for usage across the controllers in the application via public property on the main application class inheriting from HttpApplication. But in our case we&amp;#8217;ll do it in HomeController, making PusherProvider a private static member of the class - which in result will make sure we got only one instance, initialized on first request made to &amp;#8216;/&amp;#8217; of the application, in turn routed to HomeController&amp;#8217;s Index() method. Here&amp;#8217;s the code using previously setup keys/values in web.config&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Code for the initialization of PusherProvider&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomeController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;PusherProvider&lt;/span&gt; &lt;span class="n"&gt;Provider&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;PusherProvider&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;   &lt;span class="n"&gt;ConfigurationManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AppSettings&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;pusher_app_id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;   &lt;span class="n"&gt;ConfigurationManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AppSettings&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;pusher_key&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;   &lt;span class="n"&gt;ConfigurationManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AppSettings&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;pusher_secret&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;//Rest of the code in this class skipped&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;We need a channel name for, well - communication channel which will allow us to send messages via Pusher, to which both - client and a server subscribe. And also - event name - so we could bind an action from the user using the client (a web page in our case, but might be some desktop application, mobile application, or whatever app that can make use of Pusher&amp;#8217;s API). Here&amp;#8217;s server side code, method on the HomeController:&lt;/li&gt;
&lt;/ul&gt;


&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Setting up Pusher server-side&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="nf"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;chatMessage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UtcNow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ObjectPusherRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="s"&gt;&amp;quot;chat_channel&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="s"&gt;&amp;quot;message_received&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="k"&gt;new&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;            &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chatMessage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;            &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;            &lt;span class="n"&gt;timestamp&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToShortDateString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;&amp;quot; &amp;quot;&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToShortTimeString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;View&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;And here&amp;#8217;s JavaScript from the Index.cshtml (View for the Index() method of HomeController):&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Setting up Pusher client-side&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;pusher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Pusher&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;0b7eeff567653e170094&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;channel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pusher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;chat_channel&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message_received&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;#messages&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;lt;li&amp;gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;/li&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;#chatSubmitMessage&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;click&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;chatMessage&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;#chatMessage&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;                    &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;#messages&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;itemid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;ul&gt;
&lt;li&gt;Some changes to Index.cshtml view rendered as a result of Index() method on HomeController class invocation (this is where HTML and JavaScript for the look and feel of our chat application resides), and minor changes to _Layout.cshtml, main layout file for our application, we will remove not needed sections/links etc.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Interesting part in my opinion is how we make sure client for our web application makes username available for consumption. Our application requires user to be authenticated before one can post any chat messages. We will need username to display information who sent given message, e-mail will be used later on - when we will provide integration with &lt;a href="http://gravatar.com/"&gt;Gravatar&lt;/a&gt; to display picture in chat window and on user profile page. Our website allows registration, so should you not have an account already - you can register on the page and use the chat. These are the features that will be implemented in the second part of this post, for now you can enjoy working live chat (I&amp;#8217;ve verified it works under latest versions of Firefox and Chrome). Enjoy!&lt;/p&gt;

&lt;p&gt;All of the code is available on Github, here: &lt;a href="https://github.com/geekbeing/pusher-mvc-4-chat/"&gt;pusher-mvc-4-chat&lt;/a&gt;. Shortly I&amp;#8217;ll update the project to use user&amp;#8217;s e-mail address, will modify the UI to look nicer and also I&amp;#8217;ll show you how to get your application up and running on &lt;a href="http://appharbor.com/"&gt;AppHarbor&lt;/a&gt;.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/zKL19bmThuI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/05/18/implement-live-web-chat-part-1/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Amazon, Linux, nginx, blitz.io, New Relic, oh my...]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/s24EFyUKFI0/" />
    <updated>2012-04-02T00:04:00-04:00</updated>
    <id>http://www.geekbeing.com/2012/04/02/new-world-of-hosting</id>
    <content type="html">&lt;p&gt;It&amp;#8217;s a post about using fancy, contemporary tools, top of its breed, just to show you how many - once cumbersome, now really easy to setup - things can be done the smart way. We will have virtual machine running on Amazon&amp;#8217;s cloud, &lt;a href="http://nginx.org/"&gt;nginx&lt;/a&gt; web server on Ubuntu Linux installation, &lt;a href="http://wordpress.org/"&gt;WordPress&lt;/a&gt; on steroids &lt;a href="http://wordpress.org/extend/plugins/w3-total-cache/"&gt;W3 Total Cache&lt;/a&gt;, with &lt;a href="http://newrelic.com/"&gt;New Relic&lt;/a&gt; installed for monitoring, all load tested by &lt;a href="http://blitz.io/"&gt;Blitz&lt;/a&gt;. I can&amp;#8217;t stop myself from mentioning I&amp;#8217;m writing this blog post using &lt;a href="http://www.sublimetext.com/2/"&gt;Sublime Text 2&lt;/a&gt;, using &lt;a href="http://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt; so I could compile it later for &lt;a href="http://octopress.org/"&gt;Octopress&lt;/a&gt;, not worrying about the files, because I&amp;#8217;m using git to back it up in remote location.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been inspired recently by the &lt;a href="http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-server/"&gt;Ewan&amp;#8217;s blog entry&lt;/a&gt; and so I wanted to try it myself. I&amp;#8217;m still quite new to *ux world of operating systems, so a few of the steps will mostly require me to google out a lot of things, things I&amp;#8217;d like to share with you dear reader. This might be especially interesting for rookies, as I&amp;#8217;ll try to be pretty detailed describing what I&amp;#8217;ve done to get this setup up and running. Like Ewan in his original work I also wanted to host WordPress, for selfish reasons - this is something we&amp;#8217;ve been working on for a while at work. The only difference is we&amp;#8217;ll be hosted on Windows, IIS. Wanted to see in comparison how easily I&amp;#8217;ll be able to get it all up and running in the cloud.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve recently had a few chances, on different occasions, to use &lt;a href="http://aws.amazon.com/ec2/"&gt;Amazon&amp;#8217;s EC2 services&lt;/a&gt; and I must admit I&amp;#8217;m impressed and it&amp;#8217;s not that easy to impress me, I&amp;#8217;ll tell you that. It&amp;#8217;s reasonably priced, it&amp;#8217;s fast, it&amp;#8217;s secure by default, it&amp;#8217;s super easy to setup (as soon as you learn finding your way with lots of new terminology, as AWS - Amazon Web Services - offering has really a lot of different services to offer, each one of them), really - pure awesomeness. I&amp;#8217;ll be making side-notes for you once in a while, due to a little bit of background in Amazon&amp;#8217;s WS offerings - it&amp;#8217;s likely you&amp;#8217;ll find out something interesting.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;First step is to request an account for &lt;a href="http://aws.amazon.com/"&gt;Amazon Web Services&lt;/a&gt;. After you&amp;#8217;re done head over to the EC2 tab (EC2 is &amp;#8216;Elastic Cloud&amp;#8217; and allows creation of the Virtual Machines, with various configurations of OS/CPU/memory) and click &amp;#8216;Launch Instance&amp;#8217; button located just under &amp;#8220;My Instances&amp;#8221; section. This brings up &amp;#8216;Request Instances Wizard&amp;#8217; which allows you to pick the server. As in Ewan&amp;#8217;s post - pick Ubuntu 11.10:
&lt;img src="https://img.skitch.com/20120330-pmc2rqxx4m5dwca3eeqf7mjw2u.jpg" alt="Picking a server in AWS console" /&gt;&lt;/p&gt;

&lt;p&gt;In the next step, pick Micro instance (this is sufficient for our setup), like so:
&lt;img src="https://img.skitch.com/20120330-8i27b5is6usqrsyac84jwiubyw.jpg/" alt="Choosing Instance Type" /&gt;&lt;/p&gt;

&lt;p&gt;Leave rest of the settings with default values. On &amp;#8216;Instance Details&amp;#8217; step you may add some metadata for your instance, for example I&amp;#8217;ve used following keys/values:
&lt;img src="https://img.skitch.com/20120330-94dysj311wfni7qj85wd3ds3j.jpg/" alt="Custom tags for EC2 server instance" /&gt;&lt;/p&gt;

&lt;p&gt;If you&amp;#8217;re requesting new machine from Amazon, you&amp;#8217;ll also need a Key Pair - in order to be able to receive administrator password for the machine later on (if you&amp;#8217;ve already went through this procedure before - you might re-use your key obtained then). This is unless you would be restoring the machine you&amp;#8217;ve prepared beforehand, with Administrator account already setup and one you know password for - then no Key Pair is needed. Wizard is pretty informative about choices you need to make on your way.&lt;/p&gt;

&lt;p&gt;You need to pay attention on the &amp;#8216;Configure Firewall&amp;#8217; screen. All of these settings may be modified later on, just think about how you&amp;#8217;d like your server to be visible/accessible over the Internet. Don&amp;#8217;t expose too much. For example - for ssh connection I only enabled access from the ip of my machine at home. Of course ip could be spoofed, I just don&amp;#8217;t think it would be worthwhile to go through that much effort to get to my personal machine (e.g. hosting my blog), so as a security measure, it&amp;#8217;s good enough. You might also want to enable HTTP access for at least your ip (again - depending on what you&amp;#8217;d like to use machine for). In this particular case - we should enable access from everywhere - it will allow us to use external tooling for our load testing planned for later on.&lt;/p&gt;

&lt;p&gt;Finally you&amp;#8217;ll get to the summary screen, scan through the configuration of the machine you&amp;#8217;re requesting to make sure this is what you wanted, and happily press &amp;#8216;Launch&amp;#8217; button to start your instance. Shortly enough (minutes) you will have your machine up and running.&lt;/p&gt;

&lt;p&gt;With your shiny new machine running in the cloud you should now connect to it via ssh. This is actually the first place in Ewan&amp;#8217;s entry that didn&amp;#8217;t work for me as he describes. I had both of the private keys - id_dsa and id_rsa in .ssh folder, but when I was trying to connect to the server I&amp;#8217;d get a message (debugging enabled, just use ssh -i):&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;connecting to ec2-46-137-2-17.eu-west-1.compute.amazonaws.com&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;debug1: Offering RSA public key: /Users/geekbeing/.ssh/id_rsa
&lt;/span&gt;&lt;span class='line'&gt;debug1: Authentications that can &lt;span class="k"&gt;continue&lt;/span&gt;: publickey
&lt;/span&gt;&lt;span class='line'&gt;debug1: Offering DSA public key: /Users/geekbeing/.ssh/id_dsa
&lt;/span&gt;&lt;span class='line'&gt;debug1: Authentications that can &lt;span class="k"&gt;continue&lt;/span&gt;: publickey
&lt;/span&gt;&lt;span class='line'&gt;debug1: No more authentication methods to try.
&lt;/span&gt;&lt;span class='line'&gt;Permission denied &lt;span class="o"&gt;(&lt;/span&gt;publickey&lt;span class="o"&gt;)&lt;/span&gt;.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Took me a while but then I suddenly realized - how on earth could Amazon know about my .ssh keys? They couldn&amp;#8217;t - I thought I&amp;#8217;d need to use a key I agreed upon with Amazon. This is where Key Pair key is needed. So I&amp;#8217;ve copied my .pem file downloaded during EC2 Ubuntu server setup to my .ssh folder and retried ssh connection, this time providing the key, like so (debugging still enabled until the issue will be resolved):&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;second attempt connecting to ec2-46-137-2-17.eu-west-1.compute.amazonaws.com&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;ssh -v -i macbook-home.pem root@ec2-46-137-2-17.eu-west-1.compute.amazonaws.com
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This time debug message made sense instantly:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;connecting to ec2-46-137-2-17.eu-west-1.compute.amazonaws.com&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;Permissions 0644 &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;macbook-home.pem&amp;#39;&lt;/span&gt; are too open.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;During investigation of the ssh connection error earlier on, I&amp;#8217;ve read somewhere correct permissions should be 06000, so I&amp;#8217;ve run:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;setup permissions for .pem file&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;chmod 0600 macbook-home.pem
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This time upon another login attempt I&amp;#8217;ve finished with error message telling me not to use root user for access (rightfully so):&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;don&amp;#8217;t use &amp;#8216;root&amp;#8217; access, stupid&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;Please login as the user &lt;span class="s2"&gt;&amp;quot;ubuntu&amp;quot;&lt;/span&gt; rather than the user &lt;span class="s2"&gt;&amp;quot;root&amp;quot;&lt;/span&gt;.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;But this is very good, we&amp;#8217;re actually getting somewhere - what is more - not only error messages point me exactly to what&amp;#8217;s wrong - as a bonus they make total sense too!
Finally, with&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;all right, let&amp;#8217;s try one more time&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;ssh -v -i macbook-home.pem ubuntu@ec2-46-137-2-17.eu-west-1.compute.amazonaws.com
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Next steps are taken 1:1 from &lt;a href="http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-server/"&gt;Ewan&amp;#8217;s blog&lt;/a&gt;
We&amp;#8217;re in! For the purpose of my installation, as we&amp;#8217;ve already setup Security Group in AWS management console, I&amp;#8217;m skipping firewall setup from Ewan&amp;#8217;s blog, heading straight to installing MySQL, which can be easily done with:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;installing MySQL&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;apt-get update
&lt;/span&gt;&lt;span class='line'&gt;apt-get install mysql-server
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;During installation you&amp;#8217;ll be prompted to setup password for root user in MySQL, enter the password twice, don&amp;#8217;t leave it blank. After installation is done - connect to MySQL:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;connect to newly installed MySQL instance&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;mysql -u root -p
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;You&amp;#8217;ll be asked for credentials you&amp;#8217;ve setup for the &amp;#8216;root&amp;#8217; user upon installation - enter these and then run following commands at mysql prompt - this assumes you&amp;#8217;ll be hosting WordPress and MySQL on the same server - hence &amp;#8216;localhost&amp;#8217; appearing in SQL commands:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;preparing database for WordPress&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;CREATE DATABASE wordpress;
&lt;/span&gt;&lt;span class='line'&gt;GRANT ALL PRIVILEGES ON wordpress.* TO
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="s2"&gt;&amp;quot;wp_user&amp;quot;&lt;/span&gt;@&lt;span class="s2"&gt;&amp;quot;localhost&amp;quot;&lt;/span&gt; IDENTIFIED BY &lt;span class="s2"&gt;&amp;quot;PASSWORD_YOU_WANT_FOR_WP_USER&amp;quot;&lt;/span&gt;;
&lt;/span&gt;&lt;span class='line'&gt;FLUSH PRIVILEGES;
&lt;/span&gt;&lt;span class='line'&gt;EXIT
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Next step is to install and configure PHP. Not only PHP but also &lt;a href="http://php-fpm.org/"&gt;PHP FPM&lt;/a&gt;, &lt;a href="http://php.net/manual/en/book.apc.php/"&gt;PHP APC&lt;/a&gt; and MySQL module for PHP. Run the following command:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;installing PHP&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;apt-get install php5-fpm php-pear php5-common php5-mysql php-apc
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Configure PHP for APC, by adding following lines at the bottom of php.ini file (you can use e.g. vi editor. Just use &amp;#8216;vi /etc/php5/fpm/php.ini&amp;#8217; command, then press &amp;#8216;G&amp;#8217; to jump to the bottom of the file, &amp;#8216;i&amp;#8217; to enter Insert mode in vi, then enter those lines. When you&amp;#8217;re done - press ESC to exit Insert mode and finally &amp;#8216;:wq&amp;#8221; to write file to disk and quit vi:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;configure php.ini&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;[&lt;/span&gt;apc&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;apc.write_lock &lt;span class="o"&gt;=&lt;/span&gt; 1
&lt;/span&gt;&lt;span class='line'&gt;apc.slam_defense &lt;span class="o"&gt;=&lt;/span&gt; 0
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Now you need to configure PHP for nginx. These are the changes you need to do, starting with &amp;#8216;vi /etc/php5/fpm/pool.d/www.conf&amp;#8217; and going into Insert mode as previously - so first replace&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;configure www.conf, step one&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 127.0.0.1:9000
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;with&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;configure www.conf, step one&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /dev/shm/php-fpm-www.sock
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;then insert the following lines just below the line you&amp;#8217;ve just modified:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;configure www.conf, step two&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;listen.owner &lt;span class="o"&gt;=&lt;/span&gt; nginx
&lt;/span&gt;&lt;span class='line'&gt;listen.group &lt;span class="o"&gt;=&lt;/span&gt; nginx
&lt;/span&gt;&lt;span class='line'&gt;listen.mode &lt;span class="o"&gt;=&lt;/span&gt; 0660
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;then change&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;configure www.conf, step three&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; www-data
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;group&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; www-data
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;to&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;configure www.conf, step three&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nginx
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;group&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nginx
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;We&amp;#8217;re done with that part. Now we need to install nginx itself. From now on, since I haven&amp;#8217;t actually modified anything in Ewan&amp;#8217;s description, just follow the instructions on &lt;a href="http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-server/"&gt;his blog&lt;/a&gt; or from nginx website, Ewan has just reused it on his blog.&lt;/p&gt;

&lt;p&gt;If it all went down quickly and smoothly (as it was in my case) - you&amp;#8217;ve ended up with your WordPress installation at this point. If you want to see mine, running in the cloud - feel free accessing it &lt;a href="http://ec2-46-137-2-17.eu-west-1.compute.amazonaws.com/"&gt;http://ec2-46-137-2-17.eu-west-1.compute.amazonaws.com/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It was really fun, now we can play a little bit with &lt;a href="http://blitz.io/"&gt;Blitz&lt;/a&gt; to see ourselves how much load we can put our server under and still have reasonable response times. In order to collect more information we should set up our WordPress installation with e.g. &lt;a href="http://www.google.com/analytics/"&gt;Google Analytics&lt;/a&gt;, or to have different kind of statistics and more detailed reports (e.g. about SQL queries being run, CPU or memory usage, etc&amp;#8230;) - I will also go for &lt;a href="http://newrelic.com/"&gt;New Relic&lt;/a&gt;. With all of these setup, we can now get back to Blitz, register for an account and test response time of our instance, by entering the URL to the text box and clicking &amp;#8216;Run&amp;#8217; we will receive results like so:
&lt;img src="https://img.skitch.com/20120331-1d7a4xxrxa38yqxr1jtkmw7a46.jpg/" alt="Blitz.io test run results" /&gt; As you can see this also includes suggestion how you can run load tests on your site. Handy enough - this text in greenish color is actually a link you can click to start the first load test! Clicking it issues a request to Blitz to load test the application under the given url, however, this first attempt ends up with the message:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Piotr, we have a little hiccup&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;Prove to us you own this app and we are happy to &lt;span class="nb"&gt;let &lt;/span&gt;you rush it.
&lt;/span&gt;&lt;span class='line'&gt;Just make sure that one of the following URLs is reachable
&lt;/span&gt;&lt;span class='line'&gt;and returns 42 as the content.
&lt;/span&gt;&lt;span class='line'&gt;This helps us understand the meaning of it all.
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;Status    Authorization URL   
&lt;/span&gt;&lt;span class='line'&gt;404   /mu-eb1fb975-6fa67f08-xxxxxxxx-xxxxxxxx
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;What can I see. Funny, geeky, simply 1337. Ok then, let&amp;#8217;s set our WordPress installation up for authorization with Blitz. I wasn&amp;#8217;t able to google out how to setup routing in order for authorization URL to return 42, so I went with the option of using .txt file. You just create one in the folder where you have all of your WordPress files, in my case it was mu-eb1fb975-6fa67f08-xxxxxxxx-xxxxxxxx.txt, fill it with 42 and next time you try running rush Blitz will do its magic.&lt;/p&gt;

&lt;p&gt;When I&amp;#8217;ve run it for the first time, I effectively killed the site. It seemed like it was doing pretty well, but that&amp;#8217;s only before I got to 200 concurrent requests. Then it died, got up for a 10 more seconds before finally giving up:
&lt;img src="https://img.skitch.com/20120331-ctpeinrt9sdsudai4cqm24ure3.jpg/" alt="Dying WordPress" /&gt;&lt;/p&gt;

&lt;p&gt;I&amp;#8217;d be awesome to know more about what happened server side. Can you imagine the hell there? So as mentioned before I decided to install New Relic&amp;#8217;s software for monitoring. Signing Up is really simple and then you just need to install their component on the server in order to start collecting detailed information about health of your server and application. Once again - they make it really simple - you just pick PHP from the list of the available languages/platforms, pick Debian-based Linux (we are using Ubuntu in this case) and you get nice and easy to follow step-by-step instructions for the installation.&lt;/p&gt;

&lt;p&gt;On the next few attempts I wanted to be a little less brutal, seems like command&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;performing rush using blitz.io with 100 concurrent requests&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;-p 1-100:60 http://ec2-46-137-2-17.eu-west-1.compute.amazonaws.com/
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;&lt;img src="https://img.skitch.com/20120401-qiwkgfkm6dka9shgnw497fpjtd.jpg/" alt="Results for rush with 100 concurrent requests thanks to Blitz.io" /&gt;
almost allowed me to be kind - my poor WordPress died by the very end of the test. Plateau at the beginning is just a WordPress not fully recovered after previous rush ;). In the rushes that followed - site was dying after circa 50 seconds, I just didn&amp;#8217;t get to take the screenshots. The detailed report says:&lt;/p&gt;

&lt;p&gt;&amp;#8216;This rush generated 277 successful hits in 1.0 min and we transferred 272.31 KB of data in and out of your app. The average hit rate of 4.39/second translates to about 379,705 hits/day.
You got bigger problems though: 87.53% of the users during this rush experienced timeouts or errors! (&amp;#8230;) The first timeout happened at 5.01 seconds into the test when the number of concurrent users was at 9. Looks like you&amp;#8217;ve been rushing with a timeout of 1 second.&amp;#8217;&lt;/p&gt;

&lt;p&gt;New Relic&amp;#8217;s monitoring has already been running in background - but more about the results later in this post.&lt;/p&gt;

&lt;p&gt;Seems like it&amp;#8217;s time for some tweaks. First of all, we will enable &lt;a href="http://wordpress.org/extend/plugins/w3-total-cache/"&gt;W3 Total Cache&lt;/a&gt;. Head over to the admin dashboard under your WordPress installation, go to Plugins-&gt;Add New-&gt;Search. Find this plugin and install it. When installation is complete, click &amp;#8216;Activate Plugin&amp;#8217;. In the plugin&amp;#8217;s settings enable Database Cache and Object Cache. Additionally, everywhere where it&amp;#8217;s possible pick from the drop-down &amp;#8216;Opcode: Alternative PHP Cache (APC)&amp;#8217;. Save all settings. Click &amp;#8216;Deploy&amp;#8217; on the very top of the settings page. You should see a message appearing &amp;#8216;Preview settings successfully deployed&amp;#8217;.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s get back to Blitz.io and re-run the tests with the same settings as previously, so you&amp;#8217;d have some data to compare against. For me, results are simply astonishing:
&lt;img src="https://img.skitch.com/20120401-m7ghfgcqmpj1jak8ucta4khkwx.jpg/" alt="Results for rush with 100 concurrent requests, W3 Total Cache enabled" /&gt;
First of all - my WordPress instance didn&amp;#8217;t die! This is way better then before. But not only that - check out how much more we&amp;#8217;ve actually accomplished:&lt;/p&gt;

&lt;p&gt;&amp;#8216;This rush generated 2,272 successful hits in 1.0 min and we transferred 21.19 MB of data in and out of your app. The average hit rate of 36/second translates to about 3,131,096 hits/day.
You got bigger problems though: 0.18% of the users during this rush experienced timeouts or errors!&amp;#8217;.&lt;/p&gt;

&lt;p&gt;Almost ten times more successful hits, over ten times more of data transferred. And only (ok, it&amp;#8217;s still too much, but you get the point) one user expected timeout! This is very encouraging, however - re-running the rush with 250 concurrent users leads to a situation where server stops responding. By the end of the test &amp;#8216;You got bigger problems though: 5.21% of the users during this rush experienced timeouts or errors!&amp;#8217;. This is way too many. Desperate time need desperate measures (or something) - so besides having W3 Total Cache installed we will also install &lt;a href="https://www.varnish-cache.org/about/"&gt;Varnish 3&lt;/a&gt; - &amp;#8216;Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy&amp;#8217;. For reference on how to do that - please take a look at &lt;a href="http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-server/"&gt;Ewan&amp;#8217;s blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With Varnish installed - restart nginx (service nginx restart) and Varnish (service varnish restart) let&amp;#8217;s re-run the rush, with following parameters:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;performing rush using blitz.io with 250 concurrent requests&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='line'&gt;-p 1-250:60 http://ec2-46-137-2-17.eu-west-1.compute.amazonaws.com/
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;My mind is literally blown away. Really cheap machine, powerful software (even though everything is available for free, at least in basic version) and something that not long ago seemed to require lots of money and effort - and take a look at the results:
&lt;img src="https://img.skitch.com/20120401-pfpt2xd6s246h5irnjqdp272rg.jpg/" alt="Blitz.io rush results, with W3 Super Cache and Varnish 3 installed" /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#8216;This rush generated 5,681 successful hits in 1.0 min and we transferred 50.13 MB of data in and out of your app. The average hit rate of 90/second translates to about 7,851,141 hits/day.&amp;#8217;
This means we had 5,681 hits during which users have not experienced a single time-out nor error! It is a truly an outstanding result. What is interesting - with index page being bigger in size and by re-running the tests I was able to maintain equally good results, even though amount of transferred data rised to &amp;#8216;106.65 MB of data in and out of your app&amp;#8217;.&lt;/p&gt;

&lt;p&gt;And here, just to give you idea about the difference - a screenshot from the statistics gathered by New Relic:
&lt;img src="https://img.skitch.com/20120401-k6g449yhmy1t91jict4n4csaji.jpg/" alt="Response time and throughput - before and after enabling W3 Total Cache and Varnish 3" /&gt;&lt;/p&gt;

&lt;p&gt;This is where Ewan stopped (minus New Relic, minus detailed instructions for connecting to EC2 instance, minus solutions to the problems when following Ewan&amp;#8217;s instructions) - but to me it&amp;#8217;s more or less half of the way. Because of the requirements for the setup I&amp;#8217;m going to use for our project at work, during next few weeks I&amp;#8217;ll be doing some research and blog about my findings right after. Here&amp;#8217;s the list of topics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://aws.amazon.com/elasticloadbalancing/"&gt;Elastic Load Balancing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://aws.amazon.com/rds/"&gt;Amazon Relational Database Service (Amazon RDS) (beta)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://memcached.org/about"&gt;Memcached&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.alachisoft.com/ncache/"&gt;NCache&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Might take a little while to implement, as most of the hacking is done during the night, which isn&amp;#8217;t as easy-peasy-lemon-squeezy to do as it might sound, with two little kids at home and daily job and moving to the house we&amp;#8217;ve just built. Ok, enough wining, getting back to work.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/s24EFyUKFI0" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/04/02/new-world-of-hosting/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Eight books for .NET (mostly) developers (mostly web) you must read]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/-gyenu5mbd0/" />
    <updated>2012-02-25T21:51:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/02/25/eight-books-for-net-developers-you-must-read</id>
    <content type="html">&lt;ol&gt;
&lt;li&gt;&lt;a href="http://www.albahari.com/nutshell/"&gt;C# 4.0 in a Nutshell&lt;/a&gt; - complete and comprehensive book that nicely explains and presents A, B and C for C# developers from perspective of both - C# as a language and .NET as a framework.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.manning.com/skeet2/"&gt;C# in Depth, Second Edition&lt;/a&gt; - at first one might think it&amp;#8217;s not for the faint of heart. On the second thought - one just might be right. Seriously though - this isn&amp;#8217;t a simple book to digest due to the in depth treatment topics touched there get. Jon Skeet&amp;#8217;s writing skills are unmatched in tech world (in my opinion), it&amp;#8217;s just not the kind of book you can quickly scan through and move on. I can&amp;#8217;t recommend it if you&amp;#8217;re new to C#, but I can assure you - it&amp;#8217;s totally worth reading, sticking to it and giving it as much time as it&amp;#8217;s going to take for you to fully get it. A pearl.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.com/3-0-Design-Patterns-Judith-Bishop/dp/059652773X/ref=sr_1_1?ie=UTF8&amp;amp;qid=1330203360&amp;amp;sr=8-1"&gt;C# 3.0 Design Patterns&lt;/a&gt; - to be honest I&amp;#8217;m not a super fan of the famous Gang of Four and their book about Design Patterns. Call me troglodyte - I&amp;#8217;ve tried really really hard to read it, was always falling asleep sooner than later. This book takes a whole different approach. It will present the patterns but at the same time show you where the money is. By which I mean - the code of course. &lt;!--more--&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://manning.com/osherove/"&gt;The Art of Unit Testing&lt;/a&gt; - If you want to do it - do it right. And there is no other way of doing it right than doing TDD. And no other way of getting to know how to use TDD than by reading (and practicing with!) Roy&amp;#8217;s book. Plenty good.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://manning.com/seemann/"&gt;Dependency Injection in .NET&lt;/a&gt; - Once again - hail to the king baby. And king, in this dog eat dog world, is Manning and their amazing authors. Dependency Injection in .NET world picked up relatively late in comparison to Java (on the other hand Java is practically dead now so it doesn&amp;#8217;t matter anymore), but it seems it&amp;#8217;s finally getting the attention it deserves.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://manning.com/palermo3/"&gt;ASP.NET MVC 3 in Action, Third Edition&lt;/a&gt; - you&amp;#8217;ve picked .NET, you&amp;#8217;ve picked ASP, you will be picked on by the kids in your school. Folks over internet will laugh at you - but the good news is - joke&amp;#8217;s on them. Rails is already passé, node.js will be - tomorrow morning. One gotta be stupid to work on web apps using Microsoft&amp;#8217;s technology. Then join me on the bandwagon of stupid people, with this awesome, well written book and let&amp;#8217;s pee on the rails &lt;a href="http://gilesbowkett.blogspot.com/2012/02/rails-went-off-rails-why-im-rebuilding.html"&gt;Rails Went Off The Rails: Why I&amp;#8217;m Rebuilding Archaeopteryx In CoffeeScript &lt;/a&gt; since it requires too much ceremony and scratching one&amp;#8217;s balls should be a fairly simple task.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.manning.com/bibeault2/"&gt;jQuery in Action, Second Edition&lt;/a&gt; - you may like the fact, or may not, jQuery is de facto standard JavasScript library.No matter the side you pick on the server side war - on the client we&amp;#8217;re all happily-ever-after-united by jQuery sweet sweet loving it makes to our browsers and most importantly - clients.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.com/Innocent-Code-Security-Wake-Up-Programmers/dp/0470857447"&gt;Innocent Code: A Security Wake-Up Call for Web Programmers&lt;/a&gt; - last but certainly not least! (And with the longest title! Hurray!) - this isn&amp;#8217;t a super-advanced books, but everyone needs to start somewhere. So start there - totally worth a read.&lt;/li&gt;
&lt;/ol&gt;

&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/-gyenu5mbd0" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/02/25/eight-books-for-net-developers-you-must-read/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RavenDB Tutorial, part 3 - tips for development]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/8Cn51p4IPOk/" />
    <updated>2012-02-24T08:26:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/02/24/ravendb-tutorial-part-3</id>
    <content type="html">&lt;p&gt;Recently at work I had a chance to co-write, along with two of my buddies, application (ASP .NET MVC 3 + RavenDB for the data) used by circa 1000 people internally (with good chance of the user base growing significantly - more and more people come to us asking whether they could use it for the project of theirs). In case you&amp;#8217;re interested - it&amp;#8217;s a &lt;a href="http://uservoice.com/"&gt;User Voice&lt;/a&gt; clone. Application has been really successful and I&amp;#8217;m happy how it turned out. Even that early in the process of learning on how to work with Raven I already have a few caveats I&amp;#8217;ve run into and wanted to spend a while sharing with you what I&amp;#8217;ve found out. And some things I still haven&amp;#8217;t found out, maybe you, dear reader, will be able to help me out.&lt;/p&gt;

&lt;p&gt;So first about picking the preferred way of hosting Raven. RavenDB can be installed as service, run as .exe, web site on IIS, embedded or embedded in-memory. Raven itself can be downloaded from &lt;a href="http://ravendb.net/download"&gt;RavenDB&lt;/a&gt; page, from the CI (Continuous Integration) server (both - stable and unstable builds) or installed via &lt;a href="http://nuget.org/"&gt;NuGet&lt;/a&gt; - package manager for Visual Studio and .NET. It doesn&amp;#8217;t make too much difference where you install it from, however picking an option on how to run it is more important. I used to install RavenDB via NuGet and then, during the development just run Raven.Server.exe and keep the command line opened. Good thing is that Raven logs requests and responses in the console, so you can peek a little bit under the hood and see what&amp;#8217;s going on (although I&amp;#8217;m going to show you later on, how to do it in a more convenient way). For me, there were more downsides though. First of all, I don&amp;#8217;t like having too many applications opened at once (I still have for the most of the time, one way or another - I don&amp;#8217;t need yet another one), as I&amp;#8217;ve said - there are more convenient ways of looking at the communication going on between your application and RavenDB server instance. Another downside is that should you need to update to new version of RavenDB server - you got to do it for each of the solutions separately. And should you need to start new application with Raven as a data source when you&amp;#8217;re temporarily offline - you&amp;#8217;d need to copy the files from the other directory to the new solution&amp;#8217;s dir. Of course you could also use RavenDB from some other directory, but then if you&amp;#8217;re just using default instance of the database, files storing documents from your different solutions will be all mixed up in Raven&amp;#8217;s directory. I didn&amp;#8217;t see the point of configuring yet another site on IIS. &amp;#8216;In memory&amp;#8217; option is great in my opinion for integration tests, where you don&amp;#8217;t need to persist data in Raven between each of the runs.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;So I&amp;#8217;m using RavenDB as a service and I find it the most convenient. And I&amp;#8217;m always using named of the db - that way entities from my different pet projects are nicely separated. All you need to do is to configure connections for RavenDB in your app.config/web.config like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Setting up named RavenDB instance&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;ApplicationName&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;connectionString&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Url=http://localhost:8081/databases/ApplicationName&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;When Raven is hosted as a service I don&amp;#8217;t need to remember about running it each time I fire up the application, it&amp;#8217;s always running (and consuming really small amount of memory - circa 30 MB most of the time). When I need to update the server - there&amp;#8217;s only one place where I need to do it. I&amp;#8217;ll be happy to hear in the comments about your patterns of usage.&lt;/p&gt;

&lt;p&gt;Management Studio - for browsing, editing and querying your data, checking projections of the data in the indices, data import/export, etc&amp;#8230; It&amp;#8217;s built on Silverlight (RavenDB is supported on Silverlight) and frankly - to me it&amp;#8217;s one of the weakest points in Raven. Silverlight is just uncool and looks really weird in comparison to truly great product RavenDB is. Starting from build 1.0.616 Management Studio supports deleting documents by collection which, especially during the phase I&amp;#8217;m experimenting with new application comes in very handy.
One caveat I&amp;#8217;ve run into was the fact that working on my machine @home with local account setup to have no password I couldn&amp;#8217;t edit any documents nor delete them via the Silverlight interface. In order to be able to do it I needed to change:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Original configuration in Raven.Server.exe.config&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='xml'&gt;&lt;span class='line'&gt;&lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Raven/AnonymousAccess&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Get&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;to&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Altered configuration in Raven.Server.exe.config&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='xml'&gt;&lt;span class='line'&gt;&lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Raven/AnonymousAccess&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;All&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This obviously cannot be used in production environment but if you&amp;#8217;re just experimenting this is fine should you run into the aforementioned issue.&lt;/p&gt;

&lt;p&gt;Another thing, not necessarily related to RavenDB, but the one I find very handy is to use a bootstrap for the UI. With new release of ASP .NET MVC - version 4 - visual styles for the default template has been revamped and now looks modern, fresh and cool. But for those who won&amp;#8217;t like it, or would like to have a beautiful web apps, even if just for playing around with new technology - using a bootstrap comes really handy. I&amp;#8217;ll blog more about it - for now just check out the following: &lt;a href="http://twitter.github.com/bootstrap/"&gt;Twitter Bootstrap&lt;/a&gt; or &lt;a href="http://foundation.zurb.com/docs/index.php"&gt;Foundation&lt;/a&gt;. It really just takes a second to setup and use and you get a beautiful web apps practically for free. And free is good. Once you&amp;#8217;ve tweaked your MVC app to use the latest assemblies (e.g. via NuGet) and tuned up the UI a little bit, you can export this project as a template, so you&amp;#8217;d have a nice base to start off for your next project.&lt;/p&gt;

&lt;p&gt;When working with ASP .NET MVC you get a handy routing engine, which allows you to define the mappings between the paths in the URL and the controller and action that is going to respond to this request. When you create a RESTful API in your web application for read/update operations on single entity you&amp;#8217;re using id of the entity as a part of the URL. Since by default Raven assigns your entities names similar to: entityClassName-id (where id is auto-generated) - this starts interfering with MVC&amp;#8217;s routing engine. In order to avoid any issues, just change the default setting on the DocumentStore, by using IdentityPartsSeparator property, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;DocumentStore initialization with modified identity separator&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;IDocumentStore&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;DocumentStore&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ConnectionStringName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://localhost:8080&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Initialize&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;   
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Conventions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IdentityPartsSeparator&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Of course you might stick to the original convention, when part separating the entity class name from the id is default &amp;#8216;/&amp;#8217;, then you&amp;#8217;d need to modify the default routing, like so:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;MVC route modification to support Raven&amp;#8217;s original entity separator &amp;#8216;/&amp;#8217;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MapRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="s"&gt;&amp;quot;Default&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="s"&gt;&amp;quot;{controller}/{action}/{*id}&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;However - this might bite you again when you add more routes to the routing table in your MVC application. I&amp;#8217;d rather use the first option - changing the separator.&lt;/p&gt;

&lt;p&gt;And last but not least - a feature that comes in really handy when working on the application and trying to optimize it by reducing number of requests made, or trying to locate and fix source of the long processing time on the server, etc&amp;#8230; - RavenDB MVC Profiler. When you visit &lt;a href="http://ayende.com/"&gt;Ayende&amp;#8217;s blog&lt;/a&gt; you might notice a small, orange rectangle in the upper left corner of the page. When you click on it you&amp;#8217;ll see information about how long RavenDB&amp;#8217;s session has been opened for, how many requests were made, which resource was freshly fetched which cached, what was the path of the request made to Raven, information about the query. Really useful and informative. And pretty easy to install too. To reap the benefits of RavenDB profiler in your ASP .NET MVC application just use the following line in your Application_Start method (or anywhere else where you initialize DocumentStore, just make sure this method is called once)&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Plugging in RavenDb Profiler&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;   &lt;span class="n"&gt;Raven&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MvcIntegration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RavenProfiler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;InitializeFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;and then, in the layout file for your application (_layout.cshtml by default in ASP .NET MVC 3) add following line:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;&amp;#8230;and add it to the view&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;@Raven&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MvcIntegration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RavenProfiler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CurrentRequestSessions&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Done! Just two line to have all of these benefits. In fact - RavenDB Profiler is so efficient, we&amp;#8217;re using it in production environment, not experiencing any slowdown. We&amp;#8217;re just making sure we display aforementioned orange rectangle to the few selected people who will be working on making our application faster.&lt;/p&gt;

&lt;p&gt;This is not, by any means, a comprehensive list of the tips and tricks, as we dive deeper in the posts to come, I&amp;#8217;ll be spicing things up with new information here and there. Happy coding!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/8Cn51p4IPOk" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/02/24/ravendb-tutorial-part-3/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RavenDB Tutorial, part 2 - simple querying]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/XO-bm1i6njA/" />
    <updated>2012-02-06T00:06:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/02/06/ravendb-tutorial-part-2</id>
    <content type="html">&lt;p&gt;In the previous post &lt;a href="http://www.geekbeing.com/2012/01/21/raven-db-tutorial/"&gt;RavenDB Tutorial, Part 1 - Introduction and Basic Operations&lt;/a&gt; I&amp;#8217;ve described fundamental topics requiring your attention before you start coding and also presented how to initialize database, persist documents, load and delete them. I wanted to make indexing and querying a separate posts because, my observation is, these topics are a little bit more advanced and tricky to work with. There are some caveats you need to be aware of and careful about and at least in theory so many different articles describing the topic, but in my opinion none of them are any good and very often they do more harm (by confusing the hell out of you) than actually explain. So this is the post I wish I had a chance to read before approaching the topic for the first time.&lt;/p&gt;

&lt;p&gt;First of all - we need to have some data we will be able to query upon. From my experience there are two favorite types of data folks out there are modeling for the purposes of blog posts and tutorials about document databases - orders and blog posts. Some time ago I thought it&amp;#8217;s cliché and not really original, but now I believe this is for a reason. And the reason is that those are entities one can be almost sure readers of a blogs committed to coding/development have seen, used and experienced. What is more - those are so common in so-called &amp;#8216;real life&amp;#8217; we don&amp;#8217;t need to think too much to &amp;#8216;see&amp;#8217; a mental model in our heads, which in turn means we&amp;#8217;re not using precious brain-processor circles on digesting the being of an entity - but instead we can focus on the new material at hand. But I don&amp;#8217;t like following standard path, so in my tutorial I will be querying against database containing people. Not real people of course, but object representation of entities of class &amp;#8216;Person&amp;#8217; having a few very simple properties, which as orders and posts are rally easy to comprehend. To avoid distraction - I&amp;#8217;ve prepared a solution which contains a few projects with code accompanying posts for this series.&lt;/p&gt;

&lt;p&gt;It can be found on GitHub, here: &lt;a href="https://github.com/geekbeing/ravendb-tutorial"&gt;Geekbeing.Blog.RavenDb.Tutorial&lt;/a&gt;. With that you can create a copy of RavenDB and data (‘readme’ file in GitHub repository describes how to set it up) for yourself pretty easily and take a look at the code I&amp;#8217;ll be discussing in this post. ‘Readme’ also instructs you on how to setup your database and populate it with the entities. Console application shows some basic querying, while ASP .NET MVC 3 based sample shows more advanced scenario (not that advanced, though, we will take on more complex querying in the upcoming posts). Let&amp;#8217;s go!&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;First thing you might want to do, would be to find out how many records (entities, or better - documents in RavenDB&amp;#8217;s nomenclature) there are. For code I&amp;#8217;m about to present make more sense to you familiarize yourself with at least two interfaces in .NET - IQueryable&lt;T&gt; and IEnumerable&lt;T&gt;. The most awesome summary on both can be found in a superb position by Jon Skeet - &lt;a href="http://www.manning.com/skeet/"&gt;C# in Depth&lt;/a&gt; (and not only that - it&amp;#8217;s an advanced book on C# language, if you are serious about development in c# you really should buy a copy and read it). To make long story short - what is important from our point of view is that no request is being made to RavenDB until we either start accessing properties of the documents (while enumerating) we are querying on, or we call a method which triggers database roundtrip, e.g. by calling extension method Count(), ToArray(), ToList() - as those to be processed require documents to be available for processing not on the server but on the client of RavenDB (in our case - console application or mvc web project). Let&amp;#8217;s take a look at example:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Querying RavenDB database&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;takeTenSkipFifty&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Skip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;takeTenSkipFifty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Looking at the code we need to be aware that first two lines in using statement are not triggering a call to Raven. Only in third line, because we call &amp;#8216;ToList()&amp;#8217; method - actual request to database is made.&lt;/p&gt;

&lt;p&gt;One of the caveats one needs to be aware of when working with Raven is presented in the code below. For the sake of the example you must know I&amp;#8217;ve seeded my instance of the database with 220 documents, each of these representing object of &amp;#8216;Person&amp;#8217; class (part of the aforementioned solution, available for download). What do you think happens when you call code below?&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Fetching all of the documents?&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;().&lt;/span&gt;&lt;span class="n"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Interesting thing is that if you count how many object variable &amp;#8216;people&amp;#8217; holds - you will encounter not the exact amount of the docs of given type in RavenDB server instance you are querying - but 128 elements (no more than 128, no matter how many there actually are). It&amp;#8217;s a feature, not a bug. This is by design as it is hard to think about a situation where you&amp;#8217;d actually need more records than that all at once (Although I can easily think of a situation where some people would think they need it). So this constraint is here to prevent you from shooting yourself in the foot. There is plenty of information online where Ayende explains his motives behind this choice. Also this limit can be changed in the server configuration - but do it at your own risk - it is strongly recommended against doing so. The question you might think of right now is - How do I know how many documents of a given type are actually there? This might be interesting because you could e.g. be interested in presenting your users with a number of the accounts that have been already registered for your service. Or implement pagination, which is very common scenario nowadays. Part of the information you are going to need is a total count of the documents you will be presenting to the user of the application. It could be done this way (don&amp;#8217;t copy paste this code, it&amp;#8217;s just to present some concepts, but it&amp;#8217;s flawed)&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;So how many docs are there actually?&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;RavenQueryStatistics&lt;/span&gt; &lt;span class="n"&gt;queryStatistics&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Statistics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;out&lt;/span&gt; &lt;span class="n"&gt;queryStatistics&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="c1"&gt;//bad! don&amp;#39;t do it like that!&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="c1"&gt;//good implementation on GitHub&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;peopleCount&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;queryStatistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalResults&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Let me explain myself&amp;#8230; I start by opening the session and then issue
Query&lt;Person&gt; call - this tells raven I will be trying to access documents which are of type &amp;#8216;Person&amp;#8217;, internally this will tell Raven to use Raven/DocumentsByEntityName index (I&amp;#8217;ll explain indexes in the one of the forthcoming posts) - which by default is present in each RavenDB database. On the next line I&amp;#8217;m using Statistics extension method, which will later on allow me to read number of TotalResults. Of course you could also load all of the documents (not calling Take(0)) of given type and count them after fetching from database - this would work, but it&amp;#8217;s bad, m&amp;#8217;kay? So then I we make Take(0) call - this will explicitly tell Raven not to load any entities at all. Why? Because on the very next line I&amp;#8217;m calling ToList() which would fetch all of the documents I&amp;#8217;m querying for (well, not all, 128 with standard RavenDB server configuration) - while the only thing I wanted to do is to get their count. So as the effect of this last call TotalResults property on queryStatistics object will be set - allowing me to get to know the number of total records of a given type. This isn&amp;#8217;t that great, because it this code is embedded in one of the action methods on my controller (in MVC 3 application) - this call will be made on each request. And then I&amp;#8217;d need another request to fetch only the records I&amp;#8217;d like to display. That&amp;#8217;s why sample solution accompanying this post contains pagination implemented in correct way, use that code&lt;/p&gt;

&lt;p&gt;A pretty obvious scenario is presented at &lt;a href="http://ravendb.net/docs/client-api/querying/paging"&gt;RavenDB paging&lt;/a&gt; - unfortunately example does not show how the rest of the code (pagination logic, views) is implemented. I think RavenDB itself is much more awesome than documentation for it. It has improved a lot recently, but to me and friends I&amp;#8217;ve discussed this issue with - it&amp;#8217;s lacking information in many places, or showing only the happiest/simplest path, always leaving us with obvious questions we&amp;#8217;d like to ask further, but unfortunately - no answers. Should you feel the same about the material I&amp;#8217;m presenting in this post - drop me an e-mail, I&amp;#8217;ll be glad to sort things out for you (and for myself by the way).&lt;/p&gt;

&lt;p&gt;As I&amp;#8217;ve mentioned - &lt;a href="https://github.com/geekbeing/ravendb-tutorial"&gt;Geekbeing.Blog.RavenDb.Tutorial&lt;/a&gt; contains project Geekbeing.Blog.RavenDb.Tutorial.Web, which is a simple ASP .NET MVC 3 based web application presenting how to paginate through the list of documents of type &amp;#8216;Person&amp;#8217;. It&amp;#8217;s not important from Raven&amp;#8217;s perspective, but default MVC UI
(User Interface) template is replaced with something more contemporary. I&amp;#8217;m mentioning it only because this will be partially a topic for soon to be published post on this blog - summary of the modern web-dev tools I&amp;#8217;m using. For now - you can take a look at this really small MVC app and take a look at how pagination is implemented.&lt;/p&gt;

&lt;p&gt;Ok, enough about pagination. When querying you might also use .Where() extension method and limit the result set that will be returned by Raven. Let&amp;#8217;s say out of all of the documents of type &amp;#8216;Person&amp;#8217; you would like to retrieve all of the people that have a first name &amp;#8216;Laura&amp;#8217;. Here&amp;#8217;s how:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Let&amp;#8217;s pick all the Lauras out there&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;lauras&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Laura&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//remember what calling .ToList() does!&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Please keep in mind the code above might or might not yield results when you run it on your computer. When you&amp;#8217;ll be seeding the data using one of the projects in my solution on GitHub - all of the &amp;#8216;Person&amp;#8217; class instances have random values assigned to each of their properties. You might end up with 200+ Lauras or with none at all.
One more thing worth mentioning is that you can also use LINQ syntax when querying RavenDB.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Some sweet LINQ syntax&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;lauras&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Laura&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;               &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="c1"&gt;//at this point no call to Raven has been made!&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fetchedLauras&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lauras&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="c1"&gt;//and now all the Lauras are here&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This sums up basic Querying, in the next few posts about RavenDB I&amp;#8217;ll talk a little bit about small tips and tricks when setting up your local dev environment, how you can profile your application, view logs, monitor traffic and in another post I&amp;#8217;ll be getting to more advanced querying and in following post - indexes. See you soon!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/XO-bm1i6njA" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/02/06/ravendb-tutorial-part-2/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RavenDB tutorial, part 1 - introduction and basic operations]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/LNfMX9F1P7g/" />
    <updated>2012-01-21T18:47:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/01/21/raven-db-tutorial</id>
    <content type="html">&lt;p&gt;When starting new project we (at least lots of my collegues do) tend to automatically think about SQL whilst picking data backend for our application. Or to be honest - we sometimes skip the thinking part, picking SQL is a reflex.
If you only know how to use a hammer, then everything looks like a nail. And then solving any problem automatically means hitting things hard with it (the hammer, not the nail). Credit should go where the credit&amp;#8217;s due and I think one of the benefits of the Ruby/Rails bloom is wider popularity of so-called &amp;#8220;No-SQL&amp;#8221; databases. In R/R world the two most commonly heard names are: MongoDB and CouchDB. If you&amp;#8217;re in doubt what these are - before we get to the subject - enjoy the movie &lt;a href="http://www.youtube.com/watch?v=b2F-DItXtZs"&gt;How No-SQL databases are web-scale&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, that you know everything about things that make No-SQL databases a cool kid on the block, let me take you on the tour of RavenDB - .NET response to No-SQL movement, brought by one and only &lt;a href="https://twitter.com/#!/@ayende"&gt;@ayende&lt;/a&gt;. Without further delay - here we go:&lt;/p&gt;

&lt;p&gt;There are four distinct ways in which you may configure RavenDB to run, all of them begin with downloading Raven binaries (or sources and compiling them yourself). From here you can run RavenDB as a:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Service. You can install Raven service under Windows using command &amp;#8216;Raven.Server.exe /install&amp;#8217; and configure it like any other Service on Windows. Of course later on it can also be uninstalled (Raven.Server.exe /uninstall). For me this is a preferred way of running Raven when I&amp;#8217;m developing on my machine (and hosting production version of the application too). It&amp;#8217;s easy, you don&amp;#8217;t need to do anything else when working on a new project, it doesn&amp;#8217;t use much memory - most of the time circa 30MB&lt;/li&gt;
&lt;li&gt;IIS hosted Web Site with detailed instructions &lt;a href="http://ravendb.net/documentation/docs-deployment-iis"&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Embedded (it will run similarily to .exe mode - but it will automatically start when you start running your application and do something programatically to RavenDB instance.)&lt;/li&gt;
&lt;li&gt;Embedded In Memory - In this mode RavenDB never stores files on your disk, all documents, indexes, etc are created in memory. I personally use it for integration testing,&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Sidenote for the code: There are many, many things you need to take into account when writing your code, even if it seems like it should be a very simple one. For example - initialization of RavenDB in the code can be as simple as two short lines of code (of course, in c# you can make your whole program to fit in one line, I&amp;#8217;m saying about a case where programmer is more or less reasonable), however - question remains where this code should be contained. For simple command-line application - this could be in default Program.cs file, in Main() method, but when considering the topic in the context of e.g. ASP MVC 3 - things quickly tend to get a little more complicated (not because of MVC itself).&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DocumentStore should be used as singleton, however - how you will make sure that it indeed is, is a different story. You could use DI framework, implement your own Singleton and make DocumentStore implementation accessible via property on the instance of the singleton. You could make it public static property on e.g. MvcApplication class (default name for the new ASP MVC application), you could do hundreds of other things to make it happen, some of them not bad, some good, some just horrible&lt;/li&gt;
&lt;li&gt;I&amp;#8217;ve mentioned Singleton pattern - but this however is an issue on its own because a proper singleton implementation is a pretty tricky challenge, Jon Skeet has written up a pretty extensive explanation why - I strongly encourage you to read it &lt;a href="http://csharpindepth.com/Articles/General/Singleton.aspx"&gt;Implementing Singleton in c#&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;When accessing data you need to decide whether in the context of your ASP .NET MVC 3 application it makes any sense to implement some kind of repository, or whether you&amp;#8217;re going to use RavenDB&amp;#8217;s session directly in your controllers. People tend to have pretty strongly formed opinions, with most of them gravitating towards having some kind of repository, however, Ayende (RavenDB&amp;#8217;s project leader and owner of the company which released RavenDB) tends to consider everything in context, and for small application he uses IDocumentSession directly, skipping the repository&lt;/li&gt;
&lt;li&gt;You also need to make IDocumentSession (representing unit of work in RavenDB) available in your classess and it would probably make sense to avoid code duplication when making it happen. No matter if you pick using IDocumentSession directly in your controllers, or hidden from the controller, inside of your implementation of repository, you need to make that decision, implement it, and live with it and maintain it&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Now that we&amp;#8217;ve cleared some basic aspects up, let&amp;#8217;s take a look at some code.
Before we are able to do any CRUD on the db, it needs to be initialized. Initialization, when you&amp;#8217;re using RavenDB hosted as a Service or IIS Web Site can be done with the following code:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;DocumentStore initialization for RavenDB standalone&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;IDocumentStore&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;DocumentStore&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ConnectionStringName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://localhost:8080&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Initialize&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;   
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;and this is how you it&amp;#8217;s done when you want to initialize embedded, in-memory version:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;DocumentStore initialization for RavenDB embedded, in-memory&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;IDocumentStore&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;EmbeddableDocumentStore&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;RunInMemory&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Initialize&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Storing simple entities inside RavenDB is done using Raven&amp;#8217;s Client API and is really straightforward. Let&amp;#8217;s assume you have a following type&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Entities of this class will be persisted in RavenDB:&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Location&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Description&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;Latitude&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;Longitude&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;and then somewhere in the code you create and initialize your entity with following code:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Location class object creation and initialization&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Location&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Wawel castle&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;Description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;The most amazing castle in the whole world&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;Latitude&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;50.05386&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;Longitude&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;19.9353&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;persisting it in RavenDB is dead-simple:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Persisting entity of class Location in RavenDB&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SaveChanges&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;What has been persisted once, now needs to be fetched. This is how we can get our precious Wawel back from Raven:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Getting Wawel back from Raven&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;wawel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Load&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;locations/1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Need to update? It&amp;#8217;s quite simple and similar to what we&amp;#8217;ve just done in previous step&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Updating value of some property on the object stored in RavenDB&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;wawel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Load&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;locations/1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;wawel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;changed description&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SaveChanges&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Something went wrong? Seek and destroy. In one step&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Deleting document from RavenDB&amp;#8217;s store:&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IDocumentSession&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OpenSession&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;wawel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Load&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;locations/1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wawel&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SaveChanges&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;&lt;/p&gt;

&lt;p&gt;We&amp;#8217;ve barely scratched the surface here, but this should be enough to get you started. RavenDB can be downloaded from &lt;a href="http://www.ravendb.net/download"&gt;RavenDB&lt;/a&gt; or installed (and previously automaticaly downloaded) via NuGet (.NET assemblies package manager). In the next post I&amp;#8217;ll take you through some more advanced usages (mostly indexing and querying) and in the post after that one we&amp;#8217;ll take a peek into the source code of one of the serious projects based on RavenDB to find the most interesting usage patterns.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/LNfMX9F1P7g" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/01/21/raven-db-tutorial/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Hack KRK - a place to be for a geek]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/WcEhpnd7HlA/" />
    <updated>2012-01-12T22:17:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/01/12/hack-krk-a-place-to-be</id>
    <content type="html">&lt;p&gt;&lt;img class="center" src="https://lh5.googleusercontent.com/-gz0NCIsRZaY/TxCiqIaI2WI/AAAAAAAAbYQ/_yWyZLvbrAM/s640/IMG_2378.JPG" title="Geeks at work, hacking the hell out of it" alt="Geeks at work, hacking the hell out of it"&gt;&lt;/p&gt;

&lt;p&gt;Thanks to the &lt;a href="http://www.futuresimple.com/"&gt;Future Simple&lt;/a&gt; me and plenty of herd of fellow geeks had a chance to participate in the awesome event devoted to&amp;#8230; hacking! Free beer, food, power supplies, internet. Plenty of creative people packed in a few rooms, hacking the hell out of different technologies. Objective-C, JavaScript, Ruby, Rails, Android and me, proudly representing .NET ;). The event &lt;a href="http://hackkrk.com/"&gt;HackKRK&lt;/a&gt; was the first one and is scheduled to happen monthly -so in case you&amp;#8217;ve missed this one - there will be a chance to get it straight!&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been working (I&amp;#8217;ve started this blog post still sitting there) on a &amp;#8216;Spacerownik&amp;#8217; (&amp;#8216;Guide&amp;#8217;) - a web based application allowing users to browse through the list of the cities, and then walking paths for each of the cities, finally allowing user to pick one route which will then be displayed on screen. One can print a map, pick a location to see additional information about it. Future plans include administration panel for easily adding new routes (based on the import of .gtx files which in turn can be easily created using e.g. Endomondo application for mobile devices and then exporting the route via web interface), displaying additional information about the path, I18n for the whole project and much more.&lt;/p&gt;

&lt;p&gt;After short while a fellow geek - Jakub joined me in my efforts. Interesting thing I&amp;#8217;ve learnt is that some people actually keep Visual Studio opened just to be able to easily build and debug the solution file, while they develop using some more lightweight software (Notepad++, Sublime Text 2 and such). I can&amp;#8217;t imagine my coding without Resharper, it grew on me that much, but I might just want to try doing it this way, just for the sake of trying new things out. Another valuable lesson I&amp;#8217;ve learnt during that night turned out to be a fact you simply can&amp;#8217;t trust git under Windows to take your global .gitignore into account ;). This resulted in bloody bloody mess in our repository. Nevertheless - you can take a look at the code, which we will be hopefully adding gradually, download it and of course fork. Pull requests highly appreciated. It will be built on .NET 4.0, c#, Razor View Engine and &lt;a href="http://ravendb.net/"&gt;RavenDB&lt;/a&gt; as a database. Should you be interested in joining the project - don&amp;#8217;t hesitate contacting me - GitHub repo is here: &lt;a href="https://github.com/geekbeing/Spacerownik"&gt;&amp;#8216;Spacerownik&amp;#8217; on Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get a good feeling of the atmosphere let me just tell you what was on the plate - full Guitar Hero set (forgive my ignorance if I have mistakenly taken some other equipment for GH gear - I&amp;#8217;ve seen computer avatars of musicians on TV, playing on the stage and folks in the kitchen playing on plastic guitar and drums and singing as mad), beer, Red Bulls, tasty and healthy food - all served thanks to hospitality of awesome hosts of the evening - again - thank you all very much. Kudos. I hope our hosts feel proud and that it was worth it. I just can&amp;#8217;t wait for the next Hack KRK!&lt;/p&gt;

&lt;p&gt;As it&amp;#8217;s often said - picture is worth more than a thousand words - here are some more pictures I&amp;#8217;ve taken.&lt;/p&gt;

&lt;p&gt;&lt;img class="center" src="https://lh5.googleusercontent.com/-jzpvtTa-6bE/TxCimDigv9I/AAAAAAAAbYE/AomjtqmgCEw/s640/IMG_2375.JPG" title="Geeks at work, hacking the hell out of it" alt="Geeks at work, hacking the hell out of it"&gt;&lt;/p&gt;

&lt;p&gt;&lt;img class="left" src="https://lh5.googleusercontent.com/-e6hhJ8jU88M/TxCikOXwYzI/AAAAAAAAbYA/qgSZUDbBDfs/s512/IMG_2374.JPG" width="360" height="477" title="Geeks at work, as you can see it was pretty hot" alt="Geeks at work, as you can see it was pretty hot"&gt;&lt;/p&gt;

&lt;p&gt;&lt;img class="right" src="https://lh6.googleusercontent.com/-39SLmt3RK54/TxCiozYmnYI/AAAAAAAAbYM/ekTs2y5Fah0/s512/IMG_2377.JPG" width="360" height="477" title="Geeks at work, projects list" alt="Geeks at work, projects list"&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/WcEhpnd7HlA" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/01/12/hack-krk-a-place-to-be/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Let's get back to business]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/5QUccN5jroY/" />
    <updated>2012-01-08T18:08:00-05:00</updated>
    <id>http://www.geekbeing.com/2012/01/08/lets-get-back-to-business</id>
    <content type="html">&lt;p&gt;I’ve been pretty busy picking topics for posts on the blog, learning (reading &amp;amp; doing) a lot of stuff, so there’s a lot to share in the following months.&lt;/p&gt;

&lt;p&gt;I’ll start you off with a series of post in the following order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;List of the gadgets, techniques, etc. I own and practice and that tremendously help me out learning&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Migrating my blog from &lt;a href="http://wordpress.org/"&gt;Wordpress&lt;/a&gt; to &lt;a href="http://octopress.org/"&gt;Octopress&lt;/a&gt;. This ain&amp;#8217;t over - I tell you that. Content has been migrated, design is the default one for Octopress, but for the first time in the history of my blog I&amp;#8217;m working with professional designer on it&amp;#8217;s layout and look and feel. Expect awesomeness, I might share a thought or two on the process of getting there too.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All the cool kids were having so much fun with rails and document (also called no-sql) databases and making fun of .NET devs they haven&amp;#8217;t noticed the coolest new kid in no-sql department is &lt;a href="http://ravendb.net/"&gt;RavenDB&lt;/a&gt; - expect a few blog posts about Raven coming really soon.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Setup for development I am personally using. Hopefully while worthy tips on the tooling that can help you out with most boring/mundane tasks. This includes not only tools to use on your machine but also online services helping you out a lot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Awesome libraries you can facilitate in your projects. Work smart, don’t reinvent the wheel (unless you deliberately plan to learn this way).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And last but not least - a very long series where I’ll be teaching about the web, http, tcp, web servers, clients, ports, DNS, etc… This will be information passed on from the ground up, so you won’t get lost even if you’re quite new to that stuff. I really hope for this to turn out to something bigger.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;These are those I’ve already gave a lot of thought recently and have drafts prepared and ready to go. Focus might be a little bit more on the OS X side than Windows (in contrary what you might have been used to visiting my blog until now), but don’t jump to the conclusion too soon. I’m not leaving .NET. Not now at least.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/5QUccN5jroY" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2012/01/08/lets-get-back-to-business/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[The comeback]]></title>
    <link href="http://feedproxy.google.com/~r/GeekbeingsRants/~3/uQY4dhS2VDk/" />
    <updated>2011-03-27T18:27:44-04:00</updated>
    <id>http://www.geekbeing.com/2011/03/27/the-comeback</id>
    <content type="html">&lt;p&gt;I hate when people do post about being sorry for not posting for too long and
I had promised myself this would not be the case with me. At the same time
writing about new things and not even mentioning why the break and what was
going on with me for these last few months felt weird. Let&amp;#8217;s make it quick,
get the reasons out of our ways and let&amp;#8217;s focus on the goodies to come. Here&amp;#8217;s
why I wasn&amp;#8217;t blogging for that long&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Too much work. I&amp;#8217;ve been working a lot in my day job and even when I wasn&amp;#8217;t I was still thinking about things that were going on/needed planning/I thought needed my attention. Additionally I was lucky enough to have smart managers who&amp;#8217;ve listened to what I was saying and for the past 3 months I&amp;#8217;ve had a chance to be programming more than previously. But more programming at work means less programming @home, which in turn means less topics to post about.&lt;/li&gt;
&lt;li&gt;Figuring out whether the formula of the blog works. And what does that actually mean it works? Possible answer might be that the results of my work (writing) make me happy. Or that I have a lot of folks coming to my blog. Or that I have you, dear reader, signed up for my RSS feed. At first sight it does not look relevant, but believe me - it is. You gotta weight the balance between feeling fulfilled, trying to be not to controversial (or exactly the opposite) and - let&amp;#8217;s be honest - writing about the topics which return the highest number of hits in Google, for a given query.&lt;/li&gt;
&lt;li&gt;Trying to come to the conclusion - whether the content/look and feel of the blog is good (professional) enough so I could be happy with it and be signing it with my own name. The content actually it&amp;#8217;s what has been worrying me the most - there are some shining examples in my posts (of good engineering) but also, I&amp;#8217;ve committed a few which, to be honest, were written only to fulfill the gaps (write anything). This bugged and hurt me the most, so I needed a time to think it through.&lt;/li&gt;
&lt;li&gt;Too many topics. Yes, that might be an obstacle for blogging too, believe it or not. This is partially related to 3. If I want to keep the quality high enough I need to really spend time on the blog entry. This is research about the subject, this is trials and errors, learning on the mistakes, this is constant battle with the environment, configuration, things which may or may not work for you, dear reader, even though they&amp;#8217;ve perfectly worked for me. And then there&amp;#8217;s writing itself. As you&amp;#8217;re probably instantly aware after coming to my blog, I&amp;#8217;m not a native (English speaker). Writing comes easy, but then I&amp;#8217;m constantly not happy with the result. Bloggers I value the most all have exceptional styles of writing, they make no grammatical mistakes, are funny, smart, etc&amp;#8230; Have all of that what&amp;#8217;s needed to be successful as a blogger. At least that&amp;#8217;s what it means in my mind.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;All of that resulted in me being quiet for a while, but now I think I pulled
myself together. Which means I believe I&amp;#8217;ve figured it (what I&amp;#8217;ll be blogging
about). For me, programming for almost five years, some of the things were a
struggle. One small thing I&amp;#8217;ve missed somewhere on the way and all of the
pieces were falling apart. And then the rubble wouldn&amp;#8217;t let me see what&amp;#8217;s
behind. And then things would pile up and before I knew it there was so much I
didn&amp;#8217;t know. Well, there of course still is, but especially last 2 years were
an exceptional journey for me and I feel I&amp;#8217;ve grown a lot. And so - believing
understanding the basics let&amp;#8217;s you move forward at full speed - that&amp;#8217;s what
I&amp;#8217;ll be doing. Blogging about the basics, in the context of Web.&lt;/p&gt;

&lt;p&gt;Let me elaborate. There&amp;#8217;s a plethora of blogs out there which are short
tutorials - how to call ajax method in jquery, how do I skin GridView (blaaah)
control in ASP .NET, how do I &amp;#8230; (there&amp;#8217;s blog entry for each and every of
such problems). There are also copycats (yak!) - I especially love copying and
pasting parts of help to a given program, or list of shortcuts to an
application, or - God forbid - copy paste of somebody&amp;#8217;s else blog. Do I give a
shit whether there&amp;#8217;s a new ASP .NET MVC release? Maybe I do, but before I got
to one of those dudes blog, I&amp;#8217;ve already read it on Scott Gu&amp;#8217;s. So what I&amp;#8217;ll
be doing in the upcoming blog posts is that I&amp;#8217;m gonna take you for a ride
where you&amp;#8217;ll learn - how does your browser work, how does this happen that you
can enter url in the browsers&amp;#8217; navigation bar and have a given page rendered.
How to use telnet as a browser and what for, how does the web server work, how
you can setup SSL, why doing so, how can you be sure it works? I&amp;#8217;ll include
some posts about the tooling, about setting up the environment, how to use
css, jquery, basic javascript. But in order to avoid repeating when I know
there&amp;#8217;s an awesome post about given topic - I&amp;#8217;m just gonna skip the beat and
simply link to it. It&amp;#8217;s a new DRY and I call it DRAS - Don&amp;#8217;t Repeat After
Someone.&lt;/p&gt;

&lt;p&gt;Hope to seeing you reading my blog soon. Take care&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/GeekbeingsRants/~4/uQY4dhS2VDk" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.geekbeing.com/2011/03/27/the-comeback/</feedburner:origLink></entry>
  
</feed>
