<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>CODETUNES</title>
	
	<link>http://codetunes.com</link>
	<description>is a development blog led by monterail.com</description>
	<lastBuildDate>Mon, 16 Apr 2012 09:43:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CodeTunes" /><feedburner:info uri="codetunes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><image><link>http://codetunes.com</link><url>http://codetunes.com/wp-content/uploads/2011/07/tee_small.png</url><title>Monterail.com, an offshore webdevelopment agency.</title></image><item>
		<title>How I learnt about jQuery Deffered thanks to Rails</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/5A2gbxCwGcA/how-i-learnt-about-jquery-deffered-thanks-to-rails</link>
		<comments>http://codetunes.com/2012/04/15/how-i-learnt-about-jquery-deffered-thanks-to-rails#comments</comments>
		<pubDate>Sun, 15 Apr 2012 21:35:23 +0000</pubDate>
		<dc:creator>Jan Dudulski</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=397</guid>
		<description><![CDATA[If you are not a regular JS developer but Ruby one or whatever, you probably don&#8217;t know every feature of JavaScript or jQuery, even if you use them every day. But some of them are worth spending some time to &#8230; <a href="http://codetunes.com/2012/04/15/how-i-learnt-about-jquery-deffered-thanks-to-rails">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are not a regular JS developer but Ruby one or whatever, you probably don&#8217;t know every feature of <a href="http://ejohn.org/apps/learn/">JavaScript</a> or <a href="http://jquery.com/">jQuery</a>, even if you use them every day. But some of them are worth spending some time to get to know &#8211; for me one of such features was jQuery.Deffered which I would like to introduce in this post.</p>
<h2>The context</h2>
<p>I love the idea behind <a href="http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/">unobtrusive javascript</a>, silently promoted with the release of Rails 3. It helps to keep the code clean, separate concerns of data and logic like controllers and views.</p>
<p>In one of our projects I had to replace the standard browser confirmation prompt with a  <a href="http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/">fancy one</a> and I was wondering if I can just re-use the Rails unobtrusive solution with <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to"><code>data-confirm</code> param</a>. Then, the problem occured.</p>
<h2>The problem</h2>
<p>Rails wisely assigns built-in <a href="https://github.com/rails/jquery-rails/blob/master/vendor/assets/javascripts/jquery_ujs.js#L92"><code>confirm</code> method to the <code>$.rails.confirm</code></a>, which allows developer to simply replace it with anything (s)he wants. The problem is, that you cannot provide any method which would open up a prompt, wait for click and return the boolean value as <code>confirm</code> does. No <code>wait</code> here, sorry. The problem is <a href="https://www.google.pl/search?q=custom+rails+confirm">well known</a>, but there is no simple solution yet.</p>
<h2>O&#8217;rly?</h2>
<p>Eight months ago (sic!) Mr <a href="https://github.com/akzhan">akzhan</a> <a href="https://github.com/rails/jquery-ujs/pull/196">proposed the solution</a> &#8211; he rewrote jquery_ujs confirm to work with <code>$.Deferred</code>. After polishing, his work landed couple of days ago in <a href="https://github.com/JangoSteve/jquery-ujs/tree/async-confirm"><code>assync-confirm</code> branch of jquery-ujs</a> maintainer repo. Unfortunatelly, <a href="https://github.com/JangoSteve">Steve</a> will not merge it with master untill it is used by more people at production. However, if you like, you can just download the fork, put it somewhere into your assets and require the standard <code>jquery_ujs</code> instead.</p>
<p>Here&#8217;s a simple code which works for me (with jConfirm and coffee-script):</p>
<pre>$.rails.confirm = (message) -&gt;
  answer = $.Deferred()
  jConfirm message, 'Please confirm', (result) -&gt;
    if result
      answer.resolve()
    else
      answer.reject()
  return answer.promise()</pre>
<p>And that&#8217;s all! Dead simple, isn&#8217;t it? It will work with standard data-confirm, e.g.:</p>
<pre>link_to some_path,
  { :method =&gt; 'delete', :remote =&gt; true, :confirm =&gt; "o'rly?" }</pre>
<h2>How it works?</h2>
<p>So, you can ask &#8211; what is this magic <code>$.Deffered</code>? In the simplest words it&#8217;s an object with stack of callbacks inside. You can <a href="http://api.jquery.com/deferred.then/">add a new one</a> from the outside, and <a href="http://api.jquery.com/deferred.resolve/">resolve</a>/<a href="http://api.jquery.com/deferred.reject/">reject</a> the object which would end up with specific callbacks run. There are three stacks &#8211; one is called when an object receives <code>resolve()</code> call, another one when it receives <code>reject()</code> call, and lastly a one when it receives any of the two calls.</p>
<p>In the example above we&#8217;re creating a deffered object which would get resolve/reject call from the jConfirm callback, depending on user decision. Without waiting for response, the $.rails.confirm will return the misterious <a href="http://api.jquery.com/deferred.promise/"><code>promise</code> object</a> &#8211; it&#8217;s a deffered object without resolve/reject methods. You can still add new callbacks, but you cannot decide when to run them. We left that decision to jConfirm callback.</p>
<p>It&#8217;s also worth knowing that you cannot set a state of deffered object twice. However if you add a callback after resolving/rejecting, it would be fired up instantly, depending on the state of course.</p>
<h2>Conclusion</h2>
<p>Read the whole <a href="http://api.jquery.com/category/deferred-object/">doc at jquery.com</a> and just use it when you need the ability to postpone adding your callbacks. There are some objects already deffered &#8211; like <a href="http://api.jquery.com/jQuery.ajax/">$.ajax</a>. You don&#8217;t need to specify callbacks inside constructor, you can move the object around and add callback anytime you need with <a href="http://api.jquery.com/deferred.then/">then</a>, <a href="http://api.jquery.com/deferred.done/">done</a>, <a href="http://api.jquery.com/deferred.fail/">fail</a> or <a href="http://api.jquery.com/deferred.always/">always</a>.</p>
<h2>Disclaimer</h2>
<p>If you decide to use <code>assync-confirm</code> version of <code>jquery-ujs</code>, make sure that a <a href="https://github.com/JangoSteve/jquery-ujs/pull/1/files">little bug is fixed</a>, or fix it yourself.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/EYQCtcC892a_x8gKC2TT4blHpIA/0/da"><img src="http://feedads.g.doubleclick.net/~a/EYQCtcC892a_x8gKC2TT4blHpIA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EYQCtcC892a_x8gKC2TT4blHpIA/1/da"><img src="http://feedads.g.doubleclick.net/~a/EYQCtcC892a_x8gKC2TT4blHpIA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/5A2gbxCwGcA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2012/04/15/how-i-learnt-about-jquery-deffered-thanks-to-rails/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codetunes.com/2012/04/15/how-i-learnt-about-jquery-deffered-thanks-to-rails?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-i-learnt-about-jquery-deffered-thanks-to-rails</feedburner:origLink></item>
		<item>
		<title>Zen and the art of nearshore agile development, notes after StartupCamp Berlin 2012</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/HT2hbA6dGxM/zen-and-the-art-of-nearshore-agile-development-notes-after-startupcamp-berlin-2012</link>
		<comments>http://codetunes.com/2012/03/23/zen-and-the-art-of-nearshore-agile-development-notes-after-startupcamp-berlin-2012#comments</comments>
		<pubDate>Fri, 23 Mar 2012 12:58:49 +0000</pubDate>
		<dc:creator>Szymon Boniecki</dc:creator>
				<category><![CDATA[Nearshore/Offshore Development]]></category>
		<category><![CDATA[agile development]]></category>
		<category><![CDATA[nearshore development]]></category>
		<category><![CDATA[nearshoring in poland]]></category>
		<category><![CDATA[offshore development]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=368</guid>
		<description><![CDATA[One of Monterail clients is Stefan Wolpers. On top of other dozen exciting things, Stefan organizes StartUp Camp Berlin. We have been lucky enough to be invited by him to the event. So Bartosz and I spent the last weekend &#8230; <a href="http://codetunes.com/2012/03/23/zen-and-the-art-of-nearshore-agile-development-notes-after-startupcamp-berlin-2012">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of Monterail clients is <a href="http://wolpers.posterous.com/">Stefan Wolpers</a>. On top of other dozen exciting things, Stefan organizes <a href="http://startup-camp-berlin.de/">StartUp Camp Berlin</a>. We have been lucky enough to be invited by him to the event. So Bartosz and I spent the last weekend in a vibrant atmosphere of Berlin-Kreuzberg at Startup Camp Berlin 2012. Vibrant has actually kept on being the main theme throughout the whole event.</p>
<p>First of all, Berlin is a 3 hour drive from Wrocław. A very pleasant one in mid-March. The proximity is not a surprising fact while lazily scrolling through the map. Not until one actually does hop into the car and after a while finds herself amazed by the atmosphere of the city and the event itself.</p>
<p>While it was interesting to hear different opinions (some from the very insiders) on German cloning scene throughout the day, we <a href="http://www.nbc.com/the-office/exclusives/michael-scott/somehow-i-manage/">somehow managed</a> to effectively enjoy the main party in the evening the most. Yeah, like we didn&#8217;t know from the beginning.</p>
<p>However I have to give it to them: if a German party is scheduled to finish at 11pm – it will. No drinking until early dawn and partying hard just for the sake of it. That&#8217;s correct. But believe me, you cannot not have a good time.</p>
<div id="attachment_370" class="wp-caption alignnone" style="width: 310px"><a href="http://codetunes.com/wp-content/uploads/2012/03/IMG_0582-fixed.jpg"><img class="size-medium wp-image-370" src="http://codetunes.com/wp-content/uploads/2012/03/IMG_0582-fixed-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Monterail meets Fastbill.com: René and Christian</p></div>
<p>We were slowly seeing this coming. And when finally everyone was merrily hugging each other to say goodbye it struck me this is how it’s supposed to be. We found ourselves in beds just after midnight and sang a merry song of thankfulness and gratitude. Being fresh in the morning made me become a believer.</p>
<p>For us as an agency co-founders the most interesting issue that was brought up couple times was outsourcing the development of the product or a part of it. As a matter of fact Monterail has helped startups in US and Europe and has had an ongoing long-term relationship with all of them ever since. It shouldn&#8217;t be a surprise that we publicly disagreed with one of the speakers during his presentation when he shared his view to actually avoid agencies when building a product. It was a great talk by <a href="http://www.simfy.de/">Steffen Wicker from simfy</a>: “<a href="http://startup-camp-berlin.de/speaker-theme-steffen-wicker/">How to build an organization that scales</a>”. We were looking forward to this one and really enjoyed it.</p>
<p>I think Steffen and his startup are doing great job and all the lessons he shared with the audience were the bare bones and substantial knowledge that is rare to come across. That&#8217;s why it makes perfect sense to assume that they have good reasons to believe that hiring agencies doesn&#8217;t work. At least has not worked for them. As far as I understood the biggest problem they have been having is that agencies just do the required job by selling the necessary man-hours and focusing on project completion. Whereas an in-house team tends to be more caring about the quality of the work and is generally more passionate about it which leads to general comfort of the management team. I guess there is more to it like motivating your employees and other factors that vary across different organizations, including their sizes (speaking of scaling). On the other side when it comes to hiring outside agencies there are a lot of moving parts as well.</p>
<p>There is no Holy Grail when pursuing any of these approaches (in-house vs contracting). However for all I know there are couple things to keep in mind when contracting the stuff out and it may very well work out better than anything.</p>
<p>Later that day I myself had a <a href="http://startup-camp-berlin.de/speaker-theme-szymon-boniecki/">presentation with Stefan on nearshore agile development</a> and what we have learned so far about working together in this model. Stefan and Monterail have been collaborating on an exciting project “ebookMakr” that is scheduled to be released in a month.</p>
<p>As a nearshore/offshore agency Monterail has worked for various types of clients in slightly different models. However over time one begins to notice how processes and philosophies emerge in a general fashion. The more mature we become the more mature are our relationships. This was the case with Stefan where both sides immediately jumped right into their roles and set clear expectations.</p>
<p>During the talk among practicalities these were the main points that I was trying to convey:</p>
<ul>
<li><strong>A client that understands the development process is gold</strong>. But also his money is well spent. The codebase is clear and maintainable. A clear win-win for both parties.</li>
<li><strong>Make sure to know what to look for when searching for your team of choice</strong>. Have a good look at them – at the end of the day these are the people you will stick around for at least some time and you are mutually dependent. This may freak out some of you out there but the truth is you can never overestimate the value of the people. Price is rarely the best option in this business.</li>
<li><strong>Excite the team about your project</strong>. When Stefan initially showed up in our office we learned about the project on a larger scale. We are in fact still in the loop on the high-level goals and are as much as him excited about where everything is headed.</li>
<li><strong>The right team for the job that is excited is less likely to miss deadlines</strong>. It will less likely go for compromises either. Forget overpromising.</li>
<li>The development team is the one that will be working on the project on a daily basis – listen to their insights and <strong>trust their instincts</strong>. It is possible they have been in this business long enough to understand it, too.</li>
<li>The team should beg for feedback and communicate fuck-ups early (note to self).</li>
<li><strong>Establish the design and development process</strong>. Everyone around seems to advertise themselves as the true agile practitioners. Beware though – waterfall is closer than you think. You need a clear vision of the process that both of you agree upon.</li>
<li><strong>Building a relationship is what you should be after.</strong></li>
</ul>
<p>For those interested in the presentation itself you can view the slides here:</p>
<p><iframe src="https://docs.google.com/presentation/embed?id=1iTdNc1uhDdJfUbtEl4v4cxNAIkMkLu3r5NsUivR8MBI&#038;start=false&#038;loop=false&#038;delayms=3000" frameborder="0" width="480" height="389" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe></p>
<p><a href="http://twitter.com/szymo">Follow Szymon on Twitter</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/NXALYDLOBtxbcnCz5Lu5AgF48pE/0/da"><img src="http://feedads.g.doubleclick.net/~a/NXALYDLOBtxbcnCz5Lu5AgF48pE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/NXALYDLOBtxbcnCz5Lu5AgF48pE/1/da"><img src="http://feedads.g.doubleclick.net/~a/NXALYDLOBtxbcnCz5Lu5AgF48pE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/HT2hbA6dGxM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2012/03/23/zen-and-the-art-of-nearshore-agile-development-notes-after-startupcamp-berlin-2012/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://codetunes.com/2012/03/23/zen-and-the-art-of-nearshore-agile-development-notes-after-startupcamp-berlin-2012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=zen-and-the-art-of-nearshore-agile-development-notes-after-startupcamp-berlin-2012</feedburner:origLink></item>
		<item>
		<title>A digital watercooler – easiest way to improve communication inside your team</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/N_xBnWY8B1c/digital-watercooler-improve-communication-inside-your-team</link>
		<comments>http://codetunes.com/2012/01/26/digital-watercooler-improve-communication-inside-your-team#comments</comments>
		<pubDate>Thu, 26 Jan 2012 19:01:39 +0000</pubDate>
		<dc:creator>Bartosz Pietrzak</dc:creator>
				<category><![CDATA[Communication]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=350</guid>
		<description><![CDATA[I have always been struggling with the goal of constantly improving the communication inside our development team. We always followed the idea that team is always more effective than any number of individuals. Since the team has grown to 15+ people &#8230; <a href="http://codetunes.com/2012/01/26/digital-watercooler-improve-communication-inside-your-team">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have always been struggling with the goal of constantly improving the communication inside our development team. We always followed the idea that team is always more effective than any number of individuals. Since the team has grown to 15+ people and a few of us are in different physical locations throughout Poland, we had to find a way to communicate and share knowledge effectively.</p>
<p>We have tried couple different options:</p>
<ul>
<li><a href="https://www.yammer.com/">Yammer</a> &#8211; enterprise-focused twitter clone. Sluggy, overbloated and not effective for us at all &#8211; you don&#8217;t want to use a tool that you have to remember about and you find it hard to use!</li>
<li><a href="http://campfirenow.com/">Campfire</a> &#8211; 1st choice for people that find IRC not being up to the modern web. A lot of ways to integrate great tools. A lot of great mobile and desktop clients. We used it for over a year and it played well &#8211; but it&#8217;s a massive distraction generator. We&#8217;re using it right now mostly to get notifications about git commits being pushed to our repository.</li>
<li>IRC &#8211; freenode or <a href="https://grove.io/">grove.io</a>, every option had same problems as Campfire &#8211; you don&#8217;t want to get distracted by seeing an message and not knowing whether it&#8217;s important or not.</li>
<li>Jabber group chat &#8211; yes, we tried even that one. I won&#8217;t comment it.</li>
</ul>
<h2>Thanks, Captain Obvious!</h2>
<div>For couple months we&#8217;ve been using <a href="http://www.facebook.com/groups">Facebook groups</a> to share links (and funny pictures, yeah).</div>
<div><a href="http://codetunes.com/wp-content/uploads/2012/01/Zrzut-ekranu-2012-01-26-o-19.54.38.png"><img class="alignnone size-full wp-image-353" title="Zrzut ekranu 2012-01-26 o 19.54.38" src="http://codetunes.com/wp-content/uploads/2012/01/Zrzut-ekranu-2012-01-26-o-19.54.38.png" alt="" width="178" height="157" /></a></div>
<div>Stuff that&#8217;s not important to making your job done. It&#8217;s a tool that you don&#8217;t have to remember about &#8211; basically every member of our team uses Facebook, and even ones that weren&#8217;t before, have to &#8211; simply because we&#8217;re building software for / integrated with the Facebook platform (not exclusively, of course, but we still do a lot of it).</div>
<div>We use it to share some cool hacks, tools that improve our workflow, interesting gems, backbone.js libraries, design resources and even to remind about <a href="http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc7/424078_10150739559141110_542566109_12209089_281080735_n.jpg">using the water filter in a polite way</a>.</div>
<div>It&#8217;s great because it doesn&#8217;t break your workflow. It&#8217;s easy to use. You don&#8217;t have to remember about it &#8211; you&#8217;re probably using Facebook in your spare time anyway. Think of it as a digital watercooler &#8211; a place where people meet to get a few minutes of rest and have a chit-chat &#8211; simply because everyone drinks water. And if you&#8217;re <a href="http://www.youtube.com/watch?v=mAparymJ_jc">the guy that brings his own water to work</a> (or do not use Facebook for whatever reasons), you are aware that you&#8217;re missing some of the social goodness. And it&#8217;s a water cooler that you can bring home along with the people around it. And access it from your iPad. And Android device. And a feature phone.</div>
<h2>Important is important!</h2>
<p><a href="http://codetunes.com/wp-content/uploads/2012/01/noise-separated.png"><img class="size-full wp-image-352 alignnone" style="border-style: initial; border-color: initial; border-width: 0px;" title="noise separated" src="http://codetunes.com/wp-content/uploads/2012/01/noise-separated.png" alt="" width="423" height="67" /></a></p>
<p>Don&#8217;t get me wrong. We still use an group email to share updates about the office issues, absences etc. We use jabber and email (not mentioning project management tools) to communicate about day to day work. But in this case, when we get an email or an IM, we know it&#8217;s the important stuff &#8211; noise separated, achievement unlocked.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Xyf6vr3RY0f9bu8QsDox4rtuGlM/0/da"><img src="http://feedads.g.doubleclick.net/~a/Xyf6vr3RY0f9bu8QsDox4rtuGlM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Xyf6vr3RY0f9bu8QsDox4rtuGlM/1/da"><img src="http://feedads.g.doubleclick.net/~a/Xyf6vr3RY0f9bu8QsDox4rtuGlM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/N_xBnWY8B1c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2012/01/26/digital-watercooler-improve-communication-inside-your-team/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://codetunes.com/2012/01/26/digital-watercooler-improve-communication-inside-your-team?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=digital-watercooler-improve-communication-inside-your-team</feedburner:origLink></item>
		<item>
		<title>Backbone.js, Rails 3 and asynchronous interfaces</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/JuZyNQjeuQg/backbone-js-rails-3-asynchronous-interfaces</link>
		<comments>http://codetunes.com/2012/01/03/backbone-js-rails-3-asynchronous-interfaces#comments</comments>
		<pubDate>Mon, 02 Jan 2012 22:43:44 +0000</pubDate>
		<dc:creator>Bartosz Pietrzak</dc:creator>
				<category><![CDATA[Backbone.js]]></category>
		<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=292</guid>
		<description><![CDATA[Currently at Monterail we&#8217;re building a frontend-heavy app. With a lot of cool stuff. Like preloading data for daily views so that you won&#8217;t have to wait for every surrounding day to load. Many, many interactive elements that should be really &#8230; <a href="http://codetunes.com/2012/01/03/backbone-js-rails-3-asynchronous-interfaces">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://codetunes.com/2012/01/03/backbone-js-rails-3-asynchronous-interfaces/rails-backbone" rel="attachment wp-att-301"><br />
</a><a href="http://codetunes.com/2012/01/03/backbone-js-rails-3-asynchronous-interfaces/rails-backbone-2" rel="attachment wp-att-306"><img class="size-full wp-image-306 alignright" style="border-style: initial; border-color: initial; border-width: 0px;" title="Backbone.js and Rails" src="http://codetunes.com/wp-content/uploads/2012/01/rails-backbone1.png" alt="Backbone.js and Rails" width="126" height="210" /></a>Currently at <a title="Ruby on Rails development agency" href="http://monterail.com">Monterail</a> we&#8217;re building a frontend-heavy app. With a lot of cool stuff. Like preloading data for daily views so that you won&#8217;t have to wait for every surrounding day to load. Many, many interactive elements that should be really interactive &#8211; not in an oldschool, ajax &#8220;spinner&#8221; way. And a lot of other stuff we shouldn&#8217;t talk about yet.</p>
<p>We decided to put more emphasis on <strong>Backbone.js with Rails</strong> and build most of the app with this combination.</p>
<p>Below you can find some of our findings on the topic of making those two speak to each other in a nice manner.</p>
<h1>Asset pipeline</h1>
<p>Really makes things easier. Organizing your JS code before it meant a lot of things: handling dependencies, minifying &amp; compressing the code, organizing it into a lot of different files and building connections between them. With asset pipeline and it&#8217;s awesome &#8220;require&#8221; directive, you can forget about handling it manually. You just create the structure in app/assets/javascripts. Or app/assets/javascripts/backbone. Your choice. You can have many different files in whatever directories you like &#8211; in the end you&#8217;ll get one (or more, if you decide to) JS file that has everything your webapp need.</p>
<p>Don&#8217;t forget to:</p>
<ul>
<li>gzip your JS/css assets</li>
<li>minify them!</li>
</ul>
<h1>Rails-backbone gem</h1>
<p>Also makes things easier. It puts backbone.js (&amp; underscore.js) library code into your asset pipeline. It gives you some great generators to get started if you don&#8217;t know where to start. Definitely worth including in your Gemfile.</p>
<p><a href="http://rubygems.org/gems/rails-backbone">http://rubygems.org/gems/rails-backbone</a></p>
<h1>Coffeescript &amp; underscore.js</h1>
<p>Obviously. It makes Javascript code feel fresh. You can fold, iterate and do a lot of stuff. Be sure to check out <a href="http://documentcloud.github.com/underscore/">underscore.js</a> docs. And <a href="http://coffeescript.org/">coffescript docs</a>, of course, but I bet you know it already.</p>
<h1>&#8220;V&#8221; in MVC done right</h1>
<p>Views are classes. You handle logic inside them using the hardcore code, which is receiving so much hate in Rails views. They can have many methods, they do not have to render a single &#8220;action&#8221;. And templates are templates &#8211; and nothing else. There is a lot of discussion recently on the matter of Views/Templates in Rails, but you can start implementing it right away. Go and try it. You&#8217;ll fall in love.</p>
<p>You have many options for templates &#8211; <a href="https://github.com/sstephenson/eco">eco</a>, <a href="http://www.handlebarsjs.com/">Handlebars.js</a>, <a href="https://github.com/defunkt/mustache">{{ mustache }}</a>, but we recommend <a href="https://github.com/netzpirat/haml_coffee_assets">haml_coffee_assets</a>. It gives you the HAML you (probably) already know with the ability to use coffeescript within it.</p>
<h1>Single-page app</h1>
<p>Yes. You will use Rails to render only the core view of the application. Of course, you will have to handle all things around the core of your app.</p>
<p>For example, you should probably leave out:</p>
<ul>
<li><em>authentication logic</em>: sign up / in, reset password</li>
<li><em>steps necessary to use the app</em>: billing pages</li>
</ul>
<div>But, other than that, you can use the views rendered in JS. What does that mean?</div>
<div>
<ul>
<li>if they do not include any dynamic data, they are lightning fast</li>
<li>if they include dynamic data, you can preload it and they still will be lightning fast</li>
</ul>
<div>Backbone comes with it&#8217;s own router. You can utilise <a href="http://documentcloud.github.com/backbone/#History">pushState</a> without any effort. How cool is that?</div>
<h1><span class="Apple-style-span" style="color: #000000;">Asynchronous interface</span></h1>
<p>Since you&#8217;ll be doing most of the association/validation work in background, you don&#8217;t have to worry too much about server responses. It&#8217;s the same with rendering elements: you&#8217;ll be doing it in JS, not Rails. You don&#8217;t have to wait for the request to return the rendered element to actually display them. If you create something, the UI should respond right away and the ajax request can persist the data with it&#8217;s own pace.</p>
<p>You should, however, prepare a global &#8220;something went wrong, reload the page&#8221; request rescuer &#8211; in case of network outages, backend app failures and so on. But it&#8217;s way easier to manage.</p>
<h1>API</h1>
<p>You get it for free. It doesn&#8217;t have to be public, but if you decide to, it&#8217;s a matter of adding OAuth as the way of authenticating requests and it&#8217;s done. (Or you could go with http basic auth, which is obviously bad for a lot of reasons).</p>
<p>With smart caching (give <a href="http://jodosha.github.com/redis-store">redis-store</a> a try), you&#8217;ll save tons of server power. You know, relating to the old ruby saying, &#8220;views are most resource-consuming&#8221;.</p>
<h1>Conclusion</h1>
<p>There are, obviously, downsides, which I&#8217;ll cover in future (I silently hope that there won&#8217;t be any reason to do that). And topics I haven&#8217;t covered. I&#8217;m curious about other stacks and ways of doing things. Share in the comments or ping me on Twitter!</p>
<p><a class="twitter-follow-button" href="https://twitter.com/bartoszpietrzak" data-show-count="false">Follow @bartoszpietrzak</a></p>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/acEIaeUACtTWSo0p-hZUuEh7rks/0/da"><img src="http://feedads.g.doubleclick.net/~a/acEIaeUACtTWSo0p-hZUuEh7rks/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/acEIaeUACtTWSo0p-hZUuEh7rks/1/da"><img src="http://feedads.g.doubleclick.net/~a/acEIaeUACtTWSo0p-hZUuEh7rks/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/JuZyNQjeuQg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2012/01/03/backbone-js-rails-3-asynchronous-interfaces/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://codetunes.com/2012/01/03/backbone-js-rails-3-asynchronous-interfaces?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=backbone-js-rails-3-asynchronous-interfaces</feedburner:origLink></item>
		<item>
		<title>wroc_love.rb</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/e2NjmdSetV4/wroc_love_rb</link>
		<comments>http://codetunes.com/2011/12/14/wroc_love_rb#comments</comments>
		<pubDate>Wed, 14 Dec 2011 20:29:10 +0000</pubDate>
		<dc:creator>Bartosz Pietrzak</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[wroclaw]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=284</guid>
		<description><![CDATA[wroc_love.rb is a „Fresh Ruby-oriented conference in Wrocław, Poland” that happens on 10-11 March 2012. We&#8217;re proud to announce that our team got involved in co-organizing the event and one of the outcomes is the launch of the new website &#8211; &#8230; <a href="http://codetunes.com/2011/12/14/wroc_love_rb">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="wroc_love.rb" href="http://wrocloverb.com/">wroc_love.rb</a> is a „Fresh Ruby-oriented conference in Wrocław, Poland” that happens on 10-11 March 2012.</p>
<p>We&#8217;re proud to announce that our team got involved in co-organizing the event and one of the outcomes is the launch of the <a href="http://wrocloverb.com/">new website &#8211; go check it out</a>!</p>
<p><a href="http://wrocloverb.com/"><img class="aligncenter size-large wp-image-285" title="Zrzut ekranu 2011-12-14 o 21.18.16" src="http://codetunes.com/wp-content/uploads/2011/12/Zrzut-ekranu-2011-12-14-o-21.18.16-1024x438.png" alt="" width="584" height="249" /></a>One of the goals of the conference is to supply some solid topics that, we hope, will result in long and red hot discussions.</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/wrocloverb">follow the twitter account</a>, <a href="https://www.facebook.com/wroclove.rb">like the facebook page</a>, <a href="http://blog.wrocloverb.com/">follow the tumblr blog</a> and <a href="http://c4p.wrocloverb.com/">submit a paper proposal</a> - if you have something interesting to say!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/bqB-nAYXz-ej4eXEh8E7bI-mWPk/0/da"><img src="http://feedads.g.doubleclick.net/~a/bqB-nAYXz-ej4eXEh8E7bI-mWPk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/bqB-nAYXz-ej4eXEh8E7bI-mWPk/1/da"><img src="http://feedads.g.doubleclick.net/~a/bqB-nAYXz-ej4eXEh8E7bI-mWPk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/e2NjmdSetV4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2011/12/14/wroc_love_rb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codetunes.com/2011/12/14/wroc_love_rb?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wroc_love_rb</feedburner:origLink></item>
		<item>
		<title>Testing AJAX-reloaded elements with Capybara</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/woLbbKHvggY/testing-ajax-reloaded-elements-with-capybara</link>
		<comments>http://codetunes.com/2011/08/20/testing-ajax-reloaded-elements-with-capybara#comments</comments>
		<pubDate>Sat, 20 Aug 2011 16:00:15 +0000</pubDate>
		<dc:creator>Michał Szajbe</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[capybara]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=270</guid>
		<description><![CDATA[Capybara is a great tool for testing application flow and user interfaces. Thanks to Culerity and Selenium web drivers you can test javascript and AJAX features of your apps. However testing AJAX is not that straightforward because of asynchonous nature of these &#8230; <a href="http://codetunes.com/2011/08/20/testing-ajax-reloaded-elements-with-capybara">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="Capybara gem" href="https://github.com/jnicklas/capybara" target="_blank">Capybara</a> is a great tool for testing application flow and user interfaces. Thanks to Culerity and Selenium web drivers you can test javascript and AJAX features of your apps.</p>
<p>However testing AJAX is not that straightforward because of asynchonous nature of these requests. In order to test effects of AJAX calls a web driver must wait until they finish which is difficult if not impossible to detect. However this can be worked around using some tricks.</p>
<h2>Scenario 1</h2>
<p>Let&#8217;s say you want to test a link on the page that triggers an AJAX request which eventually inserts some element in DOM. This could be an &#8220;Edit&#8221; link that retrieves object&#8217;s data from database (via AJAX call) and then shows an HTML form on the page. Test scenario might look like this:</p>
<pre>@selenium
Scenario: Clicking "Edit" should show edit form
  Given I am on product's page
  And I click "Edit" link
  Then I should see form</pre>
<p>The form will not appear immediately after the link is clicked because it takes some time for your app to process the AJAX request and return the response. Capybara is intelligent enough to acknowledge this and instead of expecting a form to appear immediately it periodically looks for it in page&#8217;s DOM. You can define for how many seconds it should keep looking by setting following option:</p>
<pre>Capybara.default_wait_time = 5</pre>
<p>If the form doesn&#8217;t appear in this specified time frame, the test fails. Note that Capybara doesn&#8217;t always wait full 5 seconds, it simply moves on to the next step as soon as the form appears.</p>
<h2> Scenario 2</h2>
<p>Now you want to test a link that removes an element from DOM. This could be a &#8220;Save&#8221; link that saves object to database (via AJAX call) and then removes the form. Test scenario:</p>
<pre>@selenium
Scenario: Clicking "Save" should remove edit form
  Given I am on product's page
  And I click "Save"
  Then I should not see form</pre>
<p>This test fails even if your app works as expected. I guess you see the problem. Capybara finds the form on first lookup which is performed immediately after the click, but at that point the AJAX call has not completed yet, so the form is still there.</p>
<p>Popular solution is to explicitely tell Capybara to wait until it starts looking for changes in DOM. In other words, give the AJAX calls chance to complete. Here&#8217;s an adequate cucumber step:</p>
<pre>Given /^I wait (\d+) seconds?$/ do |sec|
  sleep(sec.to_i)
end</pre>
<p>Rebuilt scenario would look like this:</p>
<pre>@selenium
Scenario: Clicking "Save" should remove edit form
  Given I am on product's page
  And I click "Save"
  And I wait 5 seconds
  Then I should not see form</pre>
<p>The downside is that it will always wait 5 full seconds now.</p>
<h2>Other aspects</h2>
<p>Neither explicit waiting with <em>sleep</em>, nor Capybara&#8217;s <em>default_wait_time</em> option guarantees 100% success. Your tests may still ocassionally fail if the AJAX requests they perform takes longer than you assume. The time it takes for the app to process such request may be quite random as it depends on many aspects like machine load or external services it hits (database, search engines, etc.). So remember to set the option to a value high enough for your app.</p>
<p><a href="https://twitter.com/szajbus" class="twitter-follow-button" data-show-count="false">Follow @szajbus</a><br />
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script></p>

<p><a href="http://feedads.g.doubleclick.net/~a/M8liG5MOYVp8YXwuF_UQwLSKZ4g/0/da"><img src="http://feedads.g.doubleclick.net/~a/M8liG5MOYVp8YXwuF_UQwLSKZ4g/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/M8liG5MOYVp8YXwuF_UQwLSKZ4g/1/da"><img src="http://feedads.g.doubleclick.net/~a/M8liG5MOYVp8YXwuF_UQwLSKZ4g/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/woLbbKHvggY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2011/08/20/testing-ajax-reloaded-elements-with-capybara/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codetunes.com/2011/08/20/testing-ajax-reloaded-elements-with-capybara?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=testing-ajax-reloaded-elements-with-capybara</feedburner:origLink></item>
		<item>
		<title>Chosen: multiple choice select inputs made easy</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/INzol4TiDsU/chosen</link>
		<comments>http://codetunes.com/2011/08/01/chosen#comments</comments>
		<pubDate>Mon, 01 Aug 2011 06:00:38 +0000</pubDate>
		<dc:creator>Bartosz Pietrzak</dc:creator>
				<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=264</guid>
		<description><![CDATA[http://harvesthq.github.com/chosen/ Great tool for enhancing selects, multiple selects, grouped selects etc. made by the Harvest team (great timetracking tool we&#8217;re using on a daily basis). We&#8217;re all about using native controls as much as possible, but multiple select boxes were &#8230; <a href="http://codetunes.com/2011/08/01/chosen">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://harvesthq.github.com/chosen/">http://harvesthq.github.com/chosen/</a></p>
<p>Great tool for enhancing selects, multiple selects, grouped selects etc. made by the <a href="http://getharvest.com">Harvest</a> team (great timetracking tool we&#8217;re using on a daily basis).<br />
<a href="http://harvesthq.github.com/chosen/"><img class="aligncenter size-full wp-image-265" title="Zrzut ekranu 2011-07-31 o 11.26.40" src="http://codetunes.com/wp-content/uploads/2011/07/Zrzut-ekranu-2011-07-31-o-11.26.40.png" alt="" width="383" height="230" /></a>We&#8217;re all about using native controls as much as possible, but multiple select boxes were always a non-usable pain in the ass. This one is a great solution in tight areas where you can&#8217;t afford displaying a list with checkboxes.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<p><a href="http://feedads.g.doubleclick.net/~a/cyaXHWynDAN6dO_BduMy-vK2GAs/0/da"><img src="http://feedads.g.doubleclick.net/~a/cyaXHWynDAN6dO_BduMy-vK2GAs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/cyaXHWynDAN6dO_BduMy-vK2GAs/1/da"><img src="http://feedads.g.doubleclick.net/~a/cyaXHWynDAN6dO_BduMy-vK2GAs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/INzol4TiDsU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2011/08/01/chosen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codetunes.com/2011/08/01/chosen?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=chosen</feedburner:origLink></item>
		<item>
		<title>Outbound API rate limits: the nginx way</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/H4mN9-iKRrk/outbound-api-rate-limits-the-nginx-way</link>
		<comments>http://codetunes.com/2011/07/26/outbound-api-rate-limits-the-nginx-way#comments</comments>
		<pubDate>Tue, 26 Jul 2011 19:10:01 +0000</pubDate>
		<dc:creator>Bartosz Pietrzak</dc:creator>
				<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[api calls throttling]]></category>
		<category><![CDATA[api rate limits]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://codetunes.com.mhs1.monterail.eu/?p=1</guid>
		<description><![CDATA[Implementing external API rate limits can be painful. There are some solutions that aim at this problem &#8211; let&#8217;s take Slow Web for example &#8211; but things tend to complicate when we start using background jobs, or even oldschool cron-rake &#8230; <a href="http://codetunes.com/2011/07/26/outbound-api-rate-limits-the-nginx-way">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Implementing external API rate limits can be painful. There are some solutions that aim at this problem &#8211; let&#8217;s take <a href="https://github.com/benbjohnson/slowweb" target="_blank">Slow Web</a> for example &#8211; but things tend to complicate when we start using background jobs, or even oldschool cron-rake setup. Slow web takes care of one environment at a time, not to mention that it relies on Net::HTTP so you can forget using more powerful stuff like <a href="https://github.com/dbalatero/typhoeus" target="_blank">Typhoeus</a>.</p>
<p>Recently we started working on a project that uses heavily an API that limits our development calls to one per 500ms and production calls to one per 200ms (our first thought and initial information was that we can do five requests per second, but those are not the same). Inspired by a great post, „<a href="http://www.gabrielweinberg.com/blog/2011/07/nginx-json-hacks.html" target="_blank">nginx JSON hacks</a>”, an idea came to our minds. What if we could use nginx to implement limiting the API? Here comes the built-in nginx module, the <a href="http://wiki.nginx.org/HttpLimitReqModule" target="_blank">HttpLimitReqModule</a>. Let&#8217;s take a quick look.</p>
<pre>http {
  limit_req_zone  $binary_remote_addr  zone=one:10m   rate=110r/m;

  server {
    listen       8080;
    server_name  localhost;

    location / {
      limit_req   zone=one  burst=100;

      proxy_pass        http://api.example.com/;
    }
  }
}</pre>
<p><em>(Please bear in mind that this configuration is merely an example and you probably want a more comprehensive setup. You can <a href="http://monterail.com">hire us to do the job for you</a>).</em></p>
<p>We set a simple proxy on localhost:8080, configure the limit_req_zone option, apply the zone, set the burst rate to 100 (depending on how you want to handle huge load, this could be smaller or bigger). We set the rate to 110 requests per minute for a little margin. Our benchmarks went fine, as we expected &#8211; no API calls were dropped. Setting it to exact 120r/m (or 2r/s) gave us some 403s, though.</p>
<p>Okay, so what about those cool examples in the post mentioned above? Let&#8217;s apply some caching!</p>
<pre>http {
    limit_req_zone  $binary_remote_addr  zone=one:10m   rate=110r/m;
    proxy_cache_path  /tmp/nginx_cache levels=1:2 keys_zone=STATIC:64m inactive=60m max_size=128m;

    server {
        listen       8080;
        server_name  localhost;

        location /without_cache {
          limit_req   zone=one  burst=100;

          proxy_pass        http://api.example.com/;
        }

        location / {
            proxy_pass        http://localhost:8080/without_cache;

            proxy_cache STATIC;
            proxy_cache_methods POST GET PUT; # allow POST caching which is not allowed by default
            proxy_cache_valid 10s; # cache every API request for 10 seconds
            proxy_cache_key "$host$request_uri$request_body";
        }
    }
}</pre>
<p>Why two locations, you may ask? It&#8217;s because we don&#8217;t want to have a rate limit for our cached version. In this case, when the first request finishes, every other gets an ultra-speed boost from being stored in a local cache.</p>
<p>We don&#8217;t have to worry about implementing API rate limits in every place in the app. We don&#8217;t have to worry about sharing those limits between different environments. All we need to do is to change the API host and enjoy pure coding goodness.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/DGiQhfKIbagpSLDuVvDs13YsC9M/0/da"><img src="http://feedads.g.doubleclick.net/~a/DGiQhfKIbagpSLDuVvDs13YsC9M/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DGiQhfKIbagpSLDuVvDs13YsC9M/1/da"><img src="http://feedads.g.doubleclick.net/~a/DGiQhfKIbagpSLDuVvDs13YsC9M/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/H4mN9-iKRrk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2011/07/26/outbound-api-rate-limits-the-nginx-way/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://codetunes.com/2011/07/26/outbound-api-rate-limits-the-nginx-way?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=outbound-api-rate-limits-the-nginx-way</feedburner:origLink></item>
		<item>
		<title>CakePHP moved to Github!</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/T-U0eDYnk_E/cakephp-moved-to-github</link>
		<comments>http://codetunes.com/2009/12/11/cakephp-moved-to-github#comments</comments>
		<pubDate>Fri, 11 Dec 2009 17:56:00 +0000</pubDate>
		<dc:creator>Michał Szajbe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=136</guid>
		<description><![CDATA[After two of the core developers, Nate Abele and Gwoo, left the project lately, many feared the worst. Now it&#8217;s a different story! The CakePHP core team decided to move the project to Github. I&#8217;d say: finally! Now it&#8217;s truly &#8230; <a href="http://codetunes.com/2009/12/11/cakephp-moved-to-github">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After two of the core developers, Nate Abele and Gwoo, left the project lately, <a title="The end of CakePHP?" href="http://cakebaker.42dh.com/2009/10/23/the-end-of-cakephp/">many</a> feared the worst. Now it&#8217;s a different story! The CakePHP core team decided to move the project to <a title="CakePHP on Github" href="http://github.com/cakephp">Github</a>.</p>
<p>I&#8217;d say: finally!</p>
<p>Now it&#8217;s truly open to the community. That&#8217;s because Github makes it so easy to collaborate on open source projects. All you need to do is to fork a project, merge your changes, and send a pull request to project&#8217;s maintainer. Can&#8217;t imagine more painless process.</p>
<p>What I expect now is a real boost in CakePHP development, with many great features delivered by the community. Just check how other projects benefited from the move, for example <a title="Ruby on Rails" href="http://github.com/rails/rails">Ruby on Rails</a> that has more than 700 forks now. So&#8230;</p>
<p>Let&#8217;s fork it! <img src='http://codetunes.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/r5xME7Hb6IftxAg1Hwczp0dZZP0/0/da"><img src="http://feedads.g.doubleclick.net/~a/r5xME7Hb6IftxAg1Hwczp0dZZP0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/r5xME7Hb6IftxAg1Hwczp0dZZP0/1/da"><img src="http://feedads.g.doubleclick.net/~a/r5xME7Hb6IftxAg1Hwczp0dZZP0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/T-U0eDYnk_E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2009/12/11/cakephp-moved-to-github/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codetunes.com/2009/12/11/cakephp-moved-to-github?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=cakephp-moved-to-github</feedburner:origLink></item>
		<item>
		<title>Fixtures without validation with Factory Girl</title>
		<link>http://feedproxy.google.com/~r/CodeTunes/~3/TH7P6x2aeCs/fixtures-without-validation-with-factory-girl</link>
		<comments>http://codetunes.com/2009/11/05/fixtures-without-validation-with-factory-girl#comments</comments>
		<pubDate>Thu, 05 Nov 2009 12:29:34 +0000</pubDate>
		<dc:creator>Michał Szajbe</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[factory girl]]></category>
		<category><![CDATA[fixtures]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://codetunes.com/?p=132</guid>
		<description><![CDATA[Factory Girl is my fixture replacement library of choice. It improves tests readability and maintainability. It&#8217;s also customizable. There are sometimes situations when you want to create test scenarios that checks how your app is handling invalid data (not user &#8230; <a href="http://codetunes.com/2009/11/05/fixtures-without-validation-with-factory-girl">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/thoughtbot/factory_girl">Factory Girl</a> is my fixture replacement library of choice. It improves tests readability and maintainability. It&#8217;s also customizable.</p>
<p>There are sometimes situations when you want to create test scenarios that checks how your app is handling invalid data (not user input, but invalid records that already sit in your database). To do this you first need to put this invalid data to your db.</p>
<p>You could accomplish this with such line:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@user</span> = Factory<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#ff3333; font-weight:bold;">:email</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;not a correct email address&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>However, factory girl would raise an exception here, because that&#8217;s the default strategy of creating new fixtures &#8211; raise exception if save fails (because of validation errors for example).</p>
<p>Thankfully we can use our own strategy of creating new fixtures, such that does save records without validation.</p>
<p>First let&#8217;s define our new strategy:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">Factory::Proxy::CreateWithoutValidation</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#6666ff; font-weight:bold;">Factory::Proxy::Build</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> result
    <span style="color:#0066ff; font-weight:bold;">@instance</span>.<span style="color:#9900CC;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@instance</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Factory
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">create_without_validation</span> <span style="color:#006600; font-weight:bold;">&#40;</span>name, overrides = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    factory_by_name<span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">run</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">Proxy::CreateWithoutValidation</span>, overrides<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Now we can use it while defining new factory:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Factory.<span style="color:#9900CC;">define</span> <span style="color:#ff3333; font-weight:bold;">:invalid_user</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; User, <span style="color:#ff3333; font-weight:bold;">:default_strategy</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:create_without_validation</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
  ...
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And then we can happily create invalid fixtures without any exceptions raised.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Wz2iGHuEA_ieVlRUWO5VnuvRLig/0/da"><img src="http://feedads.g.doubleclick.net/~a/Wz2iGHuEA_ieVlRUWO5VnuvRLig/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Wz2iGHuEA_ieVlRUWO5VnuvRLig/1/da"><img src="http://feedads.g.doubleclick.net/~a/Wz2iGHuEA_ieVlRUWO5VnuvRLig/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/CodeTunes/~4/TH7P6x2aeCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codetunes.com/2009/11/05/fixtures-without-validation-with-factory-girl/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://codetunes.com/2009/11/05/fixtures-without-validation-with-factory-girl?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=fixtures-without-validation-with-factory-girl</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Object Caching 875/1028 objects using memcached

Served from: codetunes.com.mh1.monterail.eu @ 2012-04-16 12:00:48 --><!-- W3 Total Cache: Page cache debug info:
Engine:             memcached
Cache key:          w3tc_codetunes.com_1_page_da6f7b5015a12fe724dc34140c8664e0_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.345s
Header info:
ETag:               "54c5cd466978386d907d4f8c409471bb"
Last-Modified:      Mon, 16 Apr 2012 09:43:23 GMT
Vary:               Accept-Encoding, Cookie
X-Powered-By:       W3 Total Cache/0.9.2.4
Content-Encoding:   gzip
X-Pingback:         http://codetunes.com/xmlrpc.php
Content-Type:       text/xml; charset=UTF-8
-->

