Skip to content

Instantly share code, notes, and snippets.

# Yourinal; Your Terminal
#
# A collection tools and utilities for your terminal needs
#
# Name credit goes to Jim Albano (@JimDAlbano).
# I was going to call it Coctane; Console Octane.
# Yourinal; Your Terminal - is far better.
#
# Backup name via Flip Sasser (@flipsasser): PimpMyConsole
#
def fake_select(parameter, collection, description="", preposition="")
html = "<div class='fake_select'>"
unless params[parameter].blank?
html << "<a class='first_option'>#{preposition} #{params[parameter]} #{description}</a>"
else
html << "<a class='first_option'>#{preposition} #{collection.first} #{description}</a>"
end
html << "<ul class='fake_list'>"
collection.each do |item|
html << content_tag(:li) do
@adambair
adambair / Global Search and Replace in Vim
Created October 19, 2011 21:18
Global Search and Replace in Vim
# populate the arglist
:args app/*/*
# then use argdo <cmd>
:argdo %s/:notice/:success/gec
# the % is for the entire file
# the g is for global line substitution
# the e is to ignore errors
# the c is to confirm each substitution
@adambair
adambair / gist:1299611
Created October 19, 2011 20:46
pry is awesome.
# use instead of rails console
pry -r ./config/environment.rb
# for debugging in code put this anywhere:
binding.pry
# then check your console (rails server window) and type:
help
# win
def balance
return 0 if transactions.empty?
transactions.realized.reverse.last.balance
end

1. Achievement

Definition: A virtual or physical representation of having accomplished something. These are often viewed as rewards in and of themselves.

Example: a badge, a level, a reward, points, really anything defined as a reward can be a reward.

2. Appointment Dynamic

Definition: A dynamic in which to succeed, one must return at a predefined time to take some action. Appointment dynamics are often deeply related to interval based reward schedules or avoidance dyanmics.

Beautiful code is the balanced application of Proportion, Integrity, and Clarity.
Proportion
/\
/ \ [ each are necessary ]
/ \ [ none are sufficient ]
/______\
Integrity Clarity
Proportion: The smallest size needed to do the job. Economy of size and the ratio of pairs.
def interests_text
interests = []
interests << 'Design' if 'design'
interests << 'Web Development' if 'web'
interests << 'Mobile Development' if 'mobile'
interests << 'Strategy' if 'strategy'
interests << 'Products' if 'products'
interests << 'Other' if 'other'
interests
end
class ProductObserver < ActiveRecord::Observer
observe :product
def after_save(product)
reload_routes
end
def after_destroy(product)
reload_routes
end
def self.defaults
defaults = OpenStruct.new
defaults.from_date = default_from_date
defaults.to_date = default_to_date
defaults
end
def self.default_from_date
default_date - 1.year
end