<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>kalv.co.uk</title>
  <id>kalv.co.uk</id>
  <updated>2009-03-10T00:00:00Z</updated>
  <author>
    <name>Kalvir Sandhu</name>
  </author>
  <entry>
    <title>Engaging with early users to learn Habits</title>
    <link href="http://kalv.co.uk/2012/04/12/engaging-with-early-users-to-learn-habits/" rel="alternate"/>
    <id>http://kalv.co.uk/2012/04/12/engaging-with-early-users-to-learn-habits/</id>
    <published>2012-04-12T00:00:00Z</published>
    <updated>2012-04-12T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;As I&amp;rsquo;ve been working to get our startup &lt;a href="http://www.goodbits.co"&gt;Goodbits&lt;/a&gt; up and running I&amp;rsquo;ve been using many different tools to get as much insight on our customers activity. The one tool that I&amp;rsquo;ve been using the most has been &lt;a href="http://www.kissmetrics.com"&gt;Kissmetrics&lt;/a&gt; which has allowed me to look at specific events or actions that a user carried out on the site. Making it far more useful than the popular choice of &lt;a href="http://google.com/analytics"&gt;Google Analytics&lt;/a&gt; or similar&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;As I&amp;rsquo;ve been working to get our startup &lt;a href="http://www.goodbits.co"&gt;Goodbits&lt;/a&gt; up and running I&amp;rsquo;ve been using many different tools to get as much insight on our customers activity. The one tool that I&amp;rsquo;ve been using the most has been &lt;a href="http://www.kissmetrics.com"&gt;Kissmetrics&lt;/a&gt; which has allowed me to look at specific events or actions that a user carried out on the site. Making it far more useful than the popular choice of &lt;a href="http://google.com/analytics"&gt;Google Analytics&lt;/a&gt; or similar.&lt;/p&gt;

&lt;p&gt;It has been very important to learn what daily habits our users are carrying out, so the better information I can compile the better I can deduce common usage patterns that I have to improve and refine. Check out &lt;a href="http://www.nirandfar.com/2012/04/hooking-users-in-3-steps.html?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+NirAndFar+%28Nir+and+Far+Blog%29"&gt;this post from Nir&lt;/a&gt; which is an interesting read on Habit forming.&lt;/p&gt;

&lt;p&gt;Now there is a new kid on the block and I&amp;rsquo;m loving it. &lt;a href="http://intercom.io"&gt;Intercom&lt;/a&gt;, a web app that is a CRM (Customer Relationship Management) Tool on my customers with some serious powerful features.&lt;/p&gt;

&lt;h2&gt;How it works&lt;/h2&gt;

&lt;p&gt;Like with most of these services, you drop in a javascript snippet into your application and then set a bunch of settings, the email address of your signed in user, etc. By default Intercom then records information like &amp;lsquo;signed up&amp;rsquo;, &amp;lsquo;last seen at&amp;rsquo;, the number of &amp;lsquo;sessions&amp;rsquo; &amp;amp; then looks up more information on that customer.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var intercomSettings = {
  app_id: 'app_id',
  email: 'john.doe@example.com', // TODO: User's e-mail address
  created_at: 1234567890, // TODO: User's sign-up date, Unix timestamp
  name: 'John Doe'
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The added lookup on information is that it uses &lt;a href="http://www.fullcontact.com/"&gt;FullContact&lt;/a&gt; to link to their social media profiles, this gives you better insight of the type of user they are.  It&amp;rsquo;s great, with a couple of clicks I can see what field this customer works in, how interactive they are with certain social media tools and better understand the types of customers we have using our product.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&amp;ldquo;Whoa, this feels like getting a message from God&amp;rdquo;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;It doesn&amp;rsquo;t stop there, the interface is very well designed allowing me to filter by data stored for a user and then &lt;strong&gt;message&lt;/strong&gt; them, yep message them. Either directly so that when they next use my site a popup would appear or through email.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve always hated spam messages from an app I use, this filtering allows me to target specific behavior and I have seen that users engage back with us more than they would with a generic mail shot from &lt;a href="http://mailchimp.com/"&gt;MailChimp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have more confidence that they will engage back with me. Intercom have a column in their app with a &lt;strong&gt;heart&lt;/strong&gt; in it for relationship.&lt;/p&gt;

&lt;h2&gt;Getting more from Intercom&lt;/h2&gt;

&lt;p&gt;You can also add custom information to intercom, which then allows you to further filter your users.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var intercomSettings = {
  // .. add this
  custom_data: {
    'invites sent': 4,
    'has added twitter service': true,
    'number of sections created': 5
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This can be quite intensive on your to render this data out on every request, so instead of caching it, I am posting this data in a scheduled task hourly using their API and &lt;a href="https://github.com/intercom/intercom-ruby"&gt;Rubygem&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Auto Messaging&lt;/h2&gt;

&lt;p&gt;You can now set up filters and then create an auto message which be sent out to customers that fall into that filter.  I am using this for some great scenarios, ones where I&amp;rsquo;ve before written manual code to fire emails.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ask users why they haven&amp;rsquo;t come back to our application after a period of time to better understand what it is we&amp;rsquo;re not doing right&lt;/li&gt;
&lt;li&gt;Send targeted messages describing what they can do with our tool that they haven&amp;rsquo;t already enabled and if they didn&amp;rsquo;t use those features, why.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Constantly improving&lt;/h2&gt;

&lt;p&gt;They are adding improvements all the time, I wanted auto messages and it was something they released. I wanted to use my custom data in generated messages, deployed and notified. I wanted to easily see the number of emails being sent from their auto messages features, they updated the interface and deployed it. This reaction to customer needs is what I try to do with products I work on, so using a tool that do this for me, is satisfying.&lt;/p&gt;

&lt;p&gt;I decided to write this post because Intercom is starting to become a must have for me in building web products. It&amp;rsquo;s starting point in reviewing analytics is great, the customer.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>How a Ruby guy decided to add node.js to the mix</title>
    <link href="http://kalv.co.uk/2012/01/17/how-a-ruby-guy-decided-to-add-nodejs-to-the-mix/" rel="alternate"/>
    <id>http://kalv.co.uk/2012/01/17/how-a-ruby-guy-decided-to-add-nodejs-to-the-mix/</id>
    <published>2012-01-17T00:00:00Z</published>
    <updated>2012-01-17T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;rsquo;ve been a Ruby guy for over 4 years now and have always found the language fun and the frameworks suitable for building web based applications, I love it.&lt;/p&gt;

&lt;p&gt;Since the release of &lt;a href="http://nodejs.org"&gt;Node.js&lt;/a&gt; in 2009, I and my colleagues at
&lt;a href="http://www.gofreerange.com"&gt;GoFreeRange&lt;/a&gt; were very excited about the
event loop, non-blocking IO goodness for scalability and speed on the
web. We had even played on something to help&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;rsquo;ve been a Ruby guy for over 4 years now and have always found the language fun and the frameworks suitable for building web based applications, I love it.&lt;/p&gt;

&lt;p&gt;Since the release of &lt;a href="http://nodejs.org"&gt;Node.js&lt;/a&gt; in 2009, I and my colleagues at
&lt;a href="http://www.gofreerange.com"&gt;GoFreeRange&lt;/a&gt; were very excited about the
event loop, non-blocking IO goodness for scalability and speed on the
web. We had even played on something to help
&lt;a href="https://github.com/freerange/nodetest"&gt;testing&lt;/a&gt; (was only for a day, just to learn more about the tech).&lt;/p&gt;

&lt;p&gt;So I&amp;rsquo;ve been looking for the right time to start developing a real
application that benefits from what Node.js has to offer over what I can
do quickly and efficiently in Ruby.&lt;/p&gt;

&lt;p&gt;I have yet to see an API or website
really need the scalability or speed offered by node.js over what I know
with ruby, so I&amp;rsquo;ve always chosen to use what I know, has good
conventions and good maintainability.&lt;/p&gt;

&lt;p&gt;But last week the time finally arrived where Node.js might be a better
fit.&lt;/p&gt;

&lt;p&gt;This won&amp;rsquo;t be a post outlining benchmark metrics but just an overview of
my findings and how I settled on Node.js for this specific need.&lt;/p&gt;

&lt;h2&gt;The problem&lt;/h2&gt;

&lt;p&gt;Our feed checking mechanism at &lt;a href="http://rsshero.com"&gt;RSS Hero&lt;/a&gt; was built
using &lt;a href="https://github.com/defunkt/resque"&gt;Resque&lt;/a&gt; so that we could fetch
multiple feeds and check them (making sure they are a feed). Then to
subscribe with &lt;a href="http://superfeedr.com"&gt;Superfeedr&lt;/a&gt; if successful.&lt;/p&gt;

&lt;p&gt;This process was not fast enough for fetching lots of feeds, I found
that activating a couple of users that each had 1000 subscriptions or so,
it would stack up and take quite a while to churn through.&lt;/p&gt;

&lt;p&gt;Even though I could increase the number of resque workers running in parallel I would end up using more memory on our limited production servers.&lt;/p&gt;

&lt;p&gt;HTTP feed fetching is going to increase, one of our upcoming milestones
is to take load away from superfeedr and fetch some feeds ourselves.&lt;/p&gt;

&lt;h2&gt;Proposed Solutions&lt;/h2&gt;

&lt;p&gt;To make this faster I needed to use less memory and be able to fetch
multiple HTTP requests in parallel.  The shortlist that I came up with was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://rubyeventmachine.com/"&gt;Eventmachine&lt;/a&gt; &amp;amp;
&lt;a href="https://github.com/igrigorik/em-http-request"&gt;em-http-request&lt;/a&gt; &amp;ndash; A ruby event loop allowing async processing&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/dbalatero/typhoeus"&gt;Typhoeus&lt;/a&gt; &amp;ndash; Http fetching using curb (curl)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nodejs.org"&gt;Node.js&lt;/a&gt; &amp;ndash; event driven, non-blocking IO&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So to figure out which was best I set a time box of &amp;frac12; day to spike on each method and learn about them.&lt;/p&gt;

&lt;p&gt;With each test setup I used &lt;a href="http://redis.io/topics/pubsub"&gt;Redis
pubsub&lt;/a&gt; to push urls to be fetched onto a channel and have the fetching code consume that channel.  This would allow easy integration from the existing rails app.&lt;/p&gt;

&lt;p&gt;Also to remove bandwidth fluctuations from my ISP I ran the tests on a
&lt;a href="http://www.linode.com/"&gt;Linode&lt;/a&gt; server.&lt;/p&gt;

&lt;h2&gt;Eventmachine&lt;/h2&gt;

&lt;p&gt;This was my first choice and I believed it would be good enough for our
needs.  I would be able to use my existing tested ruby code for the feed
checking and connect it to redis.&lt;/p&gt;

&lt;p&gt;The first issue and main one was eventmachine kept on stalling.  When
the sample data was loaded, the compatible redis library
(&lt;a href="https://github.com/mloughran/em-hiredis"&gt;em-hiredis&lt;/a&gt;) would read off
all the messages off the pubsub channel and kick off http requests,
responses then stopped after the first 100 requests.&lt;/p&gt;

&lt;p&gt;I thought it might be an issue with trying to send too many requests at
one time. So I tried using &lt;a href="https://github.com/igrigorik/em-synchrony"&gt;em-synchrony&lt;/a&gt; which is a lovely library to allow synchronous control in the event loop, but it stopped the async nature of the http requesting so slowed it back down.&lt;/p&gt;

&lt;p&gt;To better manage the concurrency I then tried to store the received urls from redis into a shared
variable and then poll that collection (EM::PeriodicTimer) and only fire
off a limited amount of http requests. This worked well until 300-400
requests were sent, again eventmachine stalled for a 1-5 secs and then
came back again.&lt;/p&gt;

&lt;p&gt;After spending a bit of time debugging and digging into my limited
knowledge of Eventmachine and em-http I couldn&amp;rsquo;t see what was happening. All I could
see was that the event loop was not &amp;lsquo;ticking&amp;rsquo;, the timer was not firing
so maybe something had blocked the IO loop. Using 1000 requests to a
localhost web address worked fine, so maybe it was something in the
network layer, maybe an address not returning, DNS hanging. I did find
evidence to show that the HTTP Connection was &lt;a href="https://github.com/igrigorik/em-http-request/blob/master/lib/em-http/http_connection.rb#L75"&gt;not fully
asynchronous&lt;/a&gt; so
perhaps one or a couple of network connections were blocking.&lt;/p&gt;

&lt;p&gt;I fiddled with adding timeout settings to the http request but nothing
stopped hitting this stall.&lt;/p&gt;

&lt;p&gt;With my limited time for this spike and this stability issue I moved on.&lt;/p&gt;

&lt;h2&gt;Typhoeus&lt;/h2&gt;

&lt;p&gt;I have used curb before for fast feed fetching at
&lt;a href="http://twitterfeed.com"&gt;Twitterfeed&lt;/a&gt;, where I used a modified
&lt;a href="https://github.com/kalv/feedzirra"&gt;feedzirra&lt;/a&gt; that allowed multiple http feed fetching, this worked very well at the time.&lt;/p&gt;

&lt;p&gt;Comparing this though to the speed I was getting with Eventmachine it
was slow, a fire off of 10 http requests would still wait for them all
to return, which was too slow.&lt;/p&gt;

&lt;p&gt;Again I had to manage my own concurrency when reading urls to be fetched
from redis.&lt;/p&gt;

&lt;p&gt;This being too slow, I moved on to node.js.&lt;/p&gt;

&lt;h2&gt;Node.js&lt;/h2&gt;

&lt;p&gt;Already knowing javascript, I got it running pretty quickly and the
responses came through fast. I can&amp;rsquo;t say exactly but it responses for
for the first hundre came through a lot quicker and it stayed
consistently fast.&lt;/p&gt;

&lt;p&gt;I didn&amp;rsquo;t have to worry about concurrency control, internally node.js
seemed to manage and handle the requests fine.&lt;/p&gt;

&lt;p&gt;I had to write my own code to handle redirects and to put a cap on how
many to follow before throwing an exception as I was using the http
request library included in Node.js.&lt;/p&gt;

&lt;p&gt;The results from the little testing on Node.js was amazing. It felt
solid and fast. This was enough for me to take the plunge and deploy
some node.js.&lt;/p&gt;

&lt;h2&gt;To Summarize&lt;/h2&gt;

&lt;p&gt;I chose to use node.js because it was faster, stable and used a lower
memory footprint on my server.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rsshero.com"&gt;RSS Hero&lt;/a&gt; is now using node.js for it&amp;rsquo;s http
fetching and memory usage has reduced from 400mb of RAM to 20mb and it&amp;rsquo;s a lot faster.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Turn off annoying Skype auto gain</title>
    <link href="http://kalv.co.uk/2011/11/24/turn-off-annoying-skype-auto-gain/" rel="alternate"/>
    <id>http://kalv.co.uk/2011/11/24/turn-off-annoying-skype-auto-gain/</id>
    <published>2011-11-24T00:00:00Z</published>
    <updated>2011-11-24T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;If you like me use Skype quite bit for calls or coding together with
other developers, you might find that when you&amp;rsquo;re quiet Skype tries to be
clever and automatically increase the microphone gain.  This is crap as
it starts to pick up the background noise.&lt;/p&gt;

&lt;p&gt;You can&amp;rsquo;t easily turn off automatic gain control in Skype, it&amp;rsquo;s a
setting you can apply in a xml file.  Hunting around I found the
solution again and this time I&amp;rsquo;ve stuck in a gist in case you want to&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;If you like me use Skype quite bit for calls or coding together with
other developers, you might find that when you&amp;rsquo;re quiet Skype tries to be
clever and automatically increase the microphone gain.  This is crap as
it starts to pick up the background noise.&lt;/p&gt;

&lt;p&gt;You can&amp;rsquo;t easily turn off automatic gain control in Skype, it&amp;rsquo;s a
setting you can apply in a xml file.  Hunting around I found the
solution again and this time I&amp;rsquo;ve stuck in a gist in case you want to
try it too.  Try it, even if you have a headset with a microphone built
in, this makes a difference.&lt;/p&gt;

&lt;script src="https://gist.github.com/1391982.js?file=gistfile1.txt"&gt;&lt;/script&gt;

</content>
  </entry>
  <entry>
    <title>Learning Ruby / Rails</title>
    <link href="http://kalv.co.uk/2011/11/23/learning-ruby--rails/" rel="alternate"/>
    <id>http://kalv.co.uk/2011/11/23/learning-ruby--rails/</id>
    <published>2011-11-23T00:00:00Z</published>
    <updated>2011-11-23T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;rsquo;m often asked about where to go and what to read to learn
about Rails.  In fact just the other day, so I&amp;rsquo;m going to outline some
details here so to not repeat myself in the future or even forget!  This
is not a definitive guide but rather some links to things you should
read and think about.&lt;/p&gt;

&lt;h2&gt;Learn Ruby&lt;/h2&gt;

&lt;p&gt;Sure you can go on right ahead and start with Rails and start building a
web application but if you&amp;rsquo;re unfamilar with Ruby then please take the&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;rsquo;m often asked about where to go and what to read to learn
about Rails.  In fact just the other day, so I&amp;rsquo;m going to outline some
details here so to not repeat myself in the future or even forget!  This
is not a definitive guide but rather some links to things you should
read and think about.&lt;/p&gt;

&lt;h2&gt;Learn Ruby&lt;/h2&gt;

&lt;p&gt;Sure you can go on right ahead and start with Rails and start building a
web application but if you&amp;rsquo;re unfamilar with Ruby then please take the
time to learn the basics, it will help considerably.&lt;/p&gt;

&lt;p&gt;There are quite a few places you could learn about Ruby, books being one
of them, here are some of my favourites.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Why's_(poignant"&gt;why&amp;rsquo;s (poignant) Guide to
Ruby&lt;/a&gt;_Guide_to_Ruby)
This is a different kind of programming book, it&amp;rsquo;s distributed
under Creative Commons and has some interestig cartoon graphics to go
through Ruby.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://rubykoans.com/"&gt;Ruby Koans&lt;/a&gt; Created by &lt;a href="http://twitter.com/jimweirich"&gt;Jim
Weirich&lt;/a&gt; and
&lt;a href="http://twitter.com/objo"&gt;Joe O'Brien&lt;/a&gt; this is a hands on way to learn
more about Ruby it&amp;rsquo;s a test driven approach for you to learn Ruby&amp;rsquo;s
internals.  I myself still use these tests to remind me or even learn
about things I didn&amp;rsquo;t know about.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Test Ruby&lt;/h2&gt;

&lt;p&gt;Most guides on the web don&amp;rsquo;t include tests.  And what I mean about tests
is using &lt;a href="http://rspec.info/"&gt;rspec&lt;/a&gt;, &lt;a href="http://www.ruby-doc.org/stdlib-1.9.2/libdoc/test/unit/rdoc/Test/Unit.html"&gt;test unit&lt;/a&gt;, &lt;a href="http://cukes.info/"&gt;cucumber&lt;/a&gt; to progamatically test your
application.  Not having someone click through the site or pages.  The
importance of testing isn&amp;rsquo;t directly required to learning about ruby or
rails BUT will help you in understanding what&amp;rsquo;s going on (like the Ruby
Koans) and get you into a good practise when developing your application.&lt;/p&gt;

&lt;h2&gt;Rails&lt;/h2&gt;

&lt;p&gt;To learn about the rails framework and it&amp;rsquo;s make up check out these
sources, there are some great screencasts you can now watch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://peepcode.com"&gt;Peepcode&lt;/a&gt; &amp;ndash; Is paid but worth it. Even watching some of the
play by play is a good watch to see how others work.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://railscasts.com"&gt;Railscasts&lt;/a&gt; &amp;ndash; Very good free and now has pro content on how to do
common things in rails. Has good screencasts on commonly used gems
that enhances rails.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://guides.rubyonrails.org/"&gt;Rails Guides&lt;/a&gt; &amp;ndash; is a good source of
information too on the rails framework.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;News and updates&lt;/h2&gt;

&lt;p&gt;I found it helpful to follow some sources for updates
on what gems are out there or new gems that do something clever.  Here are some that I
followed for this and still do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://rubyflow.com"&gt;RubyFlow&lt;/a&gt; &amp;ndash; a good source for new information on Ruby/Rails&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ruby5.envylabs.com/"&gt;Ruby5 Podcast&lt;/a&gt; &amp;ndash; I used to listen to listen to podcasts quite a bit when I had time, but have stopped now. Give it a go, sometimes it quite good to hear discussion on implementation decisions and justificiation on gem use.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pivotallabs.com/blabs"&gt;Pivotal Blabs&lt;/a&gt; &amp;ndash; This is a blog ran by Pivotal Labs where they
share great little tips from their standups.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Edit:&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;@taylorbuley &lt;a href="https://twitter.com/#!/taylorbuley/status/139389431919546368"&gt;comments on
twitter&lt;/a&gt;
to see also &lt;a href="http://codeacademy.com/#!/exercise/0"&gt;Codeacademy.com&lt;/a&gt;
which seems to be for learning javascript &amp;ndash; might eventually have
some Ruby, still worth a look if you want to understand javascript.&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  <entry>
    <title>Making Textmate play nice with RVM</title>
    <link href="http://kalv.co.uk/2011/07/27/making-textmate-play-nice-with-rvm/" rel="alternate"/>
    <id>http://kalv.co.uk/2011/07/27/making-textmate-play-nice-with-rvm/</id>
    <published>2011-07-27T00:00:00Z</published>
    <updated>2011-07-27T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;I finally sat down for a while this morning to get &lt;a href="https://rvm.beginrescueend.com/"&gt;RVM&lt;/a&gt; working well with &lt;a href="http://macromates.com/"&gt;Textmate&lt;/a&gt; ruby running commands.  Whilst pairing with the team at &lt;a href="http://gofreerange.com"&gt;GoFreeRange&lt;/a&gt; we tend to stay in Textmate, write tests and then run them from there.  But recently using RVM and .rvmrc config files within 1.9.2 projects we haven&amp;rsquo;t been able to get the tests to run&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I finally sat down for a while this morning to get &lt;a href="https://rvm.beginrescueend.com/"&gt;RVM&lt;/a&gt; working well with &lt;a href="http://macromates.com/"&gt;Textmate&lt;/a&gt; ruby running commands.  Whilst pairing with the team at &lt;a href="http://gofreerange.com"&gt;GoFreeRange&lt;/a&gt; we tend to stay in Textmate, write tests and then run them from there.  But recently using RVM and .rvmrc config files within 1.9.2 projects we haven&amp;rsquo;t been able to get the tests to run.&lt;/p&gt;

&lt;p&gt;To make it easier than creating a &lt;a href="https://rvm.beginrescueend.com/integration/textmate/"&gt;textmate rvm wrapper&lt;/a&gt;, I run rvm so that it sets up the right ruby and paths.  Then check if there is a &lt;code&gt;.rvmrc&lt;/code&gt; and take that into account.&lt;/p&gt;

&lt;p&gt;I add these two lines to any Textmate commands (Bundles &amp;ndash;&gt; Bundle Editor &amp;ndash;&gt; Edit Commands&amp;hellip;) for example the &lt;code&gt;Ruby -&amp;gt; Run&lt;/code&gt; command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[[ -f "$HOME/.rvm/scripts/rvm" ]] &amp;amp;&amp;amp; . "$HOME/.rvm/scripts/rvm"
[[ -f "$TM_PROJECT_DIRECTORY/.rvmrc" ]] &amp;amp;&amp;amp; . "$TM_PROJECT_DIRECTORY/.rvmrc"
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <title>Small things I like about HTML 5</title>
    <link href="http://kalv.co.uk/2011/06/14/small-things-i-like-about-html-5/" rel="alternate"/>
    <id>http://kalv.co.uk/2011/06/14/small-things-i-like-about-html-5/</id>
    <published>2011-06-14T00:00:00Z</published>
    <updated>2011-06-14T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;Most people are talking about the big things that HTML 5 is bringing to the table, video, audio, Websockets APIs, etc. I thought I&amp;rsquo;d share a small selection of the small attributes that I&amp;rsquo;ve used so far.&lt;/p&gt;

&lt;h3&gt;the placeholder attribute&lt;/h3&gt;

&lt;p&gt;You can now add the placeholder attribute on form input elements. This will then display the text until the user provides focus to the input element.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;input type="text" placeholder="Enter your email address"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</summary>
    <content type="html">&lt;p&gt;Most people are talking about the big things that HTML 5 is bringing to the table, video, audio, Websockets APIs, etc. I thought I&amp;rsquo;d share a small selection of the small attributes that I&amp;rsquo;ve used so far.&lt;/p&gt;

&lt;h3&gt;the placeholder attribute&lt;/h3&gt;

&lt;p&gt;You can now add the placeholder attribute on form input elements. This will then display the text until the user provides focus to the input element.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;input type="text" placeholder="Enter your email address"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Wow this has made things so much easier. No more extra javascript to remove the value when clicked and then put it back when the user clicks away and it&amp;rsquo;s empty, blah di blah.&lt;/p&gt;

&lt;h3&gt;email input type&lt;/h3&gt;

&lt;p&gt;To better improve what I wrote above, you can now define an email type on input elements. Allowing mobile browsers to show a different keyboard for those elements.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;input type="email" placeholder="Enter your email address"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There are more wonderful attributes to provide browsers with better information on what needs to be entered like &amp;lsquo;min&amp;rsquo; and &amp;lsquo;step&amp;rsquo; for &amp;lsquo;number&amp;rsquo; type input elements. All good stuff, it&amp;rsquo;s great to see browsers implementing more behaviour on the structure of webpages.&lt;/p&gt;

&lt;h3&gt;the cache manifest&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE HTML&amp;gt;
&amp;lt;html manifest="/cache.manifest"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Test&amp;lt;/title&amp;gt;
    &amp;lt;script src="application.js"&amp;gt;&amp;lt;/script&amp;gt;
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Offline web pages made simple. Simply add the manifest attribute to html pointing to a web served file. This will setup which files will be available offline. So for this example a file &amp;lsquo;cache.manifest&amp;rsquo; would be created.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;CACHE MANIFEST 
/application.js
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can even define what is required for network access or even just point to an offline page. Nice.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;CACHE MANIFEST
FALLBACK:
/ /offline.html
NETWORK:
*
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This file has to be served as type &amp;lsquo;text/cache-manifest&amp;rsquo;. Read more on cache manifest at  &lt;a href="http://diveintohtml5.org/offline.html"&gt;diveintohtml5.org&lt;/a&gt;. If you use Ruby checkout &lt;a href="https://github.com/wycats/rack-offline"&gt;Rack::Offline&lt;/a&gt; to help manage your offline files.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Fastest Ruby RSS Parser?</title>
    <link href="http://kalv.co.uk/2010/12/10/fastest-ruby-rss-parser/" rel="alternate"/>
    <id>http://kalv.co.uk/2010/12/10/fastest-ruby-rss-parser/</id>
    <published>2010-12-10T00:00:00Z</published>
    <updated>2010-12-10T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;I was working on a project the other day that needed to parse a lot of RSS feeds and would need to poll &amp;amp; parse them frequently. So once again I had the question &amp;lsquo;which ruby rss parser should i use?&amp;rsquo; in my mind.&lt;/p&gt;

&lt;p&gt;Back when I was working for &lt;a href="http://twitterfeed.com"&gt;twitterfeed&lt;/a&gt; we performed some testing to find the optimal library that could fetch and parse the feeds fast. It was found then that &lt;a href="https://github.com/pauldix/feedzirra"&gt;Feedzirra&lt;/a&gt; performed the best as you could use a multiple fetch using &lt;a href="http://curb.rubyforge.org/"&gt;curb&lt;/a&gt;&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I was working on a project the other day that needed to parse a lot of RSS feeds and would need to poll &amp;amp; parse them frequently. So once again I had the question &amp;lsquo;which ruby rss parser should i use?&amp;rsquo; in my mind.&lt;/p&gt;

&lt;p&gt;Back when I was working for &lt;a href="http://twitterfeed.com"&gt;twitterfeed&lt;/a&gt; we performed some testing to find the optimal library that could fetch and parse the feeds fast. It was found then that &lt;a href="https://github.com/pauldix/feedzirra"&gt;Feedzirra&lt;/a&gt; performed the best as you could use a multiple fetch using &lt;a href="http://curb.rubyforge.org/"&gt;curb&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For now I only wanted to know how fast these libraries would just parse the feeds, I was not worried about the http fetching.&lt;/p&gt;

&lt;p&gt;I had some time so I returned to a nice performance test suite created by &lt;a href="https://github.com/julien51"&gt;Julien Genestoux&lt;/a&gt; of &lt;a href="http://superfeedr.com/"&gt;Superfeedr&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I forked the suite, updated it to use bundler, order the results and to use the latest gems and then re-ran the performance test. You can find my fork &lt;a href="https://github.com/kalv/ruby-feed-parser-benchmark"&gt;here&lt;/a&gt; if you are interested.&lt;/p&gt;

&lt;p&gt;The results were (ran on my macbook pro 2.53ghz, 4gb ram, SSD):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ruby feed-parser-bench.rb 1000

feedzirra =&amp;gt; Average: 0.0278322427572428 (0 errors) RSS: 0.0260872052845528 Atom: 0.0295189980353635
mrss =&amp;gt; Average: 0.042981384305835 (7 errors) RSS: 0.039129512244898 Atom: 0.0467262599206349
syndication =&amp;gt; Average: 0.0495069849548646 (4 errors) RSS: 0.0398204020408163 Atom: 0.0588687712031558
rfeedparser =&amp;gt; Average: 0.452556951048951 (0 errors) RSS: 0.389084115853658 Atom: 0.513909868369352
simplerss =&amp;gt; Average: 1.29865328871129 (0 errors) RSS: 0.20822887195122 Atom: 2.35265881532417
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The result was simple &amp;ndash; Feedzirra was still the fastest.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Playing with Macvim</title>
    <link href="http://kalv.co.uk/2010/11/29/playing-with-macvim/" rel="alternate"/>
    <id>http://kalv.co.uk/2010/11/29/playing-with-macvim/</id>
    <published>2010-11-29T00:00:00Z</published>
    <updated>2010-11-29T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;I have been spending some time over the last week of so with macvim. Thought I&amp;rsquo;d share my experiences so far.&lt;/p&gt;

&lt;h3&gt;Why&lt;/h3&gt;

&lt;p&gt;I wanted to play around with VIM again really, one day a team member reminded me of the &amp;lsquo;c-w&amp;rsquo; vim command when working on a server (it clears the word from the start of it). At this point I remembered the power that vim has and I wanted to get back to that and see if it would make it easier for me to edit and write code&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I have been spending some time over the last week of so with macvim. Thought I&amp;rsquo;d share my experiences so far.&lt;/p&gt;

&lt;h3&gt;Why&lt;/h3&gt;

&lt;p&gt;I wanted to play around with VIM again really, one day a team member reminded me of the &amp;lsquo;c-w&amp;rsquo; vim command when working on a server (it clears the word from the start of it). At this point I remembered the power that vim has and I wanted to get back to that and see if it would make it easier for me to edit and write code.&lt;/p&gt;

&lt;p&gt;I also felt a frustration when moving from keyboard to mouse. Could I be as productive and not have to touch the mouse (perhaps still use to explore around a project directories).&lt;/p&gt;

&lt;p&gt;Some people could argue these pains might not be enough to justify switching or spending the time to learn a new tool. I just thought I&amp;rsquo;d give it a try, I can always switch back to my long time home &lt;a href="http://macromates.com/"&gt;textmate&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Setting it up&lt;/h3&gt;

&lt;p&gt;I simply installed macvim through &lt;a href="https://github.com/mxcl/homebrew"&gt;homebrew&lt;/a&gt; &lt;code&gt;brew install macvim&lt;/code&gt;. If you don&amp;rsquo;t use homebrew to manage your packages on your mac, i seriously advise you to look into it.&lt;/p&gt;

&lt;p&gt;Once that was installed I installed the color &lt;a href="http://blog.infinitered.com/entries/show/8"&gt;IR_Black_theme&lt;/a&gt; to make it look a bit prettier than the default (I prefer dark backgrounds).&lt;/p&gt;

&lt;p&gt;I pulled parts of the &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.gvimrc&lt;/code&gt; from this &lt;a href="https://github.com/railsjedi/vimconfig"&gt;repo from railsjedi&lt;/a&gt; (found by just searching github for macvim).&lt;/p&gt;

&lt;p&gt;The main plugins I installed were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ack.vim&lt;/code&gt;: Allows me to search the project using ack, similar to AckMate. To use it in vim I would &lt;code&gt;:Ack search_for_this&lt;/code&gt;, i have now setup a mapping for my lead key and character (a shortcut really to the command)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bufexplorer.vim&lt;/code&gt;: This is a neat way to browse what files you have open in the buffer. I use this with a lead key shortcut too. Allowing quick switching files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rails.vim&lt;/code&gt;: A rails plugin that really I find the syntax highlighting helpful, it does provide other things but i haven&amp;rsquo;t used them much.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;A note on NERDTree, I started using this plugin which helps with directory navigating. But dropped it to use the included netrw in vim, it seems to do everything I need for now and thought it best to learn as much of the real tool as possible.&lt;/p&gt;

&lt;p&gt;So on to the findings.&lt;/p&gt;

&lt;h3&gt;:( Go to File / Peepopen&lt;/h3&gt;

&lt;p&gt;The first thing that became apparent was not having a &lt;code&gt;Go to File&lt;/code&gt;, the Command-T option that would list the files in your directories and allow you to quickly go to a file.&lt;/p&gt;

&lt;p&gt;I have been using &lt;a href="http://peepcode.com/products/peepopen"&gt;peepopen&lt;/a&gt; in textmate for this and it works with macvim! You simply switch the editor and reload, works really easily.&lt;/p&gt;

&lt;h3&gt;:) Love split screen&lt;/h3&gt;

&lt;p&gt;Splitting the code on a 23" screen helps for both showing test with code and view with controllers/models. I think this is a preference thing, I myself like it. Even when just learning new code from a project having the ability to have multiple windows makes it easier.&lt;/p&gt;

&lt;h3&gt;&lt;em&gt;:)&lt;/em&gt; Shortcuts for text and visual mode&lt;/h3&gt;

&lt;p&gt;To remove and move text with commands on the keyboard is probably the most thing i&amp;rsquo;ve used. Having the ease to delete to the end of line and start writing, delete just the word or a couple and then having the visual mode helps too. Sure there is shift select in textmate for visual mode, but holding down the shift sometimes (not all) is annoying.&lt;/p&gt;

&lt;h3&gt;:( Running tests&lt;/h3&gt;

&lt;p&gt;When in a rails project using textmate I would always run a focussed test and window popup would open. With the vim setup I haven&amp;rsquo;t found an easy way to do this. I have to switch to a terminal and run the test: &lt;code&gt;ruby -Itest test/blah -n '/the test to focus on/'&lt;/code&gt;. This slows things down a little by only the fact that running a new focussed test means writing out the matcher, obviously repeating a test is quick, just means alt-tab, up and bang to run the command again.&lt;/p&gt;

&lt;h3&gt;:( No markdown preview&lt;/h3&gt;

&lt;p&gt;Recently I&amp;rsquo;ve found myself writing more markdown and liked the ability to preview the page in textmate. Haven&amp;rsquo;t really looked if there is anything nice for vim on this.&lt;/p&gt;

&lt;h3&gt;:( Esc to complete&lt;/h3&gt;

&lt;p&gt;I barely used this in textmate, but have found myself wanting it now and then. It autocompleted the word you were writing when you pressed esc.&lt;/p&gt;

&lt;h3&gt;:/ To tab or not tab.&lt;/h3&gt;

&lt;p&gt;I&amp;rsquo;m finding it hard to decide on whether to open files in multiple tabs or to just switch between the buffers, this just get&amp;rsquo;s messy that&amp;rsquo;s all, i will eventually figure it out.&lt;/p&gt;

&lt;h3&gt;:) Even more fun to code&lt;/h3&gt;

&lt;p&gt;Learning something new with vim is fun and adds to the fun of doing the work I do. So for me this is a plus.&lt;/p&gt;

&lt;h3&gt;:) Remote developing.&lt;/h3&gt;

&lt;p&gt;I love the potential of using vim not just the macvim version on remote machines for pair development or even lightweight client&amp;rsquo;s being able to develop by using a remove machine having components installed (ipad for example).&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;I&amp;rsquo;m going to continue using Macvim, as I&amp;rsquo;m loving what you can do to the text in visual mode and the ability to delete and move lines/words around on the keyboard.&lt;/p&gt;

&lt;p&gt;What do you think? Would you try or already use Macvim? Have any tipes?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>LRUG talk on websockets</title>
    <link href="http://kalv.co.uk/2010/11/10/lrug-talk-on-websockets/" rel="alternate"/>
    <id>http://kalv.co.uk/2010/11/10/lrug-talk-on-websockets/</id>
    <published>2010-11-10T00:00:00Z</published>
    <updated>2010-11-10T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;I had the pleasure of giving a talk at &lt;a href="http://lrug.org"&gt;LRUG&lt;/a&gt; this month on &lt;a href="http://en.wikipedia.org/wiki/WebSockets"&gt;Websockets&lt;/a&gt; and &lt;a href="http://github.com/lifo/cramp"&gt;Cramp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I had some great fun using &lt;a href="https://github.com/schacon/showoff"&gt;Showoff&lt;/a&gt; creating the slides. It allows you to write the slides in markdown and serve them using Sinatra and some awesome javascript to make things look pretty. Making it full screen with Chrome worked a charm&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I had the pleasure of giving a talk at &lt;a href="http://lrug.org"&gt;LRUG&lt;/a&gt; this month on &lt;a href="http://en.wikipedia.org/wiki/WebSockets"&gt;Websockets&lt;/a&gt; and &lt;a href="http://github.com/lifo/cramp"&gt;Cramp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I had some great fun using &lt;a href="https://github.com/schacon/showoff"&gt;Showoff&lt;/a&gt; creating the slides. It allows you to write the slides in markdown and serve them using Sinatra and some awesome javascript to make things look pretty. Making it full screen with Chrome worked a charm.&lt;/p&gt;

&lt;p&gt;You can find the slides over at &lt;a href="http://github.com/kalv/lrug-websockets"&gt;http://github.com/kalv/lrug-websockets&lt;/a&gt; and the example chat app that I built over at &lt;a href="http://github.com/kalv/yact"&gt;http://github.com/kalv/yact&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Stop being clever Capybara</title>
    <link href="http://kalv.co.uk/2010/10/27/stop-being-clever-capybara/" rel="alternate"/>
    <id>http://kalv.co.uk/2010/10/27/stop-being-clever-capybara/</id>
    <published>2010-10-27T00:00:00Z</published>
    <updated>2010-10-27T00:00:00Z</updated>
    <author>
      <name>Kalvir Sandhu</name>
    </author>
    <summary type="html">&lt;p&gt;Today we realised that there was a bunch of functionality being tested that didn&amp;rsquo;t work when javascript was disabled and had to spend a while figuring it out.&lt;/p&gt;

&lt;p&gt;We found that it was because of the Rails 3 ability to make links become either HTTP DELETE or POST requests. So when creating a link in rails like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;link_to "Delete blog post", blog_post(@blog), :method =&amp;gt; :delete
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It would output into a html link:&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Today we realised that there was a bunch of functionality being tested that didn&amp;rsquo;t work when javascript was disabled and had to spend a while figuring it out.&lt;/p&gt;

&lt;p&gt;We found that it was because of the Rails 3 ability to make links become either HTTP DELETE or POST requests. So when creating a link in rails like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;link_to "Delete blog post", blog_post(@blog), :method =&amp;gt; :delete
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It would output into a html link:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;a href="/blog/1" data-method="delete"&amp;gt;Delete blog post&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;data-method&lt;/code&gt; is a &lt;a href="http://ejohn.org/blog/html-5-data-attributes/"&gt;HTML5 custom attribute&lt;/a&gt; by the looks of things. When the page is loaded the default &lt;code&gt;rails.js&lt;/code&gt; javascript adds an event handler to those link elements to turn it into a form that will actually send a DELETE http request when it is clicked.&lt;/p&gt;

&lt;p&gt;When testing these links in &lt;a href="http://github.com/jnicklas/capybara"&gt;Capybara&lt;/a&gt; (an integration testing framework) for some reason it performs this javascript behaviour within it&amp;rsquo;s &lt;a href="http://github.com/jnicklas/capybara/commit/58d4d0ca"&gt;rack-test driver&lt;/a&gt;. &lt;strong&gt;Isn&amp;rsquo;t this wrong?&lt;/strong&gt; Shouldn&amp;rsquo;t integration testing be just clicking through the site when javascript is disabled. And when you want to test javascript you use a javascript driver explicitly, like you can in cucumber and capybara:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@javascript
    Scenario: do something AJAXy
      When I click the AJAX link
      ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This magic that capybara performs would lead a developer into believing that those links work without javascript but they don&amp;rsquo;t. Sure some people might say why worry about it, most browsers now know about javascript, but what happens if someone chooses to turn it off or it&amp;rsquo;s disabled for other reasons.&lt;/p&gt;

&lt;p&gt;Moving forward I&amp;rsquo;m going to try and steer clear from using the &amp;lsquo;:method =&gt; :delete&amp;rsquo; in rails or monkey patch capybara to stop it changing the test request based on the &amp;lsquo;data-method&amp;rsquo;.&lt;/p&gt;

&lt;script src="http://gist.github.com/649000.js?file=capybara_monkey_patch.rb"&gt;&lt;/script&gt;

</content>
  </entry>
</feed>

