Skip to content

Instantly share code, notes, and snippets.

def do_error_prone_thing
begin
toss_peanut_and_try_catching_it_in_your_mouth
rescue PeanutNotCaught => e
casually_pretend_it_did_not_happen
end
end
@aharpole
aharpole / gist:5357667
Created April 10, 2013 19:25
an example of using an ActiveRecord transaction
ActiveRecord::Base.transaction do
PlaylistSong.delete(playlist_id:params[:playlist_id])
#<create the new PlaylistSong objects
end
@aharpole
aharpole / gist:3485302
Created August 27, 2012 03:36
Report this bug to Evernote!
Want to get Evernote's attention about the fact that its app has awful performance and point out an easy fix? Paste the following test into a support ticket of the type "bug report".
Your iOS app hangs at the drop of a hat. Though I'm sure there are tons of things that are causing the performance of the app to not be that good, the most egregious offender here is the fact that you appear to do all of your loading and synchronization in the main thread of execution of the app.
When you perform long running blocking operations (like syncing notes) in the main thread, the application is unusable to the user (i.e. it hangs). Furthermore, you make poor use of modern dual-core iPhones and iPads by not multithreading.
Please, for the love of all that is sacred, do your data synchronization on a secondary thread so that when I open the app, I can immediately get to doing what I want to do.
There may be some parts of this process that might have to be blocking (like updating the UITableView of notes, for instanc