Skip to content

Instantly share code, notes, and snippets.

jQuery('#label-switch').change(function(){
var showLabels = (jQuery(this).is(':checked') ? 1 : 0);
})
@pillowfactory
pillowfactory / gist:828394
Created February 15, 2011 22:27
How bad of practice is it to do something like this?
require 'rubygems'
require 'active_support'
module CustomName
def self.included(base)
base.alias_method_chain :name, :update
end
def name_with_update
['custom', name_without_update].join(' ')
# Given a CSV record format like:
# john,doe,blonde,26
CsvMapper.import('blah') do
map_to Person
first_name # maps to string by default
last_name # maps to string by default
_SKIP_ # skip the 'hair color' column
@pillowfactory
pillowfactory / new_csv_mapper.rb
Created April 6, 2011 04:52
Work in progress example of desired use/functionality of CsvMapper
# Import with CSV Mapper
CsvMapper.import('path') do
start_at_row 1 # Skip the first row (probably a header row)
stop_at_row 10 # Stop parsing on the 10th row
map_to Business do
business_name # Parse to String by default
net_worth :type => Float # Parse column value Float
net_worth.to_f # Parse column value Float
describe ".import" do
context "with no mapping block" do
context "given a single record" do
it "returns an empty collection" do
CsvMapper.import(nil).should be_empty
end
end
context "given a collection with only one record" do
it "returns an empty collection" do
CsvMapper.import([['John', 'Doe']]).should be_empty
@pillowfactory
pillowfactory / gist:1331639
Created November 1, 2011 19:28
ConfBot Base Functionality
* Schedule
* Who's speaking now?
* Who's speaking next?
* When's lunch?
* What's the Google map URL?
* Current Speaker's SpeakerRate URL?
* Last Speaker's SpeakerRate URL?
* Relay non-commands to convore (just an idea)