Skip to content

Instantly share code, notes, and snippets.

module Resque
...
class Worker
...
def perform(job)
begin
run_hook :after_fork, job
job.perform
rescue Object => e
break if e.is_a?(Resque::DirtyExit) # This is the line I added.
% RAILS_ENV=production rake middleware
use ActionDispatch::Static
use Rack::Lock
use ActiveSupport::Cache::Strategy::LocalCache
use Rack::Runtime
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::RemoteIp
use Rack::Sendfile
use ActionDispatch::Callbacks
@mmaa
mmaa / gist:663602
Created November 5, 2010 03:22
envelope balance
envelope_balance =
EnvelopeTransaction.where(
:destination => [self]).sum(:amount) -
EnvelopeTransaction.where(
:source_type => envelope,
:source_id => [self]).sum(:amount)
@mmaa
mmaa / gist:676309
Created November 15, 2010 01:40
envelope & internal_transactions
class Envelope < ActiveRecord::Base
has_many :internal_transactions
has_many :internal_transactions, :as => :source
def transfers_in
InternalTransaction.where(:envelope_id => self.id)
end
def transfers_out
InternalTransaction.where(:source => self)
class Parent
has_many :children, :as => :source
accepts_nested_attributes_for :children
end
class Child
belongs_to :source, :polymorphic => true
validates :source, :presence => :true
%w(
scene_01_v2_high.flv
scene_02a_v2_high.flv
scene_02b_v2_high.flv
scene_02c_v2_high.flv
scene_02d_v2_high.flv
scene_03_v2_high.flv
scene_04_v2_high.flv
scene_05_v2_high.flv
scene_06a_v2_high.flv
--type-add=ruby=.haml,.rake,.rsel,.builder,.slim
--type-add=html=.html.erb,.html.haml,.html.slim
--type-add=js=.js.erb,.json
--type-add=css=.sass,.less,.scss
--type-set=cucumber=.feature
--type-set=coffeescript=.coffee
--type-set=markdown=.markdown,.mdown,.md,.mkd,.mkdn
--ignore-dir=coverage
--ignore-dir=doc

As a rule, I prefer to be explicit and obvious about functions in our products, specifically iOS apps.

I first heard the term "pawing" in reference to UI design when Lion introduced vanishing scroll bars as first seen in iOS. One pundit referred to the act of pulling and pushing on the view in order to see if there is more content as pawing. It wasn't (isn't) obvious that a window or page can be scrolled to reveal more content if there is no visible scroll bar, unless some content can be seen peaking above the fold. Users were left to paw at windows and pages in order to see if there was any more content.

Being the default in iOS and now OS X, we can't do much about vanishing scroll bars. We can, however, ensure that we don't force users to paw at our apps in order to discover core functionality.

One example is in Message Finder. It's not obvious that swiping left reveals a list of senders. The little dots at the bottom help, but I don't think they're obvious. We can do better. If we moved the refresh and

def recent_messages(batch = 250, uid = nil)
get_connection.select('INBOX')
if uid
last_seen = get_connection.uid_fetch(uid, 'ENVELOPE').first.seqno
else
last_seen = get_connection.responses['EXISTS'].first
end
if last_seen > batch
def make_groups(names, size)
names.shuffle!.group_by { |i| names.rindex(i) % size }
end