Tag Archives: ruby

Rails Challenge: Day 2

I’m loving this “radical transperancy” experiment. Already I’ve had so manyoffers of support and great advice from RoR people around Melbourne andelsewhere, it’s made it worthwhile for day 1. Morning admin, reading andcatch up took a while though! Decks not clear to start until 11AM.

11AM – After reflecting overnight, I think Rails is muddying the picture forme at the moment – what I really need is a Ruby GEM which I’m going toimplement with Fibres that handles the basic streaming. Downloaded thisbasic Rails framework which wraps a Twitter REST client.https://github.com/jnunemaker/twitter-app/

11.30 – Registered a new app for testing, implemented the keys into the testapp and gave it a run!

1.40PM – Lots of fail. Errors and no idea why. Post lunch, stepping backto do some basic things first, still not sure how the whole Rails world fitstogether, maybe a bit more walking before running is in order…

2PM – Confusion runs riot installing RSPEC. Python installs modulesglobally, but looks like Rails loads Gems with each app (so had to run gemrspec_rails from the project directory). Can see the benefit, but trickedme for a bit.

2.05PM – More dependencies… RSpec wants autotest, then we need webrat. Webrat needs NokoGiri… Or at least some extensions that come with it…* sudo apt-get install libxslt-dev libxml2-dev* sudo gem install nokogiri* sudo gem install webrat

2.54PM – Database configuration with MySQL. More supposedly “default” railsthings that just aren’t installed. Somewhat tedious! Still, getting the hangof it now.* sudo gem install mysql23PM – Almost… looks like I need to specify it in the GemFile. All makessense, but the getting started guide could make mention ofit! Finally a successful rake:* rake db:create

4.50PM – Break while I collected son from school, but lots of good progress.Created some basic controllers, routes and views / HTML templates. Gettingthe hang of it. Now I’m going to try be a bit more ambitous and plug inTwitter OAuth. If I have this all “under control” I think the correct stepswill be:* Install the gem and enable it in the GemFile* Create a Twitter Controller with a few different action points(authenticate, callback) and then implement the OAuth code into these.

Wrap up for the day – I finished up around 9.30. Turns out that my problemswere more Twitter than rails related and to do with OAuth_Callbackparameters (something for another post). I did eventually get somethingworking, which is almost ready now, so I feel I’m making some good Railsprogress. Also I think that the client I used at the start of the day WOULDwork, it was a Twitter related issue.

I know Twitter are chaning their OAuth flows to be more compliant though, soa little bit of time here to make sure it’s implemented right is worthwhile.

It was a fairly interrupted day with my wife away in Sydney, daughter sickand school and dinner duties.

Rails Challenge: Day 1

You can read about the Rails Challenge here.

10AM – After various Monday tasks and email, started on the challenge. Aquick search for Ruby on Rails leads me to http://rubyonrails.org/. Theyadvise using Ruby 1.9.2 or 1.8.7, but the link to download leads to 1.8.7. I know we were asked to use “latest versions” so going to go for 1.9.2. Off to http://www.ruby-lang.org/en/downloads/ where I find 1.9.2. A quickdownload then squiz at the README. From the directory you extracted Ruby in:* ./configure* make* make test* sudo make installVoila! Ruby 1.9.2 installed and ready to go.

10.25AM – OK, play with the language – run through the quick start.http://www.ruby-lang.org/en/documentation/quickstart/* Got to be happy – fire up the shell, type irb and there it is (somethingmust of worked!).* First page done, nothing unusual or unexpected there.* Second page… some interesting syntactical things with Ruby. Like the wayit does string substitution, very clean and clear.

def h(name = "World")        puts "Hello #{name.capitalize}!"    end
  • Like the ? syntax to interpret if something is a boolean or not. Seemsvery well thought out as a language.
  • On balance slightly more in that Quick Start 20 minutes example than canbe explored in 20 minutes (I don’t think I can type that fast) but a goodintro.

11:00AM – Back to the Rails stuff. Rails tells me to get RubyGems. Followedthe links, downloaded, tried to install. Tells me it’s an upgrade… Littlebit of research. Turns out that RubyGems 1.3.7 ships with the latest Rubyalready. Type gem at console and sure enough, there it is.

11.10AM – sudo gem install rails

11.24AM – While that install ran, I researched IDE’s by asking around onTwitter plus a bit of searching. Deciding between a full IDE and perhaps astandard editor with a bit syntactical sugar, I’ve decided to go for thefull IDE. Mostly because I need all the hints I can get given that it’s allnew. So the suggestions I had back (ignoring the expected ribbing about notwanting to use VIM):

  • Komodo 6
  • NetBeans
  • RubyMine
  • BlueFish
  • Geany
  • Aptana Rad Rails

In the end I’ve decided to go for RubyMine. Keeping in mind this was NOT anextensive eval, main decision factors – obvious GIT integration (others mayhave it but this clearly lists it) and Twitter use it (I know they are a bigrails shop). Downside to RubyMine – $70, but there is a 30 day free trial –I figure I may as well get started with a good strong editor, then bearingin mind this is only a 2 week experiment anyway, it will either be worth theupgrade, or I won’t need it any more (or I’ll know enough to make aneducated choice on a different editor).

11.35AM – Right, that’s the IDE downloading and the rails install out theway. Let’s create a Rails Framework now.

1PM – Bit of a break there, Alex came back online, catch up after weekendand re-synch with activities for today then feed kids lunch.So creating the rails framework was easy.

  • rails new source/railstest

Now in theory, I should be able to start rails by running this from that newdirectory:

  • rails server

No dice – crashed…

1.48PM – Well that slowed us down! Long story short, latest Ruby / Railsrelies on the latest version of SQLite3, not installed on my PC. I had thefollowing error:

Could not find gem 'sqlite3-ruby (>= 0, runtime)' in any of the gemsources listed in your Gemfile. Try running `bundle install`.

After trying lots of different things (including running bundle install) Iresolved by downloading the latest SQLite3 from herehttp://www.sqlite.org/download.html, ran ./configure, make and make install,then tried bundle install again from the railstest directory (the app I’msetting up).

Finally, success.

1.50PM – Rails app up and running!

Booyah!

3.25PM – Coffee break and then managed to get RubyMine set up. Needs theSun JDE (doesn’t like Open Java) :–( Register with Oracle, 72Mb downloadlater… Wait, make that 2 installs later (downloaded the RPM first, no goodfor Ubuntu). Finally once I had the path setup properly I could install /run RubyMine.

  • export JDK_HOME=“/usr/lib/jvm/java-6-sun/”
  • .//bin/rubymine.sh

Took almost 1hr and a half for this step :–( Still hopefully pays off havingan IDE. Took a bit of time here to explore the basic IDE and play with therailstest app I setup earlier and see where all the bits went. I will saythis – there’s a heck of a lot more guff installed with a Rails app thanDjango!

3.40PM – Minor distraction – hunt down some online shopping for Master 8’sChristmas present.

4PM -OK, meat of the day. Try and find a Twitter library and install it.Mat Kelcey recommended https://github.com/jnunemaker/twitter/ which looksgood, but we want some streaming support.

4.20PM – Wow, lots of searching and flicking through Twitter Ruby GEMs, thecoverage here is a lot worse than Python. Really surprises me! I thoughtRuby would have some strong libaries. The library recommended by Mat isbest, but no streaming support. The few streaming libraries don’t includeOAuth support and are generally weak.

4.30PM – Looks like we might need to use EventMachinehttps://github.com/eventmachine/eventmachine/wiki. Thin also looksinteresting – a Python Tornado equivalent? http://code.macournoyer.com/thin/

6PM – Reading, reading reading. Going to call it quits here – lots to thinkabout on how to implement a streaming Twitter app with OAuth support – lotsof bits and pieces but no one GEM I can pull that does it all. Seriouslythinking about cutting my own to do all the pieces together.

Reflection on startup life: Week 55

The way in which people use product is endlessly fascinating.  For example, with Trunk.ly (which collects links from multiple sources) one of the very first features that most people requested was to filter links by source.  So we added this in.  A week after launch, no one is using it.  So does that make it invalid? ie. Should we “not” deliver that function?  

I think the question is more complicated than that – sometimes there are things that people want in the first 5 minutes that’s very different from what they need once they experience the product.  One premise of Trunk.ly is that it collects and indexes links from multiple sources.  Allowing a user to filter by source is a first five minutes experience that helps them quickly confirm the promise of the product.

It’s something that Twitter and Facebook spend a lot of time on, yet most people don’t see it.  If you register a new Twitter account there’s virtually an entire application around helping you get started and get connected that’s something you only use in the first five minutes.  I’ve registered a lot of Twitter accounts this last 12 months and that experience is continually changing and enhancing (to the point that as an “experienced” Twitter account creator it’s annoying, but I am a minority I suspect).  Yet if you registered your account more than 6 months ago, you’ll never have experienced any of this substantial amount of screen design and effort on Twitter’s part.

We launched a new version of Trunk.ly which went smoothly enough.  There were lots of minor bugs in there, but we fixed them quickly enough.  We continue to get a lot of interest in Trunk.ly and increasing numbers of people registering for access which is exciting.  It’s still a little way from opening it up more broadly, but it’s getting there.

Unfortunately it looks like Trunk.ly will have to remain on the back burner for the next few weeks.

Last week was very focussed on making sure we got one of our projects for SportsGeek finished – fingers crossed the minor bug I fixed this morning sees that project now complete. I won’t spoil Sean’s fun by saying what the project is, but Alex and I are both pretty excited that the first client Sean has signed up and will be launching with is an NBA team.

This week we launch into a Ruby on Rails project.  For those playing along at home, you might have a WTF moment… as of course we are primarily a Python / Django shop. 

To cut a long story very short, we had a series of really interesting email conversations around a potential project, the end result of which was “let’s do this”.  We were all on a similar wavelength and were excited about working together, but right at the end realised that Python / Django wasn’t going to suit this customer as a Ruby on Rails shop.  We needed to find a creative way to make it work – so we’ve committed to a pilot in Ruby on Rails.  Over a couple of weeks we’ll develop some of the core components, mostly on our time as we are learning as we go with a new language.  At the end of that we’ll submit it for review and if it’s good enough, we’ll negotiate from there.  Once we suggested this, they agreed and then proposed some funding to ensure we are compensated at least a little for our time (these guys are awesome – really fair, above board and straight shooters – the kind of clients you want to work with).

Of course there’s lots we need to do that we DO already know – front end, HTML, JavaScript, Twitter API and how to work with it robustly etc.  I’ve programmed to some degree with C64 Basic, Fortran, Pascal, FoxPro, Visual Basic for DOS, VB4, C#, C, C++, SQL Server Scripting, Python / Django and now Ruby.  It’s safe to say I’ve forgotten more than I remember!  Ruby / Rails is just another step on the road.

I thought as part of this “challenge” I’ll make it entertaining and for the next couple of weeks I’m going to geek out here on the transition from Python / Django to Ruby / Rails by posting daily updates. I think I’ll call it “Rails Challenge” so feel free to ignore these if you’re not into languages.

Highlights
  • Ignite talk on Wednesday – great event and well run by Mark Mansour.
  • SportsGeek project done
  • New Trunk.ly launch
Lessons Learned
  • Billing is a pain – especially when your bank stuffs up transactions and you can’t even tell if its you or them!
  • Creative persistence is worthwhile.
Goals this week
  • Learn Ruby on Rails and cut some code!