Skip to content

Instantly share code, notes, and snippets.

View brookr's full-sized avatar
💭
🚀

Brook R brookr

💭
🚀
View GitHub Profile
@brookr
brookr / suspenders-attempt.log
Created August 19, 2011 23:16
Console log of attempting to create a Rails app with Suspenders
Last login: Fri Aug 19 15:43:53 on ttys006
You have new mail.
Fri Aug 19 15:44:57 brookr@pridwen.local:~ > ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
Fri Aug 19 15:44:59 brookr@pridwen.local:~ > rvm list
rvm rubies
Fri Aug 19 15:45:03 brookr@pridwen.local:~ > rvm install 1.9.2
@brookr
brookr / existential_rails.irb
Created October 19, 2011 05:42
Comparison of existential checks in Rails
# Does it have substance? Use .blank? or .present?, it's opposite:
>> " ".blank?
=> true
>> nil.blank?
=> true
>> [].blank?
=> true
>> nil.present?
=> false
>> [].present?
@brookr
brookr / gist:2002589
Created March 8, 2012 18:40
JS Master Class assignment #1
var Card = {
isValid: function(strum) {
var sum = 0, mul = 1, length = strum.length, digit, tproduct
forEach(c in strum.slice(0,17)) {
digit = CC.substring(length-i-1,length-i);
tproduct = parseInt(digit ,10)*mul;
sum += (tproduct >= 10 ? (tproduct % 10) + 1 : tproduct)
mul += (mul == 1 ? 1 : -1)
}
var countdown = function() {
var index;
function log(){
console.log(index);
}
function iterate(){
log();
if(index>1) setTimeout(iterate, 1000);
var Person = function(name) {
this.name = name
}
Person.prototype.getName = function() { return this.name }
var thomas = new Person('Thomas');
var amy = new Person('Amy');
thomas.name // --> "Thomas"
Person.prototype.name = "Amy"
@brookr
brookr / config.ru
Created April 16, 2012 04:36
Rackup file I use for running WordPress on Pow
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# clearly this could be cleaner, but it does work
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
# patch Php from rack-legacy to substitute the original request so
# WP's redirect_canonical doesn't do an infinite redirect of /
@brookr
brookr / gist:2493622
Created April 25, 2012 21:34 — forked from derekharmel/gist:2399684
How to fix pow not using the correct gemset
# From the project root
rvm env -- `rvm current` >> .powenv
@brookr
brookr / to_inventory.rb
Created May 8, 2012 17:10
Get a human-readable listing of what is in an array in Rails.
class Array
include ActionView::Helpers::TextHelper
def to_inventory
c = {}
each { |e| c[e.class.name] = c[e.class.name].to_i + 1 }
c.sort.map{ |k, v| pluralize(v, k) }.to_sentence
end
end
@brookr
brookr / core_extensions.rb
Created May 15, 2012 06:24
Add collector methods for all attributes on objects in an array.
class Array
def method_missing(method_name, *args, &block)
if method_name.to_s.is_plural?
map{ |e| e.send(method_name.to_s.singularize) }
else
super
end
end
def respond_to?(method_name, include_private = false)
@brookr
brookr / Google Apps Standard DNS Settings
Last active May 25, 2017 16:11
All the DNS records for a new Google Apps account, as entered in AWS:Route53
A: # If using naked domain redirects via Google
216.239.32.21
216.239.34.21
216.239.36.21
216.239.38.21
MX: # If using Google Mail
1 ASPMX.L.GOOGLE.COM.
5 ALT1.ASPMX.L.GOOGLE.COM.
5 ALT2.ASPMX.L.GOOGLE.COM.