Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaac Sanders isaacsanders

View GitHub Profile
@isaacsanders
isaacsanders / form_hidden_fields_helper.rb
Created May 7, 2012
Store a hash in form hidden fields
View form_hidden_fields_helper.rb
module FormHiddenFieldsHelper
# Originally based on http://marklunds.com/articles/one/314
def spread_param_hash(hash, key_prefix = '')
format_key = key_prefix.blank? ? lambda { |k| k.to_s } :
lambda { |k| "#{key_prefix}[#{k}]" }
flat_hash = {}
hash.each do |k, v|
k = format_key.call(k)
if v.is_a?(Hash)
@isaacsanders
isaacsanders / Hide Mobile Browser Chrome
Created Apr 27, 2012 — forked from tonywok/Hide Mobile Browser Chrome
Normalized hide address bar for iOS & Android on page load and orientation change
View Hide Mobile Browser Chrome
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
*
* Modified by
* (c) Tony Schneider
*
* MIT License
*/
(function( win ){
View gist:1624529
#!/usr/bin/env ruby
require 'raptor'
class Posts
end
class Users
end
View sugar_date.coffee
startOfMonth: (date) ->
startOfMonth = date.beginningOfMonth()
console.log startOfMonth.format('{MM}-{DD}-{YYYY}')
endOfMonth: (date) ->
endOfMonth = date.endOfMonth()
console.log endOfMonth.format('{MM}-{DD}-{YYYY}')
# Maybe this?
@isaacsanders
isaacsanders / RECEIVE_REFUND.bas
Created Nov 17, 2011 — forked from bostonaholic/RECEIVE_REFUND.bas
how to receive a refund, basically
View RECEIVE_REFUND.bas
000 SUB RECEIVE_REFUND
010 ASK POLITELY
020 IF REFUND = "YES" THEN
030 GOTO GOODBYE
040 ELSE
050 GOTO ASK_STERNLY
060 END IF
070 ASK_STERNLY:
080 ASK STERNLY
090 IF REFUND = "YES" THEN
@isaacsanders
isaacsanders / gist:1351874
Created Nov 9, 2011 — forked from hay/gist:1351230
Enterprisify your Java Class Names!
View gist:1351874
<!doctype html>
<html>
<head>
<title></title>
<style>
body {
background: white;
text-align: center;
padding: 20px;
font-family: Georgia, serif;
View gist:1306234
# Original definition
class Whatever
def initialize
end
end
# Redefinition
class Whatever
alias_method :old_initialize, :initialize
def initialize(*args, &block)
View gist:1297210
class MeetingDates
def initialize
@crb_dates = []
@jam_dates = []
calc_meeting_dates
end
def calc_meeting_dates
start_date = Date.today.beginning_of_year
(0..12).inject([]){|s, num| dates_for_month(start_date + num.months)}
@isaacsanders
isaacsanders / List.rb
Created Oct 2, 2011 — forked from hoguej/User.rb
For Jon Hogue
View List.rb
roles do
role :admin, [:read, :write, :execute]
role :user do |r|
action :read
end
end
View gist:1107078
require 'rspec'
require 'date'
describe "Tim's Methods:" do
let(:tim) { TimAffinity.new }
context "Tim is in India and" do
it "should be clear that Tim needs to get his ass back here" do
tim.do_we_want_him_back?.should be_true