Cobalt Edge

 

HotelTonight is Hiring Rails and iOS Developers

App_icon_114x114
HotelTonight has job openings for great Rails and iOS developers!  I'm quite excited about this, as our company/product is off to an amazing start, and we're continuing to move fast, and expand.  We'll stay a small and nimble team, but do want additional developers to take things up a notch.  For iOS this opportunity will be building an iPhone app essentially from the ground up, and you should be well versed in Objective-C, Cocoa Touch, iOS SDK, etc.  The Rails gig will likely cover a wide range of areas, as it's a lot more than just an API for the mobile app (there's a lot going on behind the scenes).  We're also looking at mobile-specific web apps/features/functionality.

HotelTonight is an awesome place to work.  We have a truly great team and culture.  We're primarily growing our team in San Francisco (we'll open an office there early this year, currently based in San Mateo), but if you're a great developer, get in touch regardless.  We're all passionate about the mobile space, technology, and travel.  
Developers check out the jobs, but please no outsourcers or recruiters.

Filed under  //   Jobs   Rails   iOS  

Comments [0]

HotelTonight - our new iPhone app for same-day hotel bookings

This blog has been silent, due to working very hard on HotelTonight.  HotelTonight is a new mobile (iPhone to start) app that makes it super easy to book same-day or last minute hotel stays.  If you've headed into the city for a wedding, or a night on the town, for example, and decide you don't want to drive home; or maybe you're working late and just need to crash for the night, HotelTonight gives you a great rate (much better than if you just walked up to the hotel to see if they had a room).  Furthermore, we allow you to book a room until 2am!  Try that with any other service.  We show you the specific hotels we have (and we have awsome ones like the Ace in New York, or the Nikko in San Francisco).  The app has great photos of the hotels, and information that's important for such last minute bookings.  It's a game changer for hotel bookings.

Media_httpwwwhotelton_kcgta

You can install the iPhone app today, or if you're on Android, BlackBerry, or other mobile platforms, follow us on Twitter, or friend us on FaceBook to find out when we're on other platforms.  Also, even if you don't need it today, it's good to install it now, and get in on the $10 we give you towards your first purchase, whenever that may be.  As soon as you sign up, we add the $10 credit, and it doesn't expire.  We're doing a bunch of other awesome promotional things too.  Check out the Facebook page for how to get a free night, or follow us on Twitter to watch for ways you can snag more credits.

As of today, we're in San Francisco, New York, and LA/Hollywood, but we'll be expanding that shortly.  We work directly with the hotels to get great rates, and make the process as easy as can be.  The HotelTonight team has worked really hard on this, and I've personally really enjoyed building this app, and would love to hear your feedback.

Comments [0]

DealBase is Hiring Developers

Are you the type of person who checks flipboard before you get out of bed? Is a git-based workflow fundamental to your daily coding?  Is writing Ruby like writing English (only a lot more fun)?  Itching to use Rails 3?  How about Coffeescript?  Do you want to build beautiful user interfaces on top of kick-ass web apps/services?  What about mobile apps; are you yearning to build a great one that uses location, has great design and UX, and will disrupt non-mobile online businesses? Are you masterful at leveraging existing tech when possible and creating purpose-built solutions at other times?  Do you communicate well with an entire team and enjoy having the opportunity to give your opinion?

Yes?  Then DealBase wants to talk to you! We're a well funded travel deals site run by a team who have been very successful in online travel. We have a stellar set of investors (Ron Conway, Founder Collective, and several other prominent valley angels).  We are less than 2 years old and already profitable with over 1 million monthly visitors.  We're adding a lot more to the DealBase.com website and expanding our product line into some exciting new areas and need great people to make it happen. 
 
Why join us? We have a results oriented culture, offer competitive compensation and give you unlimited vacation time. We have fun nights out in San Francisco, go to premiers and crazy events in Vegas and some of us are even doing the NorCal ToughMuddr. We're runners, skiers, foodies, espresso fiends, travelers and passionate about what we do.

Requirements:
  • Demonstrated work experience with Ruby, Rails, JavaScript, HTML, CSS, git, databases, Linux, Mac, and testing (TDD/BDD).
  • Four year college degree
  • Located near one of our offices - San Mateo, CA or Portland, OR
Things we are not interested in:
  • No contractors, outsourcers, development firms, etc. This is a full-time position, where you will be an integral part of the team.
  • No recruiters please
If you're interested, send resume/work experience, cover letter, and information to devjobs@dealbase.com

Comments [0]

Cybercrime Adventures at the Eugene Modern Web Developers Meetup

Last night's Eugene Modern Web Developer's meetup was a lot of fun.  Nick told the story of his real life adventures tracking down a very serious cyber-criminal.  This included reverse engineering rootkits, walls of assembly code printouts with pins and strings to help explain the code (just like you'd see in the movies (well, the pins and string thing, they aren't usually stuck to code)), and building small programs to help investigate (and lead to the apprehension of the primary evil-doer).  He told the story very well, and it was a great time.

This morning I sent the group a bunch of links to things that came up during the talk, or, in the 3 hours after the talk that Rob (@robhudson), Nick, and I hung out and continued to talk.  A bunch of books were mentioned throughout the night, and I think I've covered all of them below, as well as Nick talked a bit about PLT Scheme, and so on.  Here are the links I'd sent out to the group:

Comments [0]

Tricky Rails Callbacks and Deleting Associated Records

UPDATE: As it turns out, the below solution was totally rookie!  The whole issue is still there, but the need to solve it with the use of update_all (which is a bit brute force and generally something to avoid for just updating a couple attributes on a single record, it avoids validations, etc, etc.), was not necessary.  As it turns out, there are association callbacks. I'm kind of surprised I hadn't seen this or thought of it.  But, there are callbacks to be notified when associated records are added, or removed (and both the before and after variations). So, instead, instead of setting the update_lowest_and_highest_rates as an after_update, specify an after_remove callback on the association:

  has_many :fares, :after_remove => :update_lowest_and_highest_rates

Then implement the update method like:

  def update_lowest_and_highest_rates

    fares.reload

    set_lowest_and_highest_rates

    save

  end

And note, set_lowest_and_highest_rates, is the same method as the create_lowest_and_highest_rates, just renamed.  It's renamed because now you'd use before_validation or before_save or whatever is needed in your case, instead of the _on_create variant of that.  The rest of the problems are still there (needing to refresh the fares association, and the general aspect of all this, etc.), but this is a much nicer solution I think.

I recently ran into some tricky issues related to deleting records on an association combined with ActiveRecord callbacks.  The issue may seem like an edge case, but from googling for solutions, clearly it's not an uncommon need.  An example will illustrate the problem...

 
I'll use a sort of pseudo-example from DealBase.  Let's take a flight "Deal" model.  It has_many "Fares", which are just prices for the deal from one airport to another.  A Deal accepts_nested_attributes_for Fares.  This lets us edit a deal and all its fares in one form, etc.  As part of this, you can select to delete a fare.  We're using the standard mechanism of the _delete parameter and a checkbox, etc.  So far, so typical.
 
In order to optimize searching and so on, we keep track of the lowest and highest rates from the fares in the deal record (i.e. we denormalize these values).  To determine these low and high rates, we use an ActiveRecord callback to compute them.  This is where the problems come in, at least when using nested attribute support.  Deletion of records from the association (Fares) does not occur until after the Deal record is saved.  What that means is that you can't calculate the low and high rates safely in a before_save callback, you need to use after_save.  That is a bit of a pain in that it means you instantly are doing more DB calls to update those values since you can't do it as part of the primary update.  For us, the rate of writes is small, so that isn't a big deal.
 
Now the second problem of course is that when you do update those values, you're going to cause another save of the record, and that will kick off the callbacks again.  You've now created an infinite loop.  There's no way that I know of, in Rails 2.3.x, to do an update without callbacks (older versions of Rails had update_without_callbacks).  As per the Rails Guide, there are however a few methods that skip callbacks.  One of those is update_all.  It's a bit of a brute force approach, but it is the solution I wound up with, at least for skipping callbacks.
 
The third problem is that within your after_save callback, your association won't be up to date if a deletion has been performed (it'll still contain the item that is marked for delete).  This makes sense, given you are still working with the same instance of your primary object.  Luckily you can just call reload on that.  If we put all these things together, the final solution is relatively simple, although still feels a bit hacky:
 
class Deal < ActiveRecord::Base
  has_many :fares
  
  accepts_nested_attributes_for :fares
  
  before_validation_on_create :create_lowest_and_highest_rates
  after_update :update_lowest_and_highest_rates
 
  ...
 
  protected
 
  def update_lowest_and_highest_rates
    fares.reload
 
    low, high = (fares.minmax_by {|fare| fare.rate}).map(&:rate)
 
    Deal.update_all({:lowest_rate => low, :highest_rate => high},
                    ['id = ?', self.id])
  end
end
 
There are some downsides, such as validations not getting called on the denormalized values when doing the update_all.  You also likely need a before_validation_on_create to do the same functionality (if you have validations for the denormalized values) when first creating your Deal, in which case you don't have to worry about the delete situation.  I'd love to hear of a better solution.  Also, there is the without_callbacks gem that provides some really nice syntactic sugar for this kind of thing, but hasn't been updated since 2008, and looks like it may not work with the latest versions of Rails.

Filed under  //   Rails  

Comments [0]

My Espresso Consumption for February 2010

James Hoffman's similar post inspired me to track my more simple espresso/coffee consumption for the month of February.  As the following graphic shows, I drink primarily straight shots of espresso, averaging 2.5 shots per day, followed by moka pot, then macchiatos (which are typically what I'll have at a good cafe), etc.  I have 3.13 espresso drinks total per day on average.

Media_httpimgskitchco_cczyf

Media_httpimgskitchco_gilpx

The numbers are a hair low, as I didn't track any data on Feb 7th for whatever reason.  As you may be able to tell, I used Daytum to track it.  In particular I did a lot of data entry via the mobile version of their web site via my iPhone.  Handy.

Comments [0]

Rails Action Caching With Query Parameters

First, if this is known to people, great, if not I hope it helps others, as I wasn't able to find this in all the Googling I did.  Furthermore, since this turned out to be such a simple solution, I'm curious if there are holes...

I wanted to setup more significant caching for some heavy use types of pages on DealBase.  Various things have made this challenging to date, but the last thing I ran into was dealing with the fact that query parameters change page results (duh), but that of course Rails' page and action caching ignore query parameters.  There isn't an easy (or?) way to get around the page caching part unless you start mucking with Nginx rules as well I think.  But, action caching has a solution.  I had done a ton of Googling on this, and I knew about adjusting the cache_path, as well as some other bits, but we have cases where there are a lot of parameters.  Plus, I didn't want to worry about what happens if I add a new search/filter type of parameter later on, and having to remember to add that to the list of things the cache_path differed on.  

As it turns out, you can simply do regular action caching, with full query parameter support, very easily with:

caches_action :my_action, :cache_path => Proc.new { |controller| controller.params }

That will do the regular style of action caching, but stick all your query parameters on (in alphabetical order so you don't have to worry about different query parameter order not retrieving the same cache results).  Now, it's quite likely that you'll want something a bit fancier.  For example, here's something closer to what I use in reality:

caches_action :action_one, :action_two,
  :cache_path => Proc.new { |c| c.params.delete_if { |k,v| k.starts_with?('utm_') } },
  :expires_in => 4.hours,
  :unless => Proc.new { |c| c.request.xml_http_request? || c.send(:current_user).try(:admin?) }

This just adds in some conditions, as well as removes some query parameters that I don't want to differentiate the cache on ("utm" keywords for Google Analytics, etc.).  In this particular case we're not caching the page at all if it's an AJAX request or for our admins.  

Finally, one comment is that you do need to be careful with things like pagination.  In many cases, page 1 is going to get viewed a ton, and maybe page 2, or page 17 for that matter are rarely viewed.  You could have a case where you make updates to the content that then makes a change such that the different pages are out of sync and thus you have duplicate items on pages or missing items.  You could skip using expires_in, and use cache sweepers if that works for you, but factor in how often updates are happening and whether that might nullify the advantage of caching (i.e. if you do frequent updates, it'd expire your cache a lot and maybe too often to benefit from it if you have high rate of updates).

What say you?  Anyone else doing this, any other issues?

Comments [15]

Evaluating RubyMine IDE for Rails Development

I have spent roughly the last month using the RubyMine IDE for about 80%+ of my daily development work.  I initially grabbed it to try out the debugger on a particularly nasty problem, and then decided to give it a real evaluation.  My daily work is on DealBase, and covers the full spectrum of Rails development.  The testing was done mostly using a quad-core Mac Pro with 8GB of RAM and 30" and 24" monitors (dual monitor setup), with RubyMine running essentially full screen on the 30".  I also did some work on my MacBook Pro (Core 2 Duo, 4GB RAM).  Both machines use Snow Leopard.  My current and longtime editor has been TextMate, although I have far more time spent historically in environments like Visual C++/Studio, IDEA, a bit of time in Eclipse, a bit in Emacs, BBEdit, CodeWarrior, regularly use Vim, etc.  To date, the speed and light weight of TextMate, combined with it's slick column editing feature (that's one killer feature), have kept me from switching.  But, there may be some movement here...

I kept notes during my eval, and simply broke it down into pros and cons for me, along with a list of "other" comments.  Just going to dump these here, and then I'll tell you the outcome at the end...

Pros
  • Debugger, oh, to have a real debugger back, is quite nice.  This is what motivated me to try it to begin with.  Super easy to setup and get working to, basically no effort at all, which is much appreciated (but do need to see if can be done with Passenger setup instead of Mongrel, since we don't use Mongrel).  I've used command line ruby debugger, but once you've used a solid GUI debugger, the command line ones are just such an inferior way to work.
  • Really like how it puts the folder name in front of the file name when there are multiple files in the project with that name
  • Puts squiggles under misspellings or other code errors - quite handy.  It also puts this under the file's name in its tab, so you can quickly see which files you have open that have errors in them.
  • Hold Cmd while hovering over the name of a partial or similar, and then click to open that file
  • Word selection via double click includes the "@" on field names for Ruby code
  • It's quite smart about correlating Cucumber step statements to their definitions: it will actually show you a step statement doesn't match when that non-match is because the regex in your definition is not matching.  For example, if you had something like  "from (\w+ airport)" in your definition, but you put "from San Francisco airport", it wouldn't match, and RubyMine figures this out (I'm impressed!)
  • Having an irb or script/console REPL avail right there is quite nice.  I'm still experimenting with whether I organize my windows such that this is always at the front or not.
  • I'm just starting to get used to using them, but the "view for" and "action for" little markers in the gutter of controller/view files will take you to the corresponding view/action, a nicety.
Cons
  • TextMate bindings didn't map Cmd-Enter the way TextMate did.  Remapped it and it works fine now.
  • Doesn't work (well) with MacOS X Spaces - prevents switching to another space when you select another app
  • Sometimes grinds to a halt while it re-parses your project or what not
  • File tabs: 
    • They go to multiple rows too easily.
    • They just don't look right/good.  I'm not sure if it's because they're non-native tabs or what.
    • I understand, but don't like how the rows swap when you change to a different tabs.  You lose track of where a file is in the tabs.
  • You can't really just open up an empty, new window at whim.  I use this a lot as a scratch pad type of thing in TextMate.
  • Find in project is nowhere near as fast, or presented as usefully as Ack in Project for TextMate.  It does provide more options, such as filtering files by directory or type and so on, but the speed is generally far more important.
  • Too slow on a MacBook Pro 2.4GHz Intel Core 2 Duo with 4GB RAM - too many operations seemed to bring it (and my machine) to its knees.  Seems ok on my quad-core tower with 8GB RAM.
  • GoTo File (Cmd-T in TextMate) is odd in that it'll match to image files.  I would expect these to be automatically culled out (they are in TextMate), as I'm not looking to open some PNG file for editing.
  • Also seems to crash enough that it bothers me.  I can tolerate an occasional crash, although with TextMate I've run it for weeks on end with no crash, using it constantly.  I've had several either hangs or crashes with RubyMine in the short couple weeks I've been trying it out.
  • Can't run parallel specs/cucumber in it and get the proper processing/handling.  Our test suite is extensive enough, or well, takes long enough to run, that I really need to take advantage of multi-core machines and run this stuff in parallel.  It'd be awesome if they could integrate parallel specs.
  • "Synchronize files on frame activation" doesn't work, or doesn't do what I thought: have to tell it to reload log files from disk.  Even closing the tab for the file, and re-opening it, doesn't re-synchronize it from disk.  This really sucks when viewing log files, and is not even good for regular files - prompt me if the file changes on disk and see what I want to do, before I've spent a lot of time editing something only to realize I was editing a stale version.  
  • Has Google Chrome browser listed in Web Browsers prefs, but I can't select it or type in its location, etc.
  • Has the usual Java UI ugliness - Java file dialogs instead of native dialogs (and thus you see files and stuff you wouldn't normally see - not all bad, but ugly), just doesn't look nearly as good as a native app.
  • If I specify WebKit as my browser (which gets opened when starting to debug), a) it doesn't bring it to front, and b) it gets the URL wrong.  I see this in the address bar: "file:///Applications/RubyMine%202.0.app/bin/http:/0.0.0.0:3000"  I fared better with Chrome, but it launches a second instance of Chrome (not just a separate window, an actual separate app process).  This may be a Chrome behavior though?
  • I added a Tool for "/bin/zsh -i" to have just a regular shell in side, but the coloring and various escape codes and such don't work, and that winds up breaking enough stuff for me (that I don't want to re-jigger for this), that that's a downer.  I'd hoped that I could sort of just "live" in the IDE, like many Emacs users do.
Other 
  • Column editing is partly there, but not as good as TextMate.  If you make a column selection, and then hit paste, it doesn't replace it, it just inserts your paste at the end.  This makes it hard to say bulk rename something that's aligned vertically.
  • The refactoring bits were just ok.  This is a really hard feature in general though.  Simple refactorings I used, like renaming a method worked fine.  But, changing the name of a model class did about 1/4 of the work needed and was questionable as to whether it was an advantage over just doing it all myself.  It got all the obvious, low-hanging fruit, but it seemed to completely ignore Rails helpers and views.  It misses a bunch of things that I'm not surprised at of course, such as table names in SQL conditions (e.g. in named_scopes), model name used anywhere in JavaScript or CSS (which isn't uncommon in Rails code), and then the one that I'd like to see it do a better job on, but that is hard of course is on associations.  So, in my application, I was refactoring our "Deal" model to be "HotelDeal".  We have a "Hotel" model and it has_many deals.  Thus in the code you'd routinely see things like "hotel.deals" to reference that association.  It didn't handle any of those.  Not surprising, but starts to devalue the refactoring feature.
  • Their TextMate keybindings don't get Cmd-Enter right, but you can fix it.  You can remap the keys for "Split Line" and "Start New Line" (swap the two for example - "Start New Line" is the one you want to be Cmd-Enter).
  • I'm not quite willing to call this a con, but I find that I still prefer to use GitX to review and commit my code, instead of what's built in to RubyMine.  GitX has a nicer UI for it, just seems more straightforward, etc.  But, it is at least quite nice to have Git support right in RubyMine.  The two key changes I'd like to see that would potentially fix this for me, would be to show diffs by simply selecting one of the changed files (just like GitX does).  This is key for me because I review all code changes prior to a commit.  Second would be to show what branch I'm on.  I always work on a branch, and it's nice to see the branch as a double-check prior to committing.
  • Hoping for a TextMate theme importer (I think that's coming?), so I can import my customized Argonaut theme.

Verdict?

So, what's the upshot?  Well, I certainly won't ditch TextMate, but to my own surprise, I find I'm getting quite comfy in RubyMine.  When you need the debugger, it's really nice to have, and the other thing that's really been growing on me is their syntax checking - the squiggly lines under misspelled variable or method names, or simple syntax errors, etc.  It just saves time.  Log file viewing is clearly a problem, so I use TextMate for that (or just tail it, depending on my needs), and I don't find it to really be usable on my MacBook Pro, mainly just feels to sluggish, but I don't often use that for heavy dev work anyway.  I'd like to see it (or the debugger) work better with launching non-standard browsers.  I had had the hope that it could be like Emacs is for some folks, where I could really do darn near all my development things from inside it.  You could, but they aren't up to the same level as the separate bits yet (real zsh shell and GitX, in particular).  

My expectation is that I will buy a license, as the $99 price is worth it just to have the debugger when needed, but I might actually wind up using it regularly.  I think their pricing is actually a bit low, but it no doubt hits a sweet spot that likely motivates more folks to buy it.  My experience has been better than expected (I thought I was done with IDE's), and I'm also now eagerly awaiting Aptana's release of RadRails 3.  Their little sneak preview videos have been very promising.  But, I generally hate Eclipse (I've had plenty of time with it back when doing Java work, and always preferred IDEA, so there's my bias out in the open), so I'm wondering how that'll impact things.

Thus, I'd suggest that if you're a Rails developer, you give RubyMine a whirl.  It's really pretty impressive and I look forward to trying it a bit more, and also seeing what improvements come in the future.

Comments [14]

Liberation by Boxcar: or Alternatives to Twitter SMS

The iPhone app Boxcar has liberated my iPhone from the stress and worry caused by Twitter SMS.  What? 

All of the server monitors I have setup, but most importantly, the ones for DealBase, will send me an SMS if there's a problem.  I also get Hoptoad exception notifications via SMS for DealBase.  These are things that are timely, and important.  I'd had one bad case where the servers were reporting down (they weren't actually, was a DNS issue), and this wound up unfortunately setting me up to be hyper-vigilant in checking SMS.  Unfortunate stress and worry.

However, what compounded this was that I was getting some tweets (friends mostly) via SMS.  Well, obviously, the tweets far outnumbered any actual server issues, but due to the above vigilance about checking SMS's, these tweets would make my phone ding and make me immediately worry, "did the server go down?!"  I wound up starting to cut down whose tweets got sent via SMS.  But during this, I also realized that I actually didn't want any tweets via SMS unless they were a "direct" or a "mention".  If they weren't, I'd just read them when going through my regular Twitter feed.  However, Twitter doesn't have an option for just getting any directs or mentions via SMS (they really should).  That led to Boxcar...

Boxcar is a fantastic iPhone app that monitors your Twitter (or Facebook, and other things) stream for directs or mentions, and sends you push notifications when one is found.  It's fast, staying extremely current with your feed, and works great.  With this addition, I've been able to off SMS for everyone I follow on Twitter.  I've been doing this now for about a week, and realized this morning how liberating it has been!  

Normally, I would wake up, instantly check my phone (which serves as my nightstand alarm clock now, thanks to the excellent Kensington Nightstand Charging Dock - click the little photo icon to see how it'll look in use), to see if any server down SMS messages came in that I didn't hear while sleeping.  Usually I'd have a few SMS messages, which would instantly raise my stress level, only to pretty much always find they were tweets.  With Boxcar, now my mornings are great.  I still check my phone of course, but yep, no SMS's anymore.

So thank you Boxcar, great product!  While I can't more heartily recommend Boxcar, I'll point out Prowl which some folks also recommended.  My main issue with Prowl is that it requires an always on Mac to grab whatever data you want as a push notification, and send it to the Prowl servers.  There are workarounds for some things for this, but it was just way more hassle and such than I wanted, for what I needed.  But, you may find it useful if you have data you want as a push notification that you don't have another way to get.

Comments [0]

Workaround for jQuery Autocomplete Plugin mustMatch Fail on Commas

The jQuery autocomplete plugin is quite nice, and we use it a fair bit on DealBase.  However, what I found was that if you set the mustMatch option, your text cannot contain commas, colons, and a few other punctuation (and maybe other) characters.  For some reason that I've yet to track down (debugging through many nested anonymous functions and callbacks has yet to yield an answer), it thinks it changes at some point to not think it's a match. A good example of this is if you allow a user to type in a city name, but you want to show them matching cities with the state and/or country included, to disambiguation.  E.g. you may have Portland, Oregon and Portland, Maine (not to mention the few Portlands in Australia :)

What I found fixed it for me was to set the matchSubset option to true.  This allowed it through, retaining the full text of something like "Portland, Oregon".  According to the plugin's docs, matchSubset should only come into play when using the cache, which we don't use (because we limit results to 20 items, and often there are more than 20 matches, e.g. a user types "new" or "las" or something - many cities will match).  

I'd still like to track down the real bug here, but since others have run into this, and I've yet to see any other solutions, I wanted to post that, in hopes it'll help some other person suffering from this.

Update: even setting matchSubset to true, did not solve the problem where you have a dash/hyphen in the string, and the part that matches is to the right of the dash.  Removing the dash is the only thing I've figured out to make it work.

Filed under  //   JavaScript   jQuery  

Comments [6]