When faced with real life complexity there rarely is an easy way out or a silver bullet solution. Here I will describe the model I ve come up with during years of trial and error. The solution presented here is as far as I know not a mainstream one and it could be considered somewhat controversial. Object Oriented Approach Here we re living in OO land. Each and every problem can be broken down to…
Few days ago as I was happily chopping away on my duck taped Rails application I decided it was a good moment to measure up bottlenecks and optimize a bit. Here is overview of what I did. It consists of common sense actions that I picked up here and there, in my ongoing battle with slow applications. Starting position Application main index page is loading in about 4.5 seconds, Apache Benchmark…
I was an avid Linux user . I love tinkering with computers and Linux provided more than enough material. You need a lot of love and time to pursue things of such vast complexity. There was this one thought in the back of my head that kept bothering me. I understand that not everything has to work, but the fact that sound stops working on (almost) every upgrade was troublesome. It did not work any…
I think it was Josh Susser that first said: Ruby is the love child of Lisp and Smalltalk, raised by Perl the eccentric nanny. I really liked that quote. Of course I hated Perl at a time for being cryptic, outdated and old school. I assumed Perl had a little influence on Ruby, not even close to influence that Smalltalk and Lisp had. After a couple of years of looking at Lisp, Smalltalk and Perl I…
If you are not a movies fan, just to clarify that title is referencing movie that Keanu Reeves was playing in. It s not that famous one about the bus that needs to maintain speed over 50 MPH (I forgot the name, according to reddit it s called The Bus That Would Not Slow Down ). It is referencing that other movie about computers and shit. I can tell you that Lisp is indeed the red pill of truth. If…
Today I ve decided to put a stop on the Variable Reinforcement Machine effect. For quite some time, it was making me feel like a rat, constantly looking for another dopamine hit. Action plan I ve deleted accounts for: Facebook Twitter Google+ Reddit Google analytics Smartphone Every time I am outside and I have more than 5 seconds of idle time I will usually pull out my phone, hunch over it and…
Usual arguments for not doing TDD are: We have no time Brittle tests Too much work No real benefits Bad experiences with too much imposed testing (after manager single day agile training) We get payed for features, not tests Those are all valid arguments. I have no problem with that. If you ve tried it and it is not working for you, that s great. Some people try testing and are not quite sure what…
I am assuming: You are on OSX & using Gmail You can live without being in Gmail web interface 100% of time You don t mail that much from iOS You secretly hate Google and want to use their infrastructure as a dumb data pipe I suspect many, many people hate Gmail interface (and maybe even the whole Google interface approach). That s why Sparrow was doing rather well until it was neutralized .…
Do you love Vim? Do you love modal editing and motions? Do you hate terminal Vim not playing nice with OS X? (copy&paste problems). Do you hate Mac Vim occasional slowness(and OCD is making it worse)? Do you hate not being able to see the project tree that looks decent? Do you hate having to compile Vim to the specific version of Ruby in order to make the Command-T plugin work? Even though the…
I am going to list a couple of great features that are marked for Ruby 2.0 milestone. Combined map/select method Let say you want to map over an Enumerable and only keep elements that meet a certain criteria. You can do it in two calls like this: [ 1 , 2 , 3 , 4 ]. select ( & :even? ) . map { | i | i + 1 } ==> [ 3 , 5 ] [ 1 , 2 , 3 , 4 ]. map { | i | i + 1 if i . even? } . compact ==> [ 3 , 5 ]…
After discovering awesome power of Ruby that was somewhat inspired by Lisp I could not help but wonder if Lisp is truly Lambda the Ultimate as they say. First impressions Some brilliant and smart people are writing essays about it, for example Revenge of the Nerds really got me hyped. It is a language that has or can have any feature any other language has (and then some). It came to my attention…
I wasted better part of last week on building my own multiselect control in Backbone.js. After some hard crashes I ve decided to give existing plugins another twirl. Here is my overview: jQuery UI Multiselect jQuery UI Multiselect Pros: Mature Drag & Drop is cool Cons: Crude search Awkward to select (click works only on +, - signs) Needs to load full data set jquery.multi-select.js…
Photo credit: Wikipedia It s a fair question. Imagine you want to solve classical allocation problem where you need to divide sum on parts: 90/3 = [30, 30, 30] Of course you need to accommodate for the rounding on two decimals: 100/3 = [33.33, 33.33, 33.34] Few weeks ago I did a similar exercise as a part of coding kata. What I got was a small module under 30 LOC and with less than 5 lines…
Photo credit: stopnlook flickr Not testing at all is at one side of a spectrum, at the other end is testing everything. Those two are easy picks to rule out since the truth is almost always somewhere in between. I remember reading about one physicist building his own supercomputer. When asked why he did that he said something like this: I could have just given 2M dollars to IBM. They have a great…
In the small database that contains about one million records the need for some reporting arose. Since the system will work for at least 5 more years I was reluctant to just winging it with recapitulation tables and some SQL approach. The green pastures of OLAP have lured me long enough. My hopes where high, and my knowledge non existing. This is a tale of a man vs. the elements. In particular…
Lately pet peeve of mine is how to make small methods look more elegant. One idea was to use indentation for implicit end of small methods . Big problem with this is that this is only a wish. I was forced to just cram the method to one line and curse the destiny. For a while I was torn. I loved cramming small methods and hated the impact on readability it had. Couple of days ago it came to my…
This article will sum up my experiences with reddit and why I think it is not worth it to bother with. It all started this summer. Somebody has putted me on a HN and I went front page. 7k visitors was more that my tender brain could comprehend :) I didn t know it right away but in hindsight that put a link-aggregate bug in my brain. I am a long time occasional reddit reader. I know you are not…
Over the course of time I ve noticed three peculiar Ruby behaviours. I am not saying these things are good or bad. They are a bit odd/unexpected, mostly neat and always good to know. String concatenation spooky = "This " "is " "kinda" " spooky!" puts spooky #=> This is kinda spooky!" Default params hack If you want to know whether your default param remained default you can do it like this: def…
I like small methods. Small methods make comments unnecessary and allow me to describe algorithms in a way I will understand in couple of months when bug strikes. They allow me to develop domain and talk about domain in the code. There is just one thing bothering me: The excessive presence of end keyword. This is particularly bothersome for small methods. def numbered? ( line )…
I ve just read an excellent article about refactoring rcat in Rubies in the Rough. If you are not subscribed you should be I couldn t resist to take a swing at it and refactor Display class since thats where most of the action is happening. In one line rcat is supposed to behave as Unix cat command for some basic cases. This is original implementation, great stuff from the Practicing Ruby.…