<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>29 Steps</title>
    <description>29 Steps Blog Posts</description>
    <link>http://29steps.co.uk/blog</link>
    <item>
      <title>Using Pygments.rb within Rails 3.2</title>
      <description>&lt;p&gt;Snipplets, the syntax highlighting app I built a month ago, makes strong use of Pygmentizer to highlight user submitted code segments. It does so by making a POST request to an external pygmentizer app located on google app engines which then makes a successful request back to the app on completion of the highlighting.&lt;/p&gt;

&lt;p&gt;While this serves the purpose of the app, it has some drawbacks. Snipplets relies on a Resque queue to wait for the request to be complete which means the user ends up with an inconsistent view of the codesnipplet; also what happens if the API service fails? &lt;/p&gt;

&lt;p&gt;After watching the railscasts episode 207 which introduces &lt;a href='https://github.com/tmm1/pygments.rb'&gt;pygments.rb&lt;/a&gt; I ported all the syntax highlighting code to using pygments.rb.&lt;/p&gt;

&lt;p&gt;Whats kool about pygments.rb is that it still uses pygemntizer but the program itself is embedded within the gem and your app using ruby-python and libffi ( through the ffi gem ) which means any environment that supports or runs python can run pygments.rb and that includes Heroku.&lt;/p&gt;

&lt;p&gt;However I ran into this peculiar bug whereby pygments.rb crashes the entire application server ( both Mongrel and Webrick as shown in the Railscasts) with a killed signal message on the console when running Pygments.highlight method.&lt;/p&gt;

&lt;p&gt;If you are running into the same issue, try switching over to &lt;strong&gt;Thin&lt;/strong&gt; which works for me without any issues. As yet I still cannot ascertain the error whether it is system dependent or not and ruby-debug did not thrown up any unusual bugs. Could have something to do with asynchronous processing but will look into it in a separate post.&lt;/p&gt;

&lt;p&gt;If you are new to using pygments.rb and have just switched over you might notice that the line numbers have disappeared completely if you used to have line numbers enabled. This is off by default in the gem and can be enabled by passing the line numbers options to true inside the Pygments.highlight method.&lt;/p&gt;

&lt;p&gt;Below is a short snipplet describing some of the workarounds for pygments.rb as discussed above:&lt;/p&gt;

&lt;script src="http://www.snipplets.co.uk/snipplets/63.js"&gt;&lt;/script&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The second issue you might run into when deploying onto Heroku is the version of RubyPython you are using. If you get errors such as 'lexer cannot be found' then it is related to RubyPython as pygments.rb cannot pick up on the Python interpreter. To do so simply create an initializer file ( I called mine 'rubypython.rb' and put it inside config/initializers) with the following code:&lt;/p&gt;

&lt;script src="http://www.snipplets.co.uk/snipplets/64.js"&gt;&lt;/script&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Essentially what the above does is to start a python interpreter session so that pygmentizer can run. I can't seem to find any other way to avoid this else the entire app will fail. The other gotcha is that it only seems to work with RubyPython 0.5.1 so I have the gemfiles locked down to that version. I tried it with both RubyPython 0.5.3 and the latest 0.6.1 to no avail - the cedar stack on heroku just refuses to communicate with rubypython.&lt;/p&gt;

&lt;p&gt;Hope this helps someone with similar dilemma as pygmentizer is a great syntax highlighting tool.&lt;/p&gt;</description>
      <pubDate>Sat, 19 May 2012 10:52:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/using-pygmentsrb-within-rails-32</link>
    </item>
    <item>
      <title>29 Steps Shop live and March 2012 updates</title>
      <description>&lt;p&gt;&lt;a href="http://shop.29steps.co.uk" target="_blank"&gt;&lt;img rel="450x450" alt="29 Steps Shop" title="29 Steps Shop" src="/system/images/BAhbB1sHOgZmIiYyMDEyLzAzLzE1LzE0LzMwLzE1LzQ0Ny9zaG9wMi5qcGdbCDoGcDoKdGh1bWIiDTQ1MHg0NTA+/shop2.jpg" width="450" height="273" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href="http://shop.29steps.co.uk" target="_blank"&gt;&lt;img rel="450x450" alt="29 Steps e commerce demo shop" title="29 Steps e commerce demo shop" src="/system/images/BAhbB1sHOgZmIiYyMDEyLzAzLzE1LzE0LzI5LzQ3LzU0Ni9zaG9wMS5qcGdbCDoGcDoKdGh1bWIiDTQ1MHg0NTA+/shop1.jpg" width="450" height="285" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;February has been a fairly quiet month so we are using this free time to develop our own products.&lt;/p&gt;

&lt;p&gt;We have been receiving requests for e commerce development work which is why we decided to learn and use Spree which is an open source e commerce platform. What we love about Spree is the ability to write custom extensions and there is a vibrant community of contributors out there. Also they have a really detailed set of guides to get you up and running at no time at all.&lt;/p&gt;


&lt;p&gt;We have created our own shop to showcase this. The shop can be found at &lt;a href="http://shop.29steps.co.uk" target="_blank"&gt;this link&lt;/a&gt;.The whole purpose of the shop is to say yes we can also do e commerce and if you need a bespoke / custom solution we can do it for you using the best open source tools out there.&lt;/p&gt;

&lt;p&gt;The entire shop is built using edge version of Spree; running on Rails 3.2.2 and hosted on Heroku. It uses a set of extensions such as Spree Paypal gateway; Spree carrierwave to deal with S3 uploads on Heroku; and Essential Spree CMS for the custom pages.&lt;/p&gt;

&lt;p&gt;We also learnt to use Deface to generate custom modifications to the templates ( which is the recommended way in Spree ) and also developed a small Featured Products extension on the homepage.&lt;/p&gt;

&lt;p&gt;Why would you want your own e commerce shop / solution when there are plenty of ready made even free services out there to use? The simple answer to that is it depends on your requirements. Some sellers are quite happy with ready made solutions as they have only a small number of products which don't change frequently. My personal take on that is - if you choose to migrate your data away to another service you will have a job on your hands. That is the main issue I have with ready made services.  Some services such as Shopify allows you to integrate your data through their API but it may so happen you pick and use a provider which doesn't have an API then what do you do? Re enter all your product info and images from scratch? Not for me.&lt;/p&gt;

&lt;p&gt;
I still think that having your own custom shop allows you maximum flexibility without the issue and headaches of data migration over platforms and it also allows you to customize it as you go along.&lt;/p&gt;

&lt;p&gt;If you are interested in finding out more, please &lt;a href="mailto:info@29steps.co.uk?subject=I%20want%20my%20e%20commerce%20solution"&gt;contact us&lt;/a&gt; for further details.&lt;/p&gt;

&lt;h3&gt;So ... what else is happening?&lt;/h3&gt;
&lt;p&gt;February alone is not just devoted to e commerce alone. We have also finishing off on our video encoding platform called Vide.IO. Screenshots and site coming really soon.&lt;/p&gt;

&lt;p&gt;In addition we also found the time to rewrite Snipplets to use the Bootstrap CSS and JS and also enhanced features such as github integration through the github API so you can version control your own snipplets. We also added a social network touch to it and that should be completed over the weekend.&lt;/p&gt;

&lt;p&gt;Last but not least, we are also developing a new rubygem for the Amazon DynamoDB. We are completing the specs for it at the moment so it should be launched fairly soon. The Amaze SNS rubygem has attracted over 24000 downloads as of today. We feel that an update is due soon as there has been some API changes.&lt;/p&gt;

</description>
      <pubDate>Thu, 15 Mar 2012 21:32:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/29-steps-shop-live-and-march-2012-updates</link>
    </item>
    <item>
      <title>Introducing Snipplets</title>
      <description>&lt;p&gt;&lt;a href='http://www.snipplets.co.uk' target='_blank'&gt;Snipplets&lt;/a&gt; is a code hightlighter built using Rails and uses pygmentizer to highlight code blocks.&lt;/p&gt;
&lt;p&gt;It allows for code embedding within HTML pages as well as oEmbed links which is an open format used to display rich content on HTML pages.&lt;/p&gt;&lt;p&gt;Snipplets runs on Heroku and processes the code snipplets by encoding it through RubyPython and pygments.rb&lt;/p&gt;
&lt;p&gt;To see it in action please visit: &lt;a href="http://www.snipplets.co.uk" target="_blank"&gt;Snipplets site&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A sample is shown below:&lt;/p&gt;
&lt;p&gt;&lt;script src="http://www.snipplets.co.uk/snipplets/60.js"&gt;&lt;/script&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 11 Feb 2012 15:56:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/introducing-snipplets</link>
    </item>
    <item>
      <title>FFMPEG 2012 update - Installing frei0r plugin</title>
      <description>&lt;p&gt;&lt;a href="http://piksel.org/frei0r" target="_blank"&gt;frei0r&lt;/a&gt; is a plugin which allows for video effects and can be built into the ffmpeg program by enabling the &lt;strong&gt;'--enable-frei0r'&lt;/strong&gt;option during compile. That requires building frei0r first.&lt;/p&gt;
&lt;p&gt;I tried building frei0r from the git source and ran into several issues on Ubuntu Oneiric 11. &lt;/p&gt;
&lt;p&gt;The first problem I came across after running './config.sh' to generate the makefile followed by 'make' is the following:&lt;/p&gt;
&lt;pre&gt;libtool: Version mismatch error. This is libtool 2.4.2, but the&lt;br /&gt;libtool: definition of this LT_INIT comes from libtool 2.4.&lt;br /&gt;libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2&lt;br /&gt;libtool: and run autoconf again.&lt;/pre&gt;
&lt;p&gt;
To proceed with the build I did the following within the source directory:
&lt;/p&gt;
&lt;pre&gt;aclocal&lt;br /&gt;&lt;br /&gt;autoreconf -i -f&lt;br /&gt;&lt;br /&gt;./configure&lt;/pre&gt;
&lt;p&gt;
The second issue occurs when you try to compile frei0r with ffmpeg. The Makefile generated by frei0r does not include linking with the system &lt;strong&gt;libc&lt;/strong&gt; library as indicated by the lack of LDFLAGS '-ldl' during the make output hence causing the compile crash later in ffmpeg with the following errors:
&lt;/p&gt;
&lt;pre&gt;undefined reference to 'dlclose'
undefined reference to 'dlopen'
undefined reference to 'dlerror'
&lt;/pre&gt;
&lt;p&gt;
To solve this just link frei0r with the libc library during configure and compile like so:
&lt;/p&gt;
&lt;pre&gt;./configure LIBS=-ldl&lt;br /&gt;
make -j3
&lt;/pre&gt;
&lt;p&gt;
Next during the actual ffmpeg configure after enabling the &lt;strong&gt;--enable-frei0r&lt;/strong&gt; option, you would still need to enable the 'extra-libs' flag as so:
&lt;/p&gt;
&lt;pre&gt;( from within the ffmpeg source directory )&lt;br /&gt;&lt;br /&gt;./configure --extra-libs="-ldl" ... -enable-frei0r&lt;/pre&gt;
&lt;p&gt;
There is also a prebuilt version of frei0r in the synaptic library if the above does not work. This has been tested with the latest ffmpeg git version and version 1.3 of the frei0r plugin from its git source.
&lt;/p&gt;
&lt;p&gt;
If anyone out there has a better solution to compile frie0r from source please feel free to contribute. Additionally, I am also looking into how to compile frie0r on OSX Snow Leopard. 
&lt;/p&gt;
</description>
      <pubDate>Tue, 17 Jan 2012 21:21:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/ffmpeg-2012-update-installing-frei0r-plugin</link>
    </item>
    <item>
      <title>More or Less Heroku</title>
      <description>&lt;p&gt;&lt;a target="_blank" title="http://lesscss.org" href="http://lesscss.org"&gt;LESS&lt;/a&gt; is a dynamic stylesheet language which I just discovered recently. It is powerful enough to allow for variables; mixins and functions.&lt;/p&gt;
&lt;p&gt;In a recent Rails 2.3x project which I had to deploy to Heroku, it uses a rails plugin called &lt;a target="_blank" title="http://github.com/cloudhead/more" href="http://github.com/cloudhead/more"&gt;More&lt;/a&gt; to generate the stylesheet from an existing LESS template. However the issue is Heroku uses protected directories and the More plugin tries to delete the current generated stylesheet whenever you do a deploy.&lt;/p&gt;
&lt;p&gt;
This is due to the following block of code within more/rails/init.rb
&lt;/p&gt;
&lt;pre&gt;config.after_initialize {&lt;br /&gt;  Less::More.clean&lt;br /&gt;  Less::More.parse if Less::More.page_cache?&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;
The line Less::More.clean will attempt to remove the stylesheet from the public/stylesheet directory which will cause a permission error since Heroku uses a readonly filesystem and does not allow for file deletion.&lt;/p&gt;
&lt;p&gt;
The second line Less::More.parse re-generates the css everytime if Less::More.page_cache? is true. In the case of Heroku, the plugin is looking for the HEROKU_ENV variable which is no longer valid, causing the heroku? method to return false and (not heroku?) to return true. Since page_cache_enabled_in_environment_configuration? calls on Rails.configuration.action_controller.perform_caching which is set to true in production, causing Less::More.parse to re generate all the css files.
&lt;/p&gt;
&lt;pre&gt;def page_cache_enabled_in_environment_configuration?
  # returns true in production env
   Rails.configuration.action_controller.perform_caching
end

def page_cache?
  (not heroku?) &amp;amp;&amp;amp; page_cache_enabled_in_environment_configuration?
end

# Returns true if the app is running on Heroku. When +heroku?+ is true,
# +page_cache?+ will always be false.
def heroku?
  !!ENV["HEROKU_ENV"]
end
&lt;/pre&gt;

&lt;p&gt;Hence the css gets regenerated causing an error.&lt;/p&gt;
&lt;p&gt;There are two approaches to solving this depending on the version of the More plugin you are using.&lt;/p&gt;
&lt;p&gt;If you are using the old More plugin, which is version less than 0.1.0, then you would need to add the following config var to your heroku variables.&lt;/p&gt;
&lt;pre&gt;  heroku config:add HEROKU_ENV=production&lt;/pre&gt;
&lt;p&gt;
This would set Less::More.parse to false hence not generating the css.
&lt;/p&gt;
&lt;p&gt;
If you are using the latest version from github, you just need to generate the css by running rake more:generate and then committing the css into the deploy. Make sure that the directory holding the generated css is not in your gitignore.
&lt;/p&gt;
&lt;p&gt;
 Next use a skip_before_filter to stop Less::More.generate_all from running during deploy:
&lt;/p&gt;
&lt;pre&gt;skip_before_filter :generate_css_from_less if Rails.env.production?&lt;/pre&gt;
&lt;p&gt;
I finally upgraded to the newer version of More as I don't think the older version still works given the fixes suggested above.
&lt;/p&gt;
</description>
      <pubDate>Wed, 11 Jan 2012 21:34:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/more-or-less-heroku</link>
    </item>
    <item>
      <title>Being AGILE in 2012</title>
      <description>&lt;p&gt;At 29 Steps we occasionally receive recommendations for new work through previous clients and there is no greater privilege&lt;br /&gt;than to be recognised for the quality of the work you have done previously for your details to be passed on to a third party.&lt;/p&gt;
&lt;p&gt;With the weeks leading up to XMAS, I had such an opportunity but after a series of email exchanges with the potential client&lt;br /&gt;I soon realised it would be difficult working with him and hence I turned it down. The debate or argument centred around the preferred set&lt;br /&gt;of working practices and once again AGILE was in the firing line.&lt;/p&gt;
&lt;p&gt;The client, whose name I shall abbreviate to A.T., disagreed with our working arrangements. He was happy with most of the work&lt;br /&gt;to be carried out remotely on the provision that I maintain a direct, open line of communication using Skype so he could walk me through&lt;br /&gt;a set of specs which is 'fluid' and changeable at the last moment and also to provide some training in Ruby on Rails&lt;/p&gt;
&lt;p&gt;My reply was to separate the two events and my concern was with the idea of 'changeable specs'. AGILE proposes that you need at least an initial&lt;br /&gt;set of clear specs before you can even begin any development which gets refined throughout the process&lt;/p&gt;
&lt;p&gt;(From past experiences that usually says to me 'I do not have a clue on what to do next but lets get the ball rolling and see how it goes'. )&lt;/p&gt;
&lt;p&gt;When I mentioned my concerns to him this was his reply verbatim:&lt;/p&gt;
&lt;pre&gt;"My priority is not to learn Rails.&lt;br /&gt; &lt;br /&gt;I can specify broadly what I need, so yes the requirements might change.&lt;br /&gt; &lt;br /&gt;I appreciate not having a totally clear spec makes estimating duration complicated which is why Im happy to pay an hourly rate, and accept that certain things may need re-doing, and refactoring as the system evolves.&lt;br /&gt; &lt;br /&gt;I have been a developer for 20 years, and have managed teams of programmers from 5 to 25 and have always worked in an industry which required a very agile approach like this."&lt;/pre&gt;
&lt;p&gt;Note the use of the phrases 'agile approach' and the more startling 'developer for 20 years'. &lt;/p&gt;
&lt;p&gt;Its by reading through the email again that something&lt;br /&gt;profound hit me: how could something such as AGILE, a set of best practices, be so misrepresented and misinterpreted in 2012?&lt;/p&gt;
&lt;p&gt;Thats when I realised there is a fundamental difference between a developer's understanding and perspective of Agile compared to that of other stakeholders.&lt;/p&gt;
&lt;h3&gt;Why is it so bad?&lt;/h3&gt;
&lt;p&gt;One of the main causes is the way AGILE has been potrayed over the years, not as a set of practices or principles but as a 'one size fits all' approach to any issue that does not fit in with the norm. In A.T.'s case since he did not have a clear list of specs, he believed he could formulate them along the way by being 'AGILE' or working in an 'AGILE' manner ( the misunderstanding here is that AGILE allows for iterations and turnarounds provided you have some specs to work with rather than chop and change whenever you feel like it ).&lt;/p&gt;
&lt;p&gt;Some individuals or companies like A.T. even go as far as hailing AGILE as their saving grace or bandied the term just to make themselves look savvy and in touch.&lt;/p&gt;
&lt;p&gt;Before we go any further let us take a step back and examine this in perspective and ask ourselves this question:&lt;/p&gt;
&lt;h3&gt;What exactly is AGILE?&lt;/h3&gt;
&lt;p&gt;Agile to me means a set of best practices and guiding principles to facilitate a fluid, manageable and less error prone software development which allows for both the stakeholders and developers to come together to make a great product&lt;/p&gt;
&lt;p&gt;The keyword here is 'principles'. Its &lt;strong&gt;NOT a set of RULES&lt;/strong&gt; to live by or followed completely. &lt;/p&gt;
&lt;p&gt;You pick out or adapt the relevant parts to fit your own development process and keep refining it until you are comfortable enough to do it without having to consciously think about it.&lt;/p&gt;
&lt;p&gt;Just because it works for person or company A does not mean it will work for you in the same way or you have to do as they do. My plea is to read these AGILE success stories with a pinch of salt rather than follow it blindly.&lt;/p&gt;
&lt;p&gt;AGILE is meant to be fluid and adaptable which means it allows you to make development changes rapidly since you are releasing at regular intervals.&lt;/p&gt;
&lt;p&gt;Some clients I have come across such as A.T. above will seize the opportunity to cramp as much work as they can into each release cycle with n cycles of iterations until  they are satisfied enough with the end result to justify paying you.&lt;/p&gt;
&lt;p&gt;If you already have 20+ years management experience under your belt you would know that AGILE proposes or allows for the workflow to be broken down into simple manageable user stories to be developed iteratively and not for addressing all your problems at one big go. Please stop abusing the AGILE term to justify your unreasonable behavior.&lt;/p&gt;
&lt;p&gt;Last but not least, AGILE is associated with TDD/BDD practices which in my opinion should be separate events.&lt;/p&gt;
&lt;p&gt;It doesn't mean that as soon as I burst open Textmate to start on a client project, out comes rspec, cucumber and all the CI suites I can think of in order to be 'AGILE'. It depends on the nature and context of the project. I think I can at least get some agreement that it will be overkill to have a full integration test on a static one page website.&lt;/p&gt;
&lt;p&gt;Likewise, some of the clients I have come across are not interested in pretty formatted PDF/HTML tests reports to read as they are comfortable with your ability to justify hiring you in the first place to solve a problem and let you get on with it.&lt;/p&gt;
&lt;p&gt;At 29 Steps we appreciate and like to achieve a healthy balance as we believe in regular testing and having a strong test suite to further backup your work but please do it in context not because 'you have to' or as a rite of passage to become a rails / ruby developer&lt;/p&gt;
&lt;p&gt;Another issue is with self-styled or industry recognised AGILE gurus who 'preaches' to you the must have tool to use if you want to stay AGILE in your development life span. A recent blog post I read on a renown website about testing introduced a new acceptance testing framework in order to improve your integration test suite but out of all the available features they recommend only 1 would have benefitted me so am I suppose to spend hours re writing my entire test suite to use this one tool just to fit in with what the gurus recommend?.&lt;/p&gt;
&lt;p&gt;For 2012 let us developers reclaim the term AGILE and for once embrace it for what it truly is - a useful set of principles to have and to learn from&lt;br /&gt;but not RULES which hinder what we love to do best - to play, create and make great software.&lt;/p&gt;
&lt;p&gt;Unless of course you relish a challenge with clients such as A.T. and D.F ( friend of A.T who has the same outlook on AGILE ) and possess a lot of time on your hands.&lt;/p&gt;
&lt;p&gt;As an aside, Zed Shaw, the author of Mongrel 2 server, has created a website which highlights some the thoughts I have mentioned so far but to a slightly greater extreme: &lt;a href="http://programming-motherfucker.com/" target="_blank"&gt;http://programming-motherfucker.com/&lt;/a&gt;
&lt;/p&gt;
</description>
      <pubDate>Tue, 10 Jan 2012 12:58:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/being-agile-in-2012</link>
    </item>
    <item>
      <title>DNode + Rails 3 = Realtime web</title>
      <description>&lt;p&gt;I recently had the opportunity to work on a project involving two totally separate skillsets: Rails 3 application running on top of a node.js application server which handles and distributes web sockets requests. In addition throw in e commerce and multi user functionality&lt;/p&gt;
&lt;p&gt;The end product is &lt;a target="_blank" title="http://squaremarket.com" href="http://squaremarket.com"&gt;SquareMarket.com&lt;/a&gt; which encompasses all the above which is why I have been keeping my head down for over a month since my last post. Below are some screenshots of the app in action.&lt;/p&gt;
&lt;p&gt;The project has been a revelation for me in terms of the work that has to be done to get websockets running in production mode and to make it secure by running ssl.&amp;#160;&lt;/p&gt;
&lt;p&gt;The realtime aspect is handled by a node.js script using dnode which has built in support for websockets using socket.io&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" title="http://squaremarket.com" href="http://squaremarket.com"&gt;&lt;img style="width: 572px; height: 362px;" rel="450x450" alt="Sq R1 C1" title="Sq R1 C1" src="/system/images/BAhbB1sHOgZmIikyMDExLzEyLzI5LzA5LzUzLzQ4LzQ3My9zcV9yMV9jMS5qcGdbCDoGcDoKdGh1bWIiDTQ1MHg0NTA+/sq_r1_c1.jpg" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;img style="width: 573px; height: 488px;" rel="450x450" alt="Sq2" title="Sq2" src="/system/images/BAhbB1sHOgZmIiQyMDExLzEyLzI5LzA5LzU0LzA3Lzc5MC9zcTIuanBnWwg6BnA6CnRodW1iIg00NTB4NDUwPg/sq2.jpg" /&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 29 Dec 2011 18:01:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/dnode-rails-3-realtime-web</link>
    </item>
    <item>
      <title>DNode 'Object.keys not found' error</title>
      <description>&lt;p&gt;In a recent project I had to integrate DNode in a node.js application which broacasts realtime events to connnected clients in the browser. For those who wonder what DNode is, its a node.js module which uses socket-io underneath to carry out RPC method calls between your browser and your backend application. More details about DNode can be found here: &lt;a target="_blank" title="https://github.com/substack/dnode" href="https://github.com/substack/dnode"&gt;DNode github&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In older browsers such as Firefox 3, it complains that a method called 'Object.keys' is not found. This is caused by the inclusion of 'dnode.js' in the browser script which makes a call to Object.keys.
&lt;/p&gt;
&lt;p&gt;
To fix this I added in an additional piece of javascript from the older branch or version of dnode 0.5 as follows:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
if (!Object.keys) Object.keys = function (obj) {
    var keys = [];
    for (var key in obj) {
        if (obj.hasOwnProperty(key))
            keys.push(key);
    }
    return keys;
};

if (typeof Object.create === 'undefined') {
    Object.create = function (o) {
        function F() {}
        F.prototype = o;
        return new F();
    };
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;
Drop the above into an external js file, include it and restart dnode again and provided you are using the latest version of jquery the above should make dnode cross browser compliant.I have tested it on firefox 3 and 7; chrome and safari on the mac.&lt;/p&gt;
&lt;p&gt;
Due to significant rewrite of the dnode library, this only affects the latest master branch and the npm version. If you are using an older version such as 0.5 the changes above has already been merged in to the core. For more details refer to the git commits and this &lt;a href="https://github.com/substack/dnode/issues/27" target="_blank"&gt;issue here&lt;/a&gt;
&lt;/p&gt;</description>
      <pubDate>Thu, 10 Nov 2011 12:17:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/dnode-objectkeys-not-found-error</link>
    </item>
    <item>
      <title>Non obtrusive contact form in Rails</title>
      <description>&lt;p&gt;In my development experience with Rails I always come to the point when I have to make some kind of contact form or contact us page and its always the part I leave to the very end for the reason that it is tedious ( write mailers; setup mail; views; controllers; tests ), sometimes buggy and difficult to test ( if you are collaborating on a project and the client only wants you to use specific testing gems ); and repetitive ( you will have to repeat the entire process again in another project.)&lt;/p&gt;
&lt;p&gt;Because of this I have developed or adpated a simple system so I have a base of standard template code I can use between projects which I know does work.&lt;/p&gt;
&lt;p&gt;For my contact forms setup, the first thing I do is to create an ActiveModel object or class called Contact or ContactForm depending on the what names are available in that project and drop it into the app/models folder. It will be prepended with Contact so I know what it is and does.&lt;/p&gt;
&lt;p&gt;Why use ActiveModel and not ActiveRecord? In some circumstances I come across, there is alreay a model called Contact in some projects which represent a different entity of the system altogether. Also I don't want to use ActiveRecord unless I know I am saving data to the DB. In the case of a contact form I'm only interested in getting details from the form and mailing it - if there is a need to store client queries, another plugin or system will need to be used to handle that aspect as there is a world of difference between sending data in a contact form and filtering and storing client queries.&amp;#160;&lt;/p&gt;
&lt;p&gt;Once the model is setup I normally add in basic validations for the commonly used fields such as name, email, subject matter. It is imperative to keep these fields to a minimum or to just the required fields. For me personally, I just want the client to provide the basic information which I need to get in contact with them again. The code below illustrates this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
class Contact
  include ActiveModel::Validations
  include ActiveModel::Conversion
  extend ActiveModel::Naming

  attr_accessor :name, :email, :phone, :alternative_phone, :subject, :question

  validates_presence_of :name, :email, :subject, :question
  validates_format_of :email, :with =&amp;gt; /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
  validates_length_of :question, :maximum =&amp;gt; 2500

  def initialize(attributes = {})
    attributes.each do |name, value|
      send("#{name}=", value)
    end
  end

  def persisted?
    false
  end
  
end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;To include the above into a form, just initialize it and if you are using the client-side-validations gem, the errors will still show up if some of the required fields are missing or malformed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
&amp;lt;%
  @contact = Contact.new
%&amp;gt;


&amp;lt;%= form_for @contact, :remote =&amp;gt; true,:validate =&amp;gt; true, :url =&amp;gt; contact_path do |f| %&amp;gt;
&lt;/code&gt;
&lt;div class="clearfix"&gt;
        &lt;label for="contact_name"&gt;Your Name &lt;span class="req"&gt;*&lt;/span&gt;
&lt;/label&gt;
        &amp;lt;%= f.text_field :name, :class=&amp;gt;'text' %&amp;gt;
  &lt;/div&gt;


&amp;lt;% end %&amp;gt;

&lt;/pre&gt;
&lt;p&gt;Assuming you have a contact_path to submit the form to, you can pass the contact object into a mailer once the validations have passed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
@contact = Contact.new(params[:contact])

unless @contact.errors.any?
  ContactMailer.query(@contact).deliver
end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Notice that in the form code sample above, I passed in remote as true to utilize the UJS capabilities in Rails 3. In the next article I will show you how to utilize this to build a less obtrusive contact form on the front end to integrate it with what we have so far.&lt;/p&gt;
</description>
      <pubDate>Thu, 10 Nov 2011 11:29:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/non-obtrusive-contact-form-in-rails</link>
    </item>
    <item>
      <title>Rails 3.1.1 + Asset Pipeline</title>
      <description>&lt;p&gt;
I had the opportunity to try out the new Rails 3.1.1 asset pipeline and although I love the way it works, it does take some getting used to and understand the way it works.
&lt;/p&gt;
&lt;p&gt;
The only issue I have with it is the sluggish speed in development mode - Sprockets compiles each asset individually and if you are using engines with nested stylesheets and js files, it grinds to a halt.
&lt;/p&gt;
&lt;p&gt;
After much googling around, I found &lt;a target="_blank" title="https://github.com/wavii/rails-dev-tweaks" href="https://github.com/wavii/rails-dev-tweaks"&gt;this gem&lt;/a&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gem 'rails-dev-tweaks', '~&amp;gt; 0.5.1'&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;
I then added the following default config into the application.rb file:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;br /&gt;config.dev_tweaks.autoload_rules do&lt;br /&gt;      keep :all&lt;br /&gt;&lt;br /&gt;      skip '/favicon.ico'&lt;br /&gt;      skip :assets&lt;br /&gt;      skip :xhr&lt;br /&gt;      keep :forced&lt;br /&gt; end&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;
Restart the server and you should find that your assets are loaded normally.&lt;/p&gt;
</description>
      <pubDate>Wed, 26 Oct 2011 19:32:00 +0000</pubDate>
      <link>http://29steps.co.uk/blog/rails-311-asset-pipeline</link>
    </item>
  </channel>
</rss>
