I hereby claim:
- I am timocratic on github.
- I am timocratic (https://keybase.io/timocratic) on keybase.
- I have a public key whose fingerprint is 7E07 1867 9F3F 2174 FA58 27C5 B405 8899 5CD3 22B9
To claim this, I am signing this object:
# If you return self you have either mutated self, mutated something else (essentially global, even worse) | |
# or thrown away the change as a NOOP. Let's play with examples? |
I hereby claim:
To claim this, I am signing this object:
require 'addressable/uri' | |
#Accepts options[:message] and options[:allowed_protocols] | |
class UriValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
uri = parse_uri(value) | |
if !uri | |
record.errors[attribute] << generic_failure_message | |
elsif !allowed_protocols.include?(uri.scheme) |
lsof -Pnl +M -i4 | grep LISTEN |
#!/usr/bin/env sh | |
#After forking and editing YOUR_ORG to point at the right repo can be run via: | |
#bash <(curl -s https://raw.github.com/gist/THEIDOFYOURFORKEDGIST) | |
#if you use `curl xxx | sh` input will be messed up and there will be no pauses | |
#I keep XCode and gcc on a thumbdrive along with java, for speeding things up | |
#http://support.apple.com/downloads/DL1421/en_US/JavaForMacOSX10.7.dmg | |
read -p "Install XCode or gcc (http://github.com/kennethreitz/osx-gcc-installer)" | |
#setup your ssh keys for github |
#rvm use 1.9.2 | |
#brew install mongo | |
#gem install mongo_mapper | |
#gem install bson_ext | |
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.database = 'mm_demo' |
# RSpec's subject method, both implicitly and explicitly set, is useful for | |
# declaratively setting up the context of the object under test. If you provide a | |
# class for your describe block, subject will implicitly be set to a new instance | |
# of this class (with no arguments passed to the constructor). If you want | |
# something more complex done, such as setting arguments, you can use the | |
# explicit subject setter, which takes a block. | |
describe Person do | |
context "born 19 years ago" do | |
subject { Person.new(:birthdate => 19.years.ago } | |
it { should be_eligible_to_vote } |
<!-- keep IE in quirks mode --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- This following meta tag does no good since there is no way to trigger quirks | |
mode only in IE7. The problems with an xml prolog that triggered quirks mode were | |
fixed in IE7, but this meta tag was not yet introduced, so the only thing you can do | |
is trigger IE-wide quirks via the comment before the DOCTYPE //--> | |
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> | |
<style type="text/css"> |
def self.logger | |
@logger ||= begin | |
(defined?(Rails) && Rails.logger) || | |
(defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER) || | |
default_logger | |
end | |
end |
#In case it wasn't obvious, this was a joke about Rails anti-patterns | |
def address(separator, seperator2=' ') | |
fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym} | |
(0..10).inject("") { |string, i| | |
if i.odd? | |
field = :separator | |
field = (field.to_s + '2').intern if i == 7 | |
else | |
field = fields_array[i/2] | |
end |