Written on 05 Apr 2013.
There are currently 5 different Redis add-ons available on the Heroku platform.
Redis To Go, Redis Cloud, openredis, MyRedis and RedisGreen
Which do you choose? I imagine there's a fairly long tail of Heroku apps that use one of the free Redis tiers offered by the providers that have one, but there must also be (me included) a pool of developers who want to develop and test on a single Heroku instance using a free tier, and then ramp everything up to a billable level once they go live.
For me the decision was based on who gives you the most for free.
Whilst I have no experience in running a hosted Redis service and what impact free tiers have on profitability, it seems unlikely that when faced with 5 options a developer is going to go for one they can't try for free. That would rule out openredis and RedisGreen straight away (chepeast tier $10 and $169 per month, respectively).
With the remaining 3 options you will be left to compare and contrast simultaneous connections and database size. MyRedis gives you 5Mb and 3 connections, which knock them out of the race.
So then you're left with RedisCloud and Redis To Go. Both have the same number of simulatenous connections (10) which leaves RedisCloud as our winner because they give you a 20Mb instance over 10Mb.
Does this make logical sense? Perhaps not, but I can't be the only one who has gone through this thought process. It might make more sense to look at the higher tiers which will match your intended capacity, but there's a great opportunity to get customers in by offering a good quality free tier.
When I went live and ramped up, did I research the next tier up? Nope, just hit upgrade on my RedisCloud free tier.
Written on 28 Mar 2013.
I've often wondered as to the best way of having two form buttons that can submit but yield slightly different actions. Turns out HTML5 scratches that itch with the `formaction` attribute.
The formaction attribute specifies the URL of a file that will process the input control when the form is submitted.
In my case, it's going to the same (Sinatra) controller action route, but by appending a simple URL parameter (`?action=this`) you can modify the response/control to change behaviour accordingly.
Simples
Check it out on W3Schools
Written on 27 Mar 2013.
After setting up a handful of Windows 8 laptops it dawned on me that the much debated operating system still refuses to set your timezone based on your region selection.
You'd think by now that when you tell Windows you are in the UK and would like a UK keyboard layout, it might be able to then set the timezone to London/GMT/BST. Nope. Still defaults to the US West Coast.
Written on 24 Aug 2012.
Interesing piece on The Pug Automatic about creative uses for the Rails `flash` function. Although the implementations differ, the Ramaze version of `flash` will enable you to do much the same things.
I particularly like the idea of passing down "one off" event data to a JavaScript embed, so you can potentially fire of Google Analytics (or other) tracking messages on a one-off basis, without having to embed excessive controller style logic in your views.
A good reminder in the comments, as well, about not caching any views where you are likely to be using this, as people will either end up with other people's flashes, or stuck with the same flash for X minutes/hours.
Read more...
Written on 21 Aug 2012.
I've been subscribed to Rubyflow for a while now, and it yields a few gems (sorry) every now and then. Today is Dan Watsons' quick post on setting a default value for an empty hash key value:
order = hash.fetch(:order, :desc)
And of course, the comments give us another great tip on setting the default value accross the entire Hash:
h = {} ; h.defaut('my_default_value')
Which can then be shorthanded again in the Hash.new initialiser:
irb(main):003:0> x = Hash.new('my_default_value')
=> {}
irb(main):004:0> x.keys
=> []
irb(main):005:0> x['no_keys_but_default_value']
=> "my_default_value"
Handy indeed.
Dan's site here...