Posts

Showing posts from 2012

Writing usable scripts in Ruby

Usable command line tools/scripts There are a lot of command line tools written in ruby, python, bash, c or any other languages. They are usable simply because there is a standard way in dealing with them this way can be summarized in the following points: There has to be a usage example/brief help at the finger tips of the user ( by running with  -- help      or -h) arguments should have default values which are explained in the help misusage or missing mandatory arguments should fire the help message ruby tools OptionParser  is part of the standard library in ruby that takes care of this script packaging.  they show long and short examples This is an example of the script: require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: script_name.rb [options]" opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|   options[:verbose] = v end end.parse! p options p ARGV # Actual script co

Success of Startups

Entrepreneurship has become one of the one of the most interesting topic in the business side in any country in the world. While it is digging its way in the middle east, there is some sort of confusion and a lot of aspects related to that topic. A Startup can act and advance to tackle business opportunities in a way that competes with large enterprises. and most of the times, they need to be supported by Investors to back them up. One of the things that started to really bother me in the culture is the definition of success of a startup. No one denies that a decent revenue generating startup is a successful one. However, some people believe that just raising an investment is a success.... umm, debatable. I believe we can make some kind of analogy with some entities that showed up in the past decade like biznas and skybiz (I'm sure some of you will remember those names).   they used an invalid scheme summarized as: People can register and join the network for a fee (as an i

Utilizing Page Caching while using query string parameters using Nginx

One of the common practices for ruby on rails developers is to wrap all parameters in the URI itself, so they can easily make use of page caching. Sometimes having a lot of parameters can start being confusing specially with the ordering of the parameters to match the defined routes. Let's elaborate with an example. Consider an API that provides a list of entries, with possible filters: http://api.example.com/feed.json This can simply be page cached, rails will place the proper feed.json file in the public directory. If we wanted to add use some supported filters like: date (in the format of 2012-03-25) order (by date, score or relevance) page (used to get the next pages of the feed) limit (or the page size.. the expected number of entries per response) type (some app related filter. let's assume the values can be: post, comment, announcement) If we used the simply form of http://api.example.com/feed.json?date=2012-03-25&page=2&limit=20&type=comment&order=score

Cuban Pete

Image
They call me Cuban Pete I'm the King of the Rumba beat When I play the marracas I go chick-chicky-boom chick-chicky-boom Yes, Sir, I'm Cuban Pete I'm the craze of my native street when I start to dance everything goes chick-chicky-boom chick-chicky-boom There Senoritas they sing and how they swing with this rumbero it's very nice so full of spice and when they dance and they bring a happy ring of vaqueros singing a song all the day long So if you like the beat take a lesson from Cuban Pete and I'll teach you to chick-chicky-boom chick-chicky-boom chick-chicky-boom Si, Senorita, I know that you will like the chicky boom chick 'cause it's the dance of Latin romance and Cuban Pete doesn't teach you in a hurry like Arthur Murray I come from Havanah and there's always manana * * * They call me Sally Sweet I'm the Queen of Delancy Street When I start to dance everything goes chick-chicky-boom chick-chicky-boom Excuse me Mister Pete have the Cub