January 26th, 2010 / No Comments » / by admin

Flvorful Bloggage : A Simple Pattern for Ruby’s inject method
Ruby’s inject is an often misunderstood method, but you would be surprised at how much it can help you clean up your code. I see many developers skipping over this method in favor of the non-injectified way, mainly because they dont get how to use inject properly. So we’ll take a look at some common examples and then you will be able to see the pattern that allows you to take advantage of inject.
4294967295 and MySQL INT(20) Syntax Blows - Laughing Meme
If you’re ever debugging a problem and you see the number 42-mumble-mumble-mumble-7295 you’ve run out of 32-bit storage. If you see 2-mumble-mumble-mumble-647 (2147483647) you’ve run out of signed 32-bit storage. 167-mumble-mumble-15 (16777215) you’ve run out of 24-bits and 65-mumble-mumble-35 (65535) you’ve run out of 16-bits of integers.
Chargify: Rails Powered Recurring Billing Service With An ActiveResource API
Over the last couple of months, a new billing and subscription company - Chargify - have been popping up around the Web 2.0, SaaS, and Rails scenes. Notably, Chargify’s CEO is Lance Walley, co-founder of Rails hosting company Engine Yard. Rails developers are a pretty entrepreneurial lot and Chargify have a lot to offer Rails developers who need to set up billing systems.
Pagetest - where web sites go to get FAST!
Welcome. Pagetest allows you to provide the URL of a webpage to be tested. The test will be conducted from the location specified and you will be provided a waterfall of your page load performance as well as a comparison against an optimization checklist. Please visit the PageTest wiki page for more information. Sample results for AOL.com can be seen here.
This tool lets you test web pages that are directly accessible as an URL from the Internet. If you need to test a page inside of a firewall or something more complicated than a web page (an authenticated product like webmail for example) please download the desktop version of PageTest which this is based on.
Tips For Sending Valid E-mails From Websites
E-mails are one of the key elements of a website/web application. They are used in contact forms, sign-ups, notifications, newsletters, etc.
It is a common experience that sometimes e-mails sent from websites go to the junk folders or never reach.
Although it is not always possible to detect the reasons for this, there are several things that we can do to minimize the risk. Here they are:
The Chris O Show: Gravatar default images - a better way
Hey, so at Harmonypark we decided to put gravatars into one of our applications (which is so easy it’s not funny) – and when the time came to select the default images for the gravatar I piped up: “I know how to fix this!” and pointed to a blog post I wrote about it long ago: (You can read it here.)
My colleague Ebony came up with a great solution: “Why not use another gravatar as the default image.”
Which is an utterly brilliant idea – that way the default image gravatar will scale correctly, and we wouldn’t have to mess around with having different image sizes for the different scaled default images. Here’s how we did it:
Find The Right JavaScript Solution With A 7-Step Test - Smashing Magazine
# How stable is the solution?
Is a good alternative available if this one doesn’t work?
# How easy is it to customize?
Do you need to be a JavaScript expert to modify the widget?
# How usable and accessible is it?
Are users who don’t have a mouse or are on a mobile browser blocked?
# Do you understand what’s going on?
Would you be able to fix a problem and explain it to others?
# Is it a contained solution?
Will other scripts be able to interfere with it, or would it contaminate the document?
# How dedicated is the developer?
Will the solution be maintained in the future?
# What is supported, and how can you extend functionality?
A new browser and client request is always around the corner?
InfoQ: Ruby Creator Yukihiro “Matz” about Ruby, Functional Programming and Programming Languages Design
In this interview, Yukihiro Matsumoto talks about programming languages design and decisions he had to take while designing Ruby. He also discusses other programming languages including Haskell, Scala, Python and Clojure. While talking about Ruby language and functional programming, Matz explores opportunities of integrating some of FP into Ruby and imagines a purer IO approach for it.
Tainted Data
“Tainted” objects are those that have come from some type of user input. Either from a file, the keyboard or the network, unless the object is a literal in the program or created by the program directly, it will be tainted. The tainted flag is always there on your objects, all you have to do is check it before you do anything unsafe. If you’ve confirmed that the data is indeed safe, you can then untaint the object.
Agile: In A Flash: Refactoring Inhibitors
With the need to avoid degradation, it’s important to recognize anything that might prevent a team from refactoring as much as they must. This card provides some inhibitors to refactoring that you should watch for.
Open-Source in Action
Several things will now happen, because we contributed back to the open-source library, instead of keeping this “addition” to ourself (and the client):
* other developers facing this same problem can now leverage our code when they use geokit
* other developers can now submit even more functionality, fixes or enhancements to our code, and even better support for problems we may have one day, meaning that we will eventually benefit from this too
* our client now knows that the code they relied on us to develop now has even more developers eyeing it, making sure it works
* our client (through us) is contributing to open-source, and can feel good about using open-source technologies, having fulfilled their part of the agreement they implicitly made, by leveraging the gains (and price) o
alex blabs - UTC vs Ruby, ActiveRecord, Sinatra, Heroku and Postgres
Now that I’m starting to use DelayedJob to perform jobs in the future in my Heroku Sinatra app, its important that they happen at the scheduled time. But unless you pay attention, you’ll find that times get mysteriously changed — in my case, since I’m in San Francisco in the wintertime, by +/-8 hours — which means that some conversion to or from UTC is being attempted, but it’s only working halfway.
Trying to keep a handle on which libraries are attempting, and which are failing, to convert times is a losing battle, so I’m trying to do the right thing and save all my times in the database in UTC, and convert them to and from the user’s local time as close to the UI as possible. Unfortunately, a variety of gotchas in Ruby and ActiveRecord and PostgreSQL makes this trickier than it should be. Here’s a little catalog of my workarounds.
nirvdrum’s Weblog :: On Amazon EC2 Spot Instances
A couple months ago Amazon announced support for EC2 spot instances. In a nutshell, a spot instance is an EC2 instance that you bid on and that Amazon creates and destroys based upon whatever spare capacity is available in a given EC2 availability zone (i.e., supply) and your maximum bidding price versus the current spot instance price (i.e., demand). A spot instance is less flexible than an on-demand or reserved instance is in terms of lifecycle, but could be significantly cheaper if your application can handle that volatility.
This post summarizes my experience with spot instances and how I make use of them.
has_many :bugs, :through => :rails: Active Record Query Interface 3.0
I’ve been working on revamping the Active Record query interface for the last few weeks ( while taking some time off in India from consulting work, before joining 37signals ), building on top of Emilio’s GSOC project of integrating ARel and ActiveRecord. So here’s an overview of how things are going to work in Rails 3.
Rails 3 Reading Material | Medium eXposure
Rails 3 is going to bring a lot of new stuff to the table. Wouldn’t hurt to organize some reading material in categorized and chronological order. So here goes whatever I scavenged so far. Leave comments so I can add more links or if I should mark something as obsolete.
Episode 104: Something New | Rails Envy
Episode #104: Something new. I’m sad to say that this will be the last episode of the Rails Envy podcast. I’m happy to say that Dan and I will be doing The Ruby Show which will follow the same general flow of Rails Envy. There’s no need to update your feeds (though you can if you’d like) because the feed will redirect for the foreseeable future. We’ve also got some other fun stuff planned so stay tuned!
Getting Up To Speed With Rails 3
I’m proud to announce that darwinweb.net is now running Rails 3.0-pre. I undertook the project as part of Bugmash last weekend, but it turned out to be a very deep rabbit hole; a two-day bugmash was too short to really dig into the meat of Rails 3 which is in ample supply.
The scope of changes to Rails is astonishing. There’s a lot of new blood contributing and brilliant ideas are popping left and right. The result is that Rails 3 represents a major maturation inflection point. It’s graduating from the scrappy, opinionated upstart to a very modular and full-featured framework containing what may once have been considered a disturbing amount of enterprise-readiness. It’s bittersweet and perhaps a bit ironic that the internals have acquired so many moving parts, but as a professional Rails developer the new flexibility and modularity is far too awesome to denounce in any way.
How to Make a Heatmap – a Quick and Easy Solution | FlowingData
In case you don’t know what a heatmap is, it’s basically a table that has colors in place of numbers. Colors correspond to the level of the measurement. Each column can be a different metric like above, or it can be all the same like this one. It’s useful for finding highs and lows and sometimes, patterns.
On to the tutorial.
Step 0. Download R
When should you store serialized objects in the database? | MySQL Performance Blog
A while back Friendfeed posted a blog post explaining how they changed from storing data in MySQL columns to serializing data and just storing it inside TEXT/BLOB columns. It seems that since then, the technique has gotten more popular with Ruby gems now around to do this for you automatically.
Perfection kills » Optimizing HTML
Mister Bleigh - Rails Quick Tip: Readable Conditional Validation
This is something that many may already use as a best practice, but if not it’s something simple and convenient to add to your repertoire. Sometimes you may have a model that requires additional information if a certain condition is met. For example, I may require a user to add more information about themselves if they wish to be listed publicly, whereas I would not if they do not wish to be listed. By combining ActiveSupport’s Object#with_options and ActiveRecord’s conditional validations, we can implement this behavior in a straightforward and readable manner (assuming here that there is a boolean field called “listed” in the database that is exposed as a checkbox or similar to the user):
PostageApp - Benefits & Features
Josh, The Rails Guy - Ruby, Rails & 5 Ways to Improve Performance
When I was speaking last night at the BIMA & Ultraspeed Virtualisation event on virtualisation and web application development, I was surprised to find that not a lot of people know about the simple ways that you can improve performance without much development or systems administration time at all.
In fact, most of the techniques that I’m going to go over aren’t new, and are pretty well publicised. Both Google and Yahoo! both go over them in tonnes of detail.
omgbloglol
This post is kicking off a series that I’m doing about moving your skills and migrating your code to Rails 3. I’ll be sharing some practical insights and covering some pretty in-depth topics as we go along (I’ve got some notes for entries about upgrading plugins, taking advantage of new features like the agnosticism, migrating applications, and so on), but before I go into a lot of specifics, I thought it might be useful to go over some of the high-level philosophical and architectural changes that have gone on in the Rails code between versions 2 and 3.
LukeW | Development Tools From An Event Apart
The An Event Apart conference in San Francisco, CA last month introduced me to a lot of interesting projects, frameworks, and tools for Web development. Though some of these have been around for a while, seeing them all together (compiled across all the speaker’s presentations) got me really excited about what can be done online. So you can share in that excitement too, here’s the list.
Sometimes It’s The Little Things « Grumpy Old Programmer
From time to time I trawl through my blog subscriptions: some are defunct while others may have changed their feed details sufficently that they’re no longer being picked up. I have about 270 subscriptions, which makes the job a chore and hence it doesn’t get done very frequently. The upshot is, for the case where the blog hasn’t just died, I sometimes miss something.
What should we do with tedious manual activities? Automate! I went and did some investigation.
Wait till I come! » How I build my data.gov.uk mashup – UK-House-Prices.com
UK-House-Prices.com is a web site to see how the prices in a certain area changed over the years using a data set released by the UK government as part of the data.gov.uk initiative.
ActiveWarehouse: Extract-Transform-Load Tool
The ActiveWarehouse ETL component provides a means of getting data from multiple data sources into your data warehouse. The links in the side bar provide additional information on ETL.
How To Create an IE-Only Stylesheet | CSS-Tricks
If you read this blog, there is a 99% chance you’ve had a hair-pulling experience with IE. But if you are worth your salt as a CSS coder, you should be able to deal with it. I am of the opinion that you can handle anything IE can throw at you without the use of hacks. Hacks are dangerous, since they are based on non-standard exploits, you can’t predict how they are going to behave in future browsers. The tool of choice for fighting IE problems is the conditional stylesheet. IE provides comment tags, supported all the way up to the current IE 8 to target specific versions, as well as greater-than/less-than stuff for targeting multiple versions at once.
Free Website Uptime Monitor: Uptime Robot
Uptime Robot is a totally free service which monitors your websites every 5 minutes & alerts you if they go down.
It allows you to monitor up to 50 websites & alerts can be received via e-mail or SMS
UK Launches Open Data Site; Puts Data.gov to Shame
A new website dedicated to making non-personal data held by the U.K. government available for software developers has launched today with the help of Sir Tim Berners-Lee, the inventor of the World Wide Web. Data.gov.uk is being slammed with traffic but six months after the U.S. government opened its Data.gov site the U.K. site already has more than three times as much data than the U.S. site offers today.
Ruby on Windows: Connecting to One of Many Open Documents
word = WIN32OLE.connect(’Word.Application’)
That works great if you have just one instance of the application running, with one or multiple documents open. But suppose you have multiple instances of the application running? How can you be sure that you connect to the instance with Document B, and not the instance with Document A?
nvie.com » Blog Archive » A successful Git branching model
In this post I present the development model that I’ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I’ve been meaning to write about it for a while now, but I’ve never really found the time to do so thoroughly, until now. I won’t talk about any of the projects’ details, merely about the branching strategy and release management.
ThinkingSphinx exits, enters ActsAsSolrReloaded | Diego Carrion
Annoyed with the situation of the project, I decided to fork the fork I liked the most and created a new repository called acts_as_solr_reloaded, with new features. This way, I hope the project gets easier to be found and that it gives more trust. I’m also compromising myself to keep the repository up to date and to pull contributions.
As today, the new features acts_as_solr_reloaded comes with are:
* support for dynamic attributes
* geo-localization or geo-spatial search
* integration with acts-as-taggable-on
* highlighting
* relevance ranking
jQuery Lint – James Padolsey
jQuery Lint is a simple script you can download and use with jQuery. It works over the top of jQuery and diligently reports errors and any incorrect usage of jQuery. It will also, to some extent, offer guidance on best practices and performance concerns.
Unlike JSLint, jQuery Lint is a runtime reporter.
Web Security: Are You Part Of The Problem? - Smashing Magazine
Website security is an interesting topic and should be high on the radar of anyone who has a Web presence under their control. Ineffective Web security leads to all of the things that make us hate the Web: spam, viruses, identity theft, to name a few.
pivotal’s refraction at master - GitHub
Luke Melia » Redis in Practice: Who’s Online?
Redis is one of the most interesting of the NOSQL solutions. It goes beyond a simple key-value store in that keys’ values can be simple strings, but can also be data structures. Redis currently supports lists, sets and sorted sets. This post provides an example of using Redis’ Set data type in a recent feature I implemented for Weplay.
Weplay members were told us they wanted to be able to see which of their friends were online, so we decided to add the feature. Let’s look at how Redis was instrumental in this functionality.
Should You Use JavaScript Library CDNs? « Lickity Split
JavaScript Library CDNs seem like a performance no brainer. Use the service, your site is loads faster and consumes less bandwidth. This post will explore if and under what conditions does a JavaScript Library CDN actually improve web performance.
Importing Legacy Data in Rails - blah blah woof woof | tim riley
ur current work project is a long-overdue rebuild of a critical business system as a modern Rails web app. We’re building this thing according to agile practices to the best of our ability. Each week we provide a new, working release that is an incremental improvement on the last. We’re not looking to replace the current system in a single swoop, and expect the new system to work alongside the old one for quite a while.
This means that we’ll need to maintain the same data in both systems for the duration of their lives together. We don’t want the new Rails app to access the data directly from the old app’s database, since this would prevent us from following the conventions that makes working with Rails so pleasant. Instead, we’ve come up with a way to import the legacy data into a new database.
airblade’s paper_trail at master - GitHub - sconover-code
PaperTrail lets you track changes to your models’ data. It’s good for auditing or versioning. You can see how a model looked at any stage in its lifecycle, revert it to any version, and even undelete it after it’s been destroyed.
Simple named_scope Searching | Viget Extend
One of the coolest aspects of named_scopes in ActiveRecord is their ability to chain together. One can chain a number of named_scopes onto each other, and the result is a single SQL query. Using this feature, I’ve come up with an easy way to do some simple searching.
jQuery 1.4 Released: The 15 New Features you Must Know | Nettuts+
jQuery 1.4 was recently released. This wasn’t simply a maintenance release as some had speculated; there are many new features, enhancements and performance improvements included in 1.4! This post covers the new features and enhancements that you may find beneficial.
Nginx Development Script for Passenger | Free PeepCode Blog
But even with the minimal configuration needed to create a new Passenger app, it’s inconvenient for spontaneous apps or small demos. If I want to try out a Rails 3 application with Passenger, I don’t want to configure a new virtual host for just a few minutes of experimentation.
At RailsCamp 6, PeepCode author Pat Allan showed a beautiful solution. It’s a script that starts Nginx from any directory3 using a shared configuration file. I modified it ever so slightly and posted a screencast above with a walkthrough.
On-the-fly image handling with Dragonfly @ Bamboo Blog
Dragonfly, a Rack-based ruby gem for processing/encoding on the fly.
Making Friends with FFI | Atomic Spin
Make friends. If you want your C code to play nicely with the other VMs out there, then FFI (foreign function interface) is the answer. FFI is built-in to JRuby and MacRuby; MRI requires a compiled gem for FFI access. After a night of experimentation, I was able to get C code from the Chipmunk Physics library running in Ruby via FFI (chipmunk-ffi). Just tell FFI what function to attach, what arguments it takes, what the return type is, and it will take care of the rest. FFI is a great tool that any Ruby developer should have in their tool belt and consider against writing a C extension.
Magic
Ruby FFI wrapper to the “magic” library, that determines content type and encoding of files and strings. The library does three types of tests: filesystem tests, magic number tests, and language tests. The first test that succeeds causes the file type to be returned.
Using Geokit with Searchlogic - Binary Logic
For those of you that don’t know, geokit is a great little gem that allows you to geocode addresses. It adds in very easy to use options in the ActiveRecord find method. Ex:
# will return all venues within 10 miles of the 10018 zip code
Venue.find(:all, :origin => “10018″, :within => 10)
The problem is that you can’t use geokit options in a named scope. Since searchlogic is named scope driven this presented a problem. So I wrote a little module that transfers geokit options from named scopes to the actual arguments of the method:
How to Create Facebook Style Footer Admin Panel | Web Resources | WebAppers
Trend All the Fucking Time (TRAFT?) | James on Software
My new years resolution was to measure more. For a while now, I’ve wanted to get a better picture of our systems and our business, and hopefully, how they relate.
So, my first day back at work after the holidays, I started looking for the right tool to gather data with. After investigating some of the options, I wound up settling on munin.
I say settling because I was quite dissatisfied with the available options. I tried everything from collectd to reconnoiter and found all of the solutions horribly lacking in some way. This is an enormous market just waiting for a startup to revolutionize it.
In any event, we were already using munin to trend our system metrics. So, now it was just a matter of figuring out how to get our business metrics in there. Here’s how we did
Powerful Color Manipulation with Sass : Nex3
There’s a lot of exciting stuff coming down the pipeline for Sass 2.41. I want to keep folks up-to-date on what they have to look forward to, so I’m starting a series of blog posts detailing the new features I’ve been working on.
New Color Functions
One of the new features I’m most excited about is a huge expansion in the color-manipulation capabilities of Sass. Sass has always supported arithmetic with colors, allowing them to be added, subtracted, and even multiplied. For example, #f00 + #00f = #f0f in Sass.
Ruby 1.9 character encoding field notes · Fingertips
As you probably already know the String class became encoding aware in Ruby 1.9. This makes it possible to manipulate strings on the character level instead of on byte level. However, it’s still a general purpose API which means writing a few lines of code to get stuff done.
It’s common to choose one internal representation for character data in an application and convert all incoming strings to this representation. For example, in modern applications strings are often encoded in UTF-8 or UTF-16. I took some time to figure out how to do this in Ruby 1.9.
ActiveModel: Make Any Ruby Object Feel Like ActiveRecord « Katz Got Your Tongue?
Rails 2.3 has a ton of really nice functionality locked up in monolithic components. I’ve posted quite a bit about how we’ve opened up a lot of that functionality in ActionPack, making it easier to reuse the router, dispatcher, and individual parts of ActionController. ActiveModel is another way we’ve exposed useful functionality to you in Rails 3.
zerosum dirt(nap) - Resque Mailer
Following in the footsteps of DelayedJobMailer, ResqueMailer allows you to shift processing of your existing mailers to an async Resque worker without doing pretty much anything. Just install the gem in your Rails project (via Gemcutter) and then mix the Resque::Mailer module into your mailer.
Website Performance: What To Know and What You Can Do - Smashing Magazine
The good news (and hard truth) about performance is that 80 to 90% of poor performance happens in the front end. Once the browser gets the HTML, the server is done and the back-end developer can do nothing more. The browser then starts doing things to our HTML, and we are at its mercy. This means that to achieve peak performance, we have to optimize our JavaScript, images, CSS and HTML, as well as the back end.
Phusion Passenger 2.2.9 released « Phusion Corporate Blog
Phusion Passenger is under constant maintenance and development. We are pleased to announce Phusion Passenger version 2.2.9.
Fixed compatibility with Rails 3.
What’s up with the Gem Bundler?
Fixed support for ActiveRecord subclasses that connect to another database.
[Nginx] Fixed PCRE URL.
Posted in: Ruby on Rails
January 8th, 2010 / No Comments » / by admin

Ruby/Rails: Loading Seed Data for Tests | Pathfinder Development | Software Developers | Blogs
Rails 2.3.4 includes a new rake task for loading seed data called db:seed. It suggests keeping all seed data as a ruby code inside of db/seeds.rb file. The issue with this is this is not DRY. You have duplicate set of representation for seed data: one side of seeds.rb and one in fixture files (.yml). Keeping them in sync is a pain and all the other disadvantages that come with not having single source of truth.
BBC - Web Developer: Always read the label
Text fields in forms need to have labels, so that people know what they’re meant to enter into them. Next to a username field, for example, it’ll say something like “Enter your username”. The HTML you’d use for this would involve a label tag, with id and for attributes tying everything together. The association between label and input lets the browser know which hint applies to which field.
Mocking and Stubbing can be evil - Rails Freak
Lately I’ve been seeing some things that make me worry. Mocking and stubbing can be very helpful tools when you use them right, but I am not seeing them used right!
tipsy
Tipsy is a jQuery plugin for creating a Facebook-like tooltips effect based on an anchor tag’s title attribute.
rgrove’s sanitize at master - GitHub
Sanitize is a whitelist-based HTML sanitizer. Given a list of acceptable elements and attributes, Sanitize will remove all unacceptable HTML from a string.
Using a simple configuration syntax, you can tell Sanitize to allow certain elements, certain attributes within those elements, and even certain URL protocols within attributes that contain URLs. Any HTML elements or attributes that you don’t explicitly allow will be removed.
Because it’s based on Nokogiri, a full-fledged HTML parser, rather than a bunch of fragile regular expressions, Sanitize has no trouble dealing with malformed or maliciously-formed HTML. When in doubt, Sanitize always errs on the side of caution.
Subdomains and sessions to the rescue! | Plataforma Tecnologia Blog
We have been working on an application that allows administrators to create accounts for their users. Each account will be accessible under a subdomain, so we needed to setup a subdomain environment inside our application, and also in our development machine. In addition, we must be able to let the users signed in among several subdomains, as a user can access other accounts when allowed.
After some research we decided to go with the subdomain-fu gem, which is great to give your application the ability of handling subdomains. Another great resource we have used is Ryan Bates’ screencast about the subject. But they did not solve our problem completely, so here we are going to document a few steps to help you get up and running easily with subdomains and sessions.
Strangest language feature - Stack Overflow
A bunch of examples of the principle of most surprise.
darwinweb.net
Recently I found myself wanting to use Rails validations semantics outside the context of saving an object. It wasn’t enough to force save without validations because I actually wanted to have some validations applied to the life-cycle of the object, and other validations for various other purposes including user feedback and control flow of other object modifications.
I ran a few searches on Github and came up with a few interesting projects including soft_validations, validation_groups, validation_scenarios (the closest to what I was looking for), and partially_valid. However none of these really hit the nail on the head. Either they didn’t expose enough of validations goodness, or the syntax just didn’t fit what I was looking for.
Confreaks: RubyConf 2009 Post-mortem
No doubt many of you are wondering why the RubyConf and JRubyConf videos are taking so long to release this time around. We felt it was important to share a few more details about some of the challenges we’ve been facing this time around.
Rails 3 beta eyed for late January release | Developer World - InfoWorld
Ruby on Rails 3, an upgrade to the popular Web development framework that merges Rails with the alternative Merb framework, is due to be offered as a beta release by the end of this month, the founder of Rails said on Monday afternoon.
If it is not out by the end of this month, then the feature-complete beta will be out in February, said David Heinemeier Hansson, founder of Rails. General release of the completed Rails 3 framework is targeted for the first quarter of 2010. With the beta release, builders of Rails seek to ensure backward compatibility with previous versions of Rails and want live applications running on the upgrade.
Christmas Gem: Redcar 0.3.0dev at Redcar
Redcar is an open-source programmers’ text editor for Ruby, written in Ruby. It is designed to be compatible with Textmate bundles (a work in progress) and run cross-platform on JRuby. Redcar is currently in the middle of begin ported to JRuby, please subscribe to get updates on our progress.
How Not To Sort By Average Rating
PROBLEM: You are a web programmer. You have users. Your users rate stuff on your site. You want to put the highest-rated stuff at the top and lowest-rated at the bottom. You need some sort of “score” to sort by.
WRONG SOLUTION #1: Score = (Positive ratings) - (Negative ratings)
Why it is wrong: Suppose one item has 600 positive ratings and 400 negative ratings: 60% positive. Suppose item two has 5,500 positive ratings and 4,500 negative ratings: 55% positive. This algorithm puts item two (score = 1000, but only 55% positive) above item one (score = 200, and 60% positive). WRONG.
Gravatars: why publishing your email’s hash is not a good idea
There is a piece of information which must be made public, though. It’s this 32 char string which serves as a token for your web browser to retrieve the right image. How much information are we leaking to the bad people inhabiting the internet? Can that key be used to retrieve our email?
The email’s hash gives a quick way to check whether a certain email is the one associated to your profile. Given a list of emails, you can check whether the user has registered with one of them.
Rackamole: Rack-Based Monitoring For Your Ruby Web Apps
Rackamole (GitHub repo) is a Rack application that lets you to monitor the interactions between users and your own Rack-based application (e.g. any Rails or Sinatra app). As well as pumping out information to the console or a log file, there’s a Web interface called Wackamole to give you the skinny on your app activity.
gist: 268192 - Rails 2.3.5 on App Engine- GitHub
We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working. Rails 2.3.5 currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.
Cryptic Ruby Global Variables and Their Meanings | Purify Blog
How many times have you looked at some ruby code and found strange variable names (eg. $0, $:, etc) and wondered what they meant? Below is a list of cryptic global variable names in ruby and their meanings.
‘Re: Why Git is so fast (was: Re: Eric Sink’s blog - notes on git,’ - MARC
So. Yes, its practical to build Git in a higher level language, but you just can’t get the same performance, or tight memory utilization, that C Git gets. That’s what that higher level language abstraction costs you. But, JGit performs reasonably well; well enough that we use internally at Google as a git server.
Debian/Ruby Extras - Dear Upstream Developers
Dear developer,
Your library/application is very good, and we would like to integrate it into our favorite distribution, so many more people would benefit easily from it. However, it would be great if you could make our work as easy as possible by following those guidelines.
Distribute your software as a source code archive
RubyGems is a useful tool for developers, but isn’t a good tool for the general distribution of your software (see this page for more information).
Distribute your software as a .tar.gz archive. .tar.gz is the most widely used archive format on Linux. Using other formats (.tar.bz2, for example) is discouraged, as it requires additional steps for the packager. A .zip file could be provided for Windows users.
Including the version of the software in the name of the archive is also a very good idea.
I <3 ruby-warrior - Steve's Blog
Every Saturday, I take some time out from my normally crazy schedule and work on XOmB, the operating system my friends and I have been working on. It’s usually a really nice break from my usually crazy schedule, hanging out with good friends and working on something completely different from what I’m normally working on. Pitt’s finals are coming up soon, and so most of the team is preparing. So rather than work on XOmB, I decided to take the week off and play around with something I heard about at the Pittsburgh Ruby Brigade’s meeting this week: ruby-warrior.
Adam Lowe: VIM Destroys All Other Rails Editors
Now that I have your attention, I’ve come across quite a few blog and forum posts from people looking for “the best” text editor or IDE to use for Ruby on Rails development. I was fortunate enough to meet Tim Pope soon after I got interested in Rails and was subsequently introduced to the awesomeness that Vim is capable of. It took some ramp up time to get comfortable with modal editing but now I find myself frustrated when I don’t have all the power that comes from Vim’s modal mindset.
A simple way to make birthday queries easier and faster at Xaprb
Queries to “find all birthdays in the next week” and similar are always a nightmare to write. If you want to see a bunch of examples, go look at the user-contributed comments on the MySQL date and time function reference. This post is about a slightly saner way to do that. There’s still some nasty math involved, but a) a lot less of it, and b) at least the query will be able to use indexes[1].
So here’s my tip: instead of storing the user’s full birthdate, just store the month and day they were born. Try it. You’ll love it!
Diving deep into user behavior with Google Analytics, Event Tracking, and jQuery
In a default Google Analytics setup, the information you have about your users’ navigation behaviors and preferences is limited to which pages they viewed and where they came from. But what does that really tell you about how your users behave inside your web pages? Not much, and that’s where all the juicy behavioral insight comes from.
alexjsharp.com Bundler is the new hotness: deploying rails apps with bundler and capistrano
This post is a compilation of useful tidbits I’ve learned from a few different sources as I’ve moved a rails app over to the new gem dependency hotness, bundler. There are a few steps involved here, and seeing that I’ve done the legwork in figuring them out, I figured I’d share what I’ve learned.
The Perils of 3rd Party APIs - ReadWriteStart
You never believe your home is going to be damaged by an earthquake, but for some it happens. If you build on a platform you don’t control, is this akin to laying your foundation on a fault line?
win32console 1.3.0 prerelease – DEV_MEM.dump_to(:blog) - Multimedia systems blog
I mentioned in previous post that I was working in a updated version of win32console.
So, just pushed to Gemcutter the prerelease version (_beta1_) so you guys can test with your current Cucumber/RSpec scenarios.
Paypal Adaptive Ruby Gem Released | Tommy Chheng
I have been tinkering with the new Paypal Adaptive Payments API and created a simple ruby gem to interface with it. Still pretty new but I’m using it with little problems so far. Submit bug reports if found. See the code at github
0×1fff: 35 Google open-source projects that you probably don’t know
Google is one of the biggest companies supporting OpenSource movement, they released more than 500 open source projects(most of them are samples showing how to use their API). In this article I will try to write about most interesting and free releases from Google, some of them might be abandoned.
Wandering Freelancer : Freelancing Gods
At a recent Melbourne Ruby meet, I was asked to speak about my travelling freelancer lifestyle, and the talk was recorded. I feel a little self-conscious about the topic, but perhaps you’ll find it interesting.
2009 Ruby survey results - GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS
Here are the results as we head into 2010.
There are result reports linked to from within each section, and this post does not comprehensively list all the results, so click through if you’re interested.
Issue #5: Winter Jam
SD Ruby - Episode 072: MongoDB
Scott Motte introduces us to the document-oriented database MongoDB and shows how to use MongoDB as an alternative to MySQL and ActiveRecord using the MongoMapper gem.
Sanity-check features in MySQL at Xaprb
MySQL has a couple of sanity-check features to help keep you from doing dumb things.
* max_join_size is a configuration option for the mysqld server program. It throws an error if you write a query that the optimizer estimates will examine more than this number of rows.
* –safe-updates is a command-line option to the mysql client program. It throws an error if you write an UPDATE or DELETE without a) a WHERE clause that refers to an indexed column or b) a LIMIT clause. It also sets the max_join_size and select_limit variables.
Interesting technologies in a new Rails application | Atomic Spin
About three weeks ago Ryan and I started a brand new Rails project. That in and of itself isn’t interesting, but some of the technologies we’ve pulled in are: * bundler * git-deploy * cancan * gritter * culerity
I like Unicorn because it’s Unix
Eric Wong’s mostly pure-Ruby HTTP backend, Unicorn, is an inspiration. I’ve studied this file for a couple of days now and it’s undoubtedly one of the best, most densely packed examples of Unix programming in Ruby I’ve come across.
Unicorn is basically Mongrel (including the fast Ragel/C HTTP parser), minus the threads, and with teh Unix turned up to 11. That means processes. And all the tricks and idioms required to use them reliably.
Main Page - MonoDevelop
MonoDevelop is an IDE primarily designed for C# and other .NET languages. MonoDevelop enables developers to quickly write desktop and ASP.NET Web applications on Linux, Windows and Mac OSX. MonoDevelop makes it easy for developers to port .NET applications created with Visual Studio to Linux and to maintain a single code base for all platforms.
Inside Ruby on Rails: Benchmarking your Ruby scripts – Simone Carletti’s Blog
Rails comes with a benchmark core extension built-in that extends the default benchmark Ruby library introducing the ms method. Unfortunately, the code doesn’t appear to be documented in the Rails API so you need to browse the source code to read its implementation.
Rails and Merb Merge: The Anniversary (Part 1 of 6) | Engine Yard Blog
A year ago today, we announced that Rails and Merb would merge. At the time, there was much skepticism about the likelihood of the success of this endeavor. Indeed, The most common imagery invoked by those who learned about our plans was a unicorn. At RailsConf last year (well into the effort), both DHH and I used unicorns in our talks, poking fun at the vast expectations we’d set, and the apparent impossibility of achieving everything we’d said we wanted to achieve for 3.0.
Upgrading Rails Applications – Some things to keep in mind! | Pathfinder Development | Software Developers | Blogs
So we just went through this humongous (believe me!) effort of upgrading the technical platform for one of our existing Rails applications that was running Rails 2.1, Ruby 1.7 and Mongrel cluster. The goal was to upgrade to Rails 2.3, Enterprise Ruby 1.8.6 and Passenger. It all started out as well as you would think. Updating the Rails gem, Ruby version, installing/configuring Passenger and updating relevant gems was pretty quick and smooth. Some quick and dirty testing of the application did not reveal any major problems or issues. Great! You are thinking the upgrade is mostly done att this point before you move on to the tests in the application!
Generating Thousands of PDFs on EC2 with Ruby « Rails Dog
For about two months, we’ve been working on a static website that exposes the results of complicated economics model to non-economists. We decided to make the site static because of the overhead involved in computing the results and the proprietary nature of the model. We would simply pre-generate the output for all valid permutations of the inputs. The visitor could then choose her inputs from a questionnaire, click a button and immediately be shown the results.
The caveat of this decision is that in addition to the numerical outputs, three graphs and a summary (both in HTML and PDF) would need to be generated for each permutation. Since there were 3600 permutations, this would amount to 18000 files in total. Initial local runs of our generation process took about 30 seconds for each permutation, mostly due to embedding the graph images into the PDF. On a single machine, that would take 30 hours of uninterrupted processing! Clearly, this was a job for “the cloud”.
Easy Accessibility Testing with the NVDA Screen Reader (Yahoo! Developer Network Blog)
Among the various testing environments, screen readers remain one of the gray areas for many developers. There are a few reasons for this: sometime people ask why do they need to bother. But perhaps many of you ask “where do I get one?” or complain, “I don’t know what to do with this thing.” I hope this article will answer the last two concerns. Perhaps I’ll try to persuade you why you should bother in another article. Hopefully, though, you already know why accessibility is important for web development.
Dealing With Gem Development Dependencies | Atomic Spin
I have been working on a DataMapper adapter for a RESTful JSON web service. I put together a gem that includes the adapter implementation, as well as a few DataMapper::Resource classes that can be used as a starting point. I did not want to install my gem’s dependencies globally while developing it, so I ended up trying a couple of different things to manage my development environment.
Code: Flickr Developer Blog » Flickr Engineers Do It Offline
It seems that using queuing systems in web apps is the new hottness . While the basic idea itself certainly isn’t new, its application to modern, large, scalable sites seems to be. At the very least, it’s something that deserves talking about — so here’s how Flickr does it, to the tune of 11 million tasks a day.
Kartar.Net » Yes Mum, I’ll Behave: Beginning Behaviour Driven Infrastructure
So can we apply Behaviour Driven Development to our infrastructure to test that it is behaving correctly? Enter Behaviour Driven Infrastructure. Behavioural Driven Infrastructure or BDI applies the principles of Behavioural Driven Development to the management of infrastructure.
Ordering and comparing text in Rails and MySQL · Fingertips
Ordering and comparing text is a lot trickier than a lot of people expect, computer scientists even came up with a complicated name for it: collation. There are two groups of problems associated with collation: cultural and technical. Today we’re not going to focus on technical problems, but rather how the cultural problems influence the technical solution.
An example of a cultural difference is letter ordering in a language, in Swedish the Ä is ordered after the z and in German it follows the letter a. You can also discuss whether the ä is an alternative form of the a or if it’s a completely different character, this is relevant when implementing search. When searching for ‘nächste’ you might also be interested in text containing ‘nachste’.
Announcing Appsta 1.1.0 - Elliott J Draper - Freelance Developer
Appsta is at its core a library of helper methods for use in Rails templates, to help you build useful Rails app creation scripts that can cut down the amount of time it takes for you to get a new Rails app up and running with your standard setup. Everyone makes some initial modifications every time they break out the “rails” command, and by encapsulating this in a Rails template, you can save some time. Appsta added helper methods for setting up projects on GitHub, and setting up hosting environments on Heroku, amongst other things.
mycheckpoint | openark forge
mycheckpoint is an open source monitoring utility for MySQL, with strong emphasis on user accessibility to monitored data.
It is SQL oriented: charts, reports and advances metrics are generated on the fly with views. There is no need for an external program to diagnose the data. In fact, mycheckpoint’s main duty is to to a one-time creation of a special purpose schema.
Recording of data is performed via a single INSERT command, which takes measurements from GLOBAL VARIABLES, GLOBAL STATUS, MASTER STATUS and SLAVE STATUS. There is no requirement that this measurement is taken by mycheckpoint itself.
_why’s Estate
Hey, welcome to my collection of why the lucky stiff links. Everything _why has published on the internet should be accessible from here. It works sort of like a museum that sells maps. Many of his abandoned writings are mirrored locally here, and everything else is through external links. I’m not sure who I’m talking to, so I’ll leave it at that.
Crowdsourced document analysis and MP expenses
As you may have heard, the UK government released a fresh batch of MP expenses documents a week ago on Thursday. I spent that week working with a small team at Guardian HQ to prepare for the release. Here’s what we built:
http://mps-expenses2.guardian.co.uk/
It’s a crowdsourcing application that asks the public to help us dig through and categorise the enormous stack of documents—around 30,000 pages of claim forms, scanned receipts and hand-written letters, all scanned and published as PDFs.
Tender Lovemaking » Blog Archive » Writing Ruby C extensions: Part 1
I like writing C extensions for Ruby. In this series of blog posts we’re
going to explore writing C extensions. I will cover topics including setting
up the development environment, TDD, debugging techniques, dealing with
Ruby’s garbage collector, cross compiling for windows, and more.
Rails Envy Podcast – Episode #103 | Rails Envy
Rails Envy Podcast – Episode #103
Why I think Mongo is to Databases what Rails was to Frameworks // RailsTips by John Nunemaker
Wait till I come! » cURL – your “view source” of the web
What is cURL?
OK, here goes. cURL is your “view source” tool for the web. In essence it is a program that allows you to make HTTP requests from the command line or different language implementations.
gotascii’s metaprogramming at master - GitHub
Intro to Ruby Meta-Programming
A collection of notes, codes and various further readings that accompanied the December 12th Hackday event.
SteamCode: Ruby and Simple Dynamic Programming
I’ve been reading”Ruby Best Practices” by Gregory T. Brown and it’s well worth checking out for anyone interested in Ruby. I’m in the middle of Chapter 3, “Mastering the Dynamic Toolkit” and thought I’d share a some simple bits of code that actually use dynamic programming.
We actually make use of the fact that with Ruby you can add a method_missing method to any class that allows you to capture calls to any method that are … well missing. Here’s a simple example that shows how it works.
Nati Shalom’s Blog: The Common Principles Behind the NOSQL Alternatives
A few weeks ago during my Qcon presentation, I went through the patterns of building a scalable twitter application, and obviously one of the interesting challenges that we discussed is the database scalability challenge. To answer that question I tried to draw the common pattern behind the various NOSQL alternatives, and show how they address the database scalability challenge. In this post I’ll try to outline these common principles.
Changelog - Episode 0.0.7 - Mike Dirolf from 10gen and MongoDB
Adam and Wynn spoke with Mike Dirolf from 10gen about their fast-growing MongoDB project. Mike gave us insight on how MongoDB came about, design decisions, and the future of this cool NoSQL server.
Changelog - Episode 0.0.6 - Steven Bristol from LessEverything and weekly news
Episode 0.0.6 - Steven Bristol from LessEverything and weekly news
In this episode, Adam, Wynn, and Steven Bristol of LessEverything fame discuss Erlang, Javascript on the server, Lighthouse, Docsplit, Rackamole/whackamole, unfollowing under-performing Twitter peeps, and suing domain squatters.
James on Software | Introducing Friendly: NoSQL With MySQL in Ruby
To make a long story short, we decided to fall back to MySQL. It’s battle hardened. We know its production characteristics and limitations. Backups are a science. We know we can count on it.
But, we have a lot of data, and adding fields and indexes was starting to get painful. Flexible schemas are one of the things that attracted me to NoSQL in the first place. Then, I remembered this article about How FriendFeed uses MySQL to store schema-less data. So, I decided to implement the system they describe in the article.
Since we put Friendly in to production, we’ve seen a significant increase in site performance. Friendly’s built-in caching has achieved a hit rate of 99.8%. We’re pretty happy with things so far.
Everything Sysadmin: How to make a product “sysadmin-friendly”?
At the most recent conference I moderated a panel of system administrators who had been in the audience watching the first day of presentations. It was our turn to “speak up” about what we had seen.
One of the useful things that came out of this panel was a list of “signs that a product was designed to be easy for system administrators to install and maintain.”
Here is a short version of the list:
NoSQL with MySQL in Ruby - Friendly
Store schema-less data in MySQL.
Evolve your data model without feeling the pain of migrations.
Build indexes offline
Building an index can take hours with a lot of data. Stay agile without taking your app offline.
Write-through and read-through caching baked right in.
Fast websites make more money. The 99.8% cache hit rate we see in production is a one-liner with Friendly.
Inside Ruby on Rails: Delegate – Simone Carletti’s Blog
If your project includes ActiveSupport, and every Rails project does, you have a more clean and easy way to implement the delegation pattern: the Module#delegate extension. It provides a delegate module you can use in your class or in your modules to delegate a specific method to an associate object.
Saving Arrays, Hashes, and Other Objects In Text Columns Using Active Record | Integrum
Have you ever wanted to store an array, hash or object in a database column? Using Active Record and YAML makes this completely painless. To do so, you must specify this with a call to the class method serialize. This makes it possible to store arrays, hashes, and other non-mappable objects without doing any additional work.
Posted in: Ruby on Rails