<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thoughtless Banter - John Bellone &#187; Pennies for Thought</title>
	<atom:link href="http://thoughtlessbanter.com/category/pennies-for-thought/feed/" rel="self" type="application/rss+xml" />
	<link>http://thoughtlessbanter.com</link>
	<description>Musings from an east coast software developer, writer and reader.</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:18:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Two Years Down</title>
		<link>http://thoughtlessbanter.com/2012/01/02/two-years-down/</link>
		<comments>http://thoughtlessbanter.com/2012/01/02/two-years-down/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 20:59:23 +0000</pubDate>
		<dc:creator>JB</dc:creator>
				<category><![CDATA[Pennies for Thought]]></category>
		<category><![CDATA[Bloomberg]]></category>

		<guid isPermaLink="false">http://thoughtlessbanter.com/?p=884</guid>
		<description><![CDATA[Two years ago (tomorrow) I started my first day as a temporary contractor at Bloomberg, and at the end of February I was brought on full-time. Since then I&#8217;ve been able to work with an amazing bunch of people, and without them I&#8217;d surely be in a gutter somewhere clutching an empty bottle of Odesse [...]]]></description>
			<content:encoded><![CDATA[<p>Two years ago (tomorrow) I started my first day as a temporary contractor at Bloomberg, and at the end of February I was brought on full-time. Since then I&#8217;ve been able to work with an amazing bunch of people, and without them I&#8217;d surely be in a gutter somewhere clutching an empty bottle of Odesse vodka. Instead I am occasionally in the gutter, which is usually directly related to drinking with <a href="http://twitter.com/seejohnrun">John Crepezzi</a> or <a href="http://twitter.com/_kennyk_">Kenny Katzgrau</a>, but at least I have moved on to some finer whiskey. Of course when I&#8217;m not in the gutter I have a well stocked shelf of various spirits. The goal is to eventually be sipping Johnny Walker Blue on a nearly regular basis.</p>
<p>Some shout outs: Becks, Shiran, Adam F., Amy, Renée, Rahul, Adam L., and of course my amigo that is soon to be on his way back from a long overdue vacation, Peter. For those of you that I forgot its probably because we haven&#8217;t drank in some time. I think its time to remedy that situation!</p>
]]></content:encoded>
			<wfw:commentRss>http://thoughtlessbanter.com/2012/01/02/two-years-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blu-ray Is Not Going Anywhere</title>
		<link>http://thoughtlessbanter.com/2011/12/07/blu-ray-is-not-going-anywhere/</link>
		<comments>http://thoughtlessbanter.com/2011/12/07/blu-ray-is-not-going-anywhere/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 04:05:18 +0000</pubDate>
		<dc:creator>JB</dc:creator>
				<category><![CDATA[Pennies for Thought]]></category>
		<category><![CDATA[Blu-ray]]></category>
		<category><![CDATA[HD]]></category>
		<category><![CDATA[Hulu]]></category>
		<category><![CDATA[Netflix]]></category>

		<guid isPermaLink="false">http://thoughtlessbanter.com/?p=868</guid>
		<description><![CDATA[It seems to be the popular opinion that the Blu-ray disc format was a complete failure, and we&#8217;re on the verge of completely going digital for everything that we consume: music, movies, and video games often the primary candidates being associated with this philosophy. Of course, it is very hard to argue against that. The [...]]]></description>
			<content:encoded><![CDATA[<p>It seems to be the popular opinion that the <a href="http://en.wikipedia.org/wiki/Blu-ray_Disc">Blu-ray disc</a> format was a complete failure, and we&#8217;re on the verge of completely going digital for everything that we consume: music, movies, and video games often the primary candidates being associated with this philosophy. Of course, it is very hard to argue against that. The past decade we have seen <a href="http://steampowered.com">digital distribution systems</a> which deliver video games directly to your personal computer. Your game library is now completely &#8220;in the cloud&#8221; and immune from hard disk failure. We saw <a href="http://itunes.com">iTunes</a> rise to the top of ladder when it comes to purchasing music digitally, and whole host of others for streaming live music to your devices over the Internet. How can anyone forget the gorilla in the room: <a href="http://netflix.com">Netflix</a> video streaming services make up for approximately thirty-two percent of all U.S. Internet traffic during peak hours.</p>
<p>Given everything above it is very hard to argue against physical mediums going the way of <a href="http://en.wikipedia.org/wiki/Betamax">Betamax</a>. Lately the talk has mostly been about the Blu-ray disc format, mainly due to the competition when it was first introduced with <a href="">HD-DVD</a>, but now because the pressure has been turned on with streaming services like <a href="http://hulu.com">Hulu</a> and <a href="http://netflix.com">Netflix</a>. But if you look at the trends in consumer devices, especially television purchasing, you can see that many people that did not buy high definition sets last decade are going out to purchase them now, and they&#8217;re looking specifically at 3D high definition set ups. Right now the only consumer disc format to support 3D is Blu-ray, which requires the use of high resolution (bitrate) audio.</p>
<p>If consumers want that crisp, clear, high definition video with surround sound, they&#8217;re not going to be able to get it over your standard Internet connection in the United States. In order to stream Netflix at 720p with high definition audio you&#8217;ll need at least a 5 megabit/second Internet connection. My <a href="http://comcast.net">Comcast</a> Internet connection is the lowest tier available, as far as I know, which <a href="http://http://www.speakeasy.net/speedtest/">I measured</a> at roughly 25 megabit/second to east coast data centers. The average speed for broadband in the United States is well under that threshold, pegged at 4 megabit/second, which would allow you to stream the &#8220;medium quality&#8221; from Netflix. Remember we&#8217;re only talking about 720p here, delivering content at 1080p would require much more bandwidth than that, but the average speed here is already struggling to deliver what consumers expect.</p>
<p>If that wasn&#8217;t enough the cable broadband providers across the United States are beginning to look towards changing their pricing models to reflect how Internet video distribution is cutting into their cable television subscriptions. That means you&#8217;ll be paying more money for your pipe, and have a cap on it before you&#8217;ll end up being charged more (usually by the 10GB increment) to fully utilize Internet streaming.</p>
<p>This summer <a href="http://money.cnn.com/2011/09/19/technology/netflix_qwikster.cnnw/index.htm?iid=EL">Netflix announced the plan to split their DVD video service into a separate entity</a>, and due to <a href="">rising costs of the content they are now providing</a> Netflix was also forced to increase the subscription service rates by 60%. These changes resulted in a consumer backlash and <a href="http://www.google.com/finance?cid=672501">Wall Street punished the stock with a drop of more than 70% since July</a>. Reed Hastings, Netflix CEO, <a href="http://paidcontent.org/article/419-netflix-ceo-compares-company-to-bank-of-america-and-oakland-as/">tried to provide an explanation and give a half-hearted apology</a>, but ultimately it turned out to be more of an excuse.</p>
<p>Ideally it would be amazing to stream high definition audio and video over the Internet with full clarity. This <em>obviously</em> is the future, but we&#8217;re only at the beginning of exploring this technology. In the coming years we&#8217;re going to realize higher bandwidth through the local Internet providers which will give services such as Hulu and Netflix the capability of delivering video streams <a href="http://www.youtube.com/watch?v=9U7e_quvkPQ">surpassing even the highest quality that televisions support now</a>. But don&#8217;t get it in your head that you&#8217;ll be throwing away your video discs anytime in the near future, at least if you care anything about surround sound, high definition video, and <a href="http://www.amazon.com/gp/product/B003ZSJ212/ref=as_li_ss_tl?ie=UTF8&#038;tag=thoughbanter-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B003ZSJ212">finally being able to own Star Wars in a quality format</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thoughtlessbanter.com/2011/12/07/blu-ray-is-not-going-anywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Furniture For Men</title>
		<link>http://thoughtlessbanter.com/2011/11/23/furniture-for-men/</link>
		<comments>http://thoughtlessbanter.com/2011/11/23/furniture-for-men/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 17:57:43 +0000</pubDate>
		<dc:creator>JB</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Pennies for Thought]]></category>

		<guid isPermaLink="false">http://thoughtlessbanter.com/?p=796</guid>
		<description><![CDATA[A few months ago I got an apartment on my own, without a roommate, and found myself in quite a pickle: the only furniture that I owned as a living room coffee set, a few chairs that I acquired from the Zinkk Inc office, and some randomly assorted Ikea pieces. After putting out my desperate [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I got an apartment on my own, without a roommate, and found myself in quite a pickle: the only furniture that I owned as a living room coffee set, a few chairs that I acquired from the <a href="http://zinkkinc.com">Zinkk Inc office</a>, and some randomly assorted Ikea pieces. After putting out my desperate (not really) call to family (and friends) I started to search around for some local bargins because let&#8217;s face it, why the fuck was I going to spend a lot of money on things to sit on in an apartment that I am barely at?</p>
<div id="attachment_803" class="wp-caption alignnone" style="width: 410px"><a href="http://thoughtlessbanter.com/wp-content/uploads/2011/11/adf.jpeg"><img src="http://thoughtlessbanter.com/wp-content/uploads/2011/11/adf.jpeg" alt="Table Design" title="Faux Design " width="400" height="318" class="size-full wp-image-803" /></a><p class="wp-caption-text">Table Design</p></div>
<p>I did a little searching on <a href="http://etsy.com">Etsy</a> and found there were a couple of desks that I fancied, some badgering and trips to the local hardware store later I had a plan for a desk. I consider myself a very minimalistic person when it comes to furniture, sure it needs to look good, but ultimately all I care about is that it gets the fucking job done.</p>
<p>The choice was to build it with three eight food pieces of pine, and stain it to match as closely as possible to my living room set, since the desk would be at the center of the situation going on up in there. The legs were built from steel piping which was linked together with various elbows, unions, and fasteners, after being sanded down and painted with some rustoleum. Three two-inch holes were cut into the back of the desk to throw down some computer wires to allow the table to be flush up against the wall. A cross bar the length of the table would be used for stability.</p>
<div id="attachment_809" class="wp-caption alignnone" style="width: 490px"><a href="http://thoughtlessbanter.com/wp-content/uploads/2011/11/382838_579953273829_199800257_31936110_435392411_n.jpg"><img src="http://thoughtlessbanter.com/wp-content/uploads/2011/11/382838_579953273829_199800257_31936110_435392411_n.jpg" alt="" title="Table Top" width="430" height="286" class="size-full wp-image-809" /></a><p class="wp-caption-text">Top of the table without the holes or the legs.</p></div>
<p>After the success of the table I started to get drunk with power, and began dreaming up various shelving units, platform beds, that can be relatively easily be made with wood, steel piping, and a little bit of elbow grease. But before filling out an application for the Home Depot contracter&#8217;s credit card there was something else that I wanted to try to get done with the scrap I had lying around.</p>
<div id="attachment_807" class="wp-caption alignnone" style="width: 410px"><a href="http://thoughtlessbanter.com/wp-content/uploads/2011/11/asd.jpeg"><img src="http://thoughtlessbanter.com/wp-content/uploads/2011/11/asd.jpeg" alt="" title="Traffic Lamp Design" width="400" height="377" class="size-full wp-image-807" /></a><p class="wp-caption-text">Traffic Light Lamp</p></div>
<p>A little over a year ago I sniped an auction on eBay and procured a traffic light for relatively cheap. At one point I was going to hack it with an <a href="http://hackaday.com/2010/01/05/arduino-traffic-light/">ardunio unit</a>, but after moving once or twice I thought it would be a lot better to turn this bad boy into a lamp. The only problem is that it weighs quite a considerable amount, and the stand itself would have to be quite beefy. While thinking out the table design the lamp stand was a natural second choice for the next project.</p>
<p>The planning stages are still underway, but I figured it would be approached in the same fashion: going to the hardware store, looking for some cool shit to throw together, and beginning the sanding, painting and piping. The only difficultly here is obviously the whole electricity thing, but I am pretty sure that I got that covered.</p>
<p><div id="attachment_798" class="wp-caption alignnone" style="width: 442px"><a href="http://thoughtlessbanter.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-23-at-12.03.43-PM.png"><img src="http://thoughtlessbanter.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-23-at-12.03.43-PM.png" alt="Call to Arms: Bean Bag Chair" title="bean bag chair" width="432" height="367" class="size-full wp-image-798" /></a><p class="wp-caption-text">Call to Arms: Bean Bag Chair</p></div>
<p>Next up something to plop my fat ass down onto and watch Netflix, play some video games, and pound away at the keyboard on. A good buddy of mine suggested buying a <em>LoveSac SuperSac</em> which is essentially a memory foam bean bag chair. That&#8217;s right, a 100 pound, 6 foot wide, bean bag chair. It is damn comfortable. As you can tell, my choice of a chair caused a lot of commotion on that website called Facebook.</p>
<p>The chair is micro-leather, which really means fake fucking leather that they can sell at a premium but is much easier to clean, and came packed into several different packages. You literally had to tear open the packaging, toss around the memory foam, and stuff the casing with this burlap sack full of lumpy foam. It was a huge pain in the ass, but in the end proved to be an perfect addition to the man-cave.</p>
<div id="attachment_812" class="wp-caption alignnone" style="width: 490px"><a href="http://thoughtlessbanter.com/wp-content/uploads/2011/11/383280_578568533859_199800257_31925166_610852852_n.jpg"><img src="http://thoughtlessbanter.com/wp-content/uploads/2011/11/383280_578568533859_199800257_31925166_610852852_n.jpg" alt="" title="Chair Before The Table" width="480" height="287" class="size-full wp-image-812" /></a><p class="wp-caption-text">My chair at the apartment before I had the table fully set up for equipment.</p></div>
<p>It definitely pays to have a little creativity (and a father with a garage full of power tools) and an open mind when you are looking at furnishing an apartment. This type of furniture probably does not suit everyone, but I have a particular taste which I think is highlighted quite well with the steel piping and stained wood finish. If the lamp goes as well as I hope my future projects will likely include a shelving unit for the kitchen to extend my &#8220;pantry,&#8221; and I&#8217;ve already started looking at new ways to improve on the design of table (union screw locks, larger lengths of pipe). If anyone is interested I&#8217;m available for hire provided you have some beer and food.</p>
<div id="attachment_808" class="wp-caption alignnone" style="width: 297px"><a href="http://thoughtlessbanter.com/wp-content/uploads/2011/11/376900_582560793339_199800257_31945791_264034435_n.jpg"><img src="http://thoughtlessbanter.com/wp-content/uploads/2011/11/376900_582560793339_199800257_31945791_264034435_n.jpg" alt="" title="Finished Table With Equipment" width="287" height="480" class="size-full wp-image-808" /></a><p class="wp-caption-text">The (nearly) finished product with all the computer equipment.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://thoughtlessbanter.com/2011/11/23/furniture-for-men/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ Web Server</title>
		<link>http://thoughtlessbanter.com/2011/07/21/c-web-server/</link>
		<comments>http://thoughtlessbanter.com/2011/07/21/c-web-server/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 10:54:37 +0000</pubDate>
		<dc:creator>JB</dc:creator>
				<category><![CDATA[Pennies for Thought]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://thoughtlessbanter.com/?p=784</guid>
		<description><![CDATA[So, this morning I couldn&#8217;t sleep, and around 4:00AM I started messing around with nginx, fastcgi and C++. For awhile now I have been considering the feasibility of an extendable and reusable framework for serving up web content from C++ applications. Of course, all you web programers want to write code in Javascript and Ruby, [...]]]></description>
			<content:encoded><![CDATA[<p>So, this morning I couldn&#8217;t sleep, and around 4:00AM I started messing around with nginx, fastcgi and C++. For awhile now I have been considering the feasibility of an extendable and reusable framework for serving up web content from C++ applications. Of course, all you web programers want to write code in Javascript and Ruby, but sometimes there are applications that can be core to a company that do not need to (or should not) be rewritten merely to service a different type of client. I wrote a little test program that I <a href="http://github.com/johnbellone/cpphttp">threw up on my Github.com account</a>.</p>
<p>That&#8217;s my reasoning for developing this simple proof of concept application. I didn&#8217;t want to actually download the fastcgi libraries that exist for C, mainly because it was 4AM and I am a lazy fuck, so I decided to write up something simple with accept(), recv() and send(). The actual configuration for nginx is quite simple, you can just use their example for proxying to an Apache web server.</p>
<p>For those of you that are just as lazy as I am, <a href="https://github.com/johnbellone/cpphttp/blob/master/main.cc">click on this big bad beautiful link</a>, and enjoy the show. Later, at some point, I will write up my thoughts on how an actual framework to solve this problem may work (and look), but right now I need to take a shower and go to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://thoughtlessbanter.com/2011/07/21/c-web-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Model Scopes in Rails 3</title>
		<link>http://thoughtlessbanter.com/2011/03/06/model-scopes-in-rails-3/</link>
		<comments>http://thoughtlessbanter.com/2011/03/06/model-scopes-in-rails-3/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 19:53:14 +0000</pubDate>
		<dc:creator>JB</dc:creator>
				<category><![CDATA[Pennies for Thought]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Arel]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Type Aloud]]></category>

		<guid isPermaLink="false">http://thoughtlessbanter.com/?p=762</guid>
		<description><![CDATA[I am going through the Type Aloud code trying to improve queries, implement some fragment caching, and generally clean anything up that I can before flipping the proverbial switch on this bad boy. I came across something a few weeks ago that, combined with the awesomeness that is Arel, makes my life a hell of [...]]]></description>
			<content:encoded><![CDATA[<p>I am going through the <a href="http://typealoud.com">Type Aloud</a> code trying to improve queries, implement some fragment caching, and generally clean anything up that I can before flipping the proverbial switch on this bad boy. I came across something a few weeks ago that, combined with the awesomeness that is <a href="http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/">Arel</a>, makes my life a hell of a lot easier writing queries.</p>
<p>These <a href="http://www.railsrocket.com/rails-21-named-scope">named scopes</a> have been around in Rails for awhile now, but as always I am coming late to the party. Because Type Aloud contains &#8220;draft mode&#8221; where stories and chapters can both be in an unpublished state I need to be able to call only the <em>chapters</em> and here is a quick, simple way to do that on the model.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">scope <span style="color:#ff3333; font-weight:bold;">:published</span>, <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
   joins<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:story</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">where</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:disabled</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:stories</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:disabled <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">includes</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:story</span>, <span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>The named scope will filter out any chapters that are not published or any chapters in stories that are not published. This is very important when displaying, let&#8217;s say, a random chapter for reading that may not have yet been published in an existing story. The last statement at the end there will eager load the story (and user) because there really is never an instance where I don&#8217;t want the story (user) records associated with this. Here are the queries that are executed.<br />
And here and the queries that are executed from this little snippet.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`chapters`</span><span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`chapters`</span> <span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`stories`</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #ff0000;">`stories`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">`chapters`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`story_id`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`chapters`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`disabled`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`stories`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`disabled`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`stories`</span><span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`stories`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`stories`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`users`</span><span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`users`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`users`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>And of course, this is what the signature looks like from the controller.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@chapter</span> = Chapter.<span style="color:#9900CC;">published</span>.<span style="color:#9900CC;">limit</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span></pre></div></div>

<p>For this particular operation it resulted in a 0.5ms improvement in time spent during the Active Record phase. That may not sound like a lot, but it actually is a 19 percent time optimization. Good stuff!</p>
]]></content:encoded>
			<wfw:commentRss>http://thoughtlessbanter.com/2011/03/06/model-scopes-in-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Object Caching 535/592 objects using memcached

Served from: thoughtlessbanter.com @ 2012-02-05 10:18:54 -->
