Skip to content

Instantly share code, notes, and snippets.

View isaacsanders's full-sized avatar

Isaac Sanders isaacsanders

View GitHub Profile
@isaacsanders
isaacsanders / form_hidden_fields_helper.rb
Created May 7, 2012 19:53
Store a hash in form hidden fields
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 April 27, 2012 17:51 — forked from tonywok/Hide Mobile Browser Chrome
Normalized hide address bar for iOS & Android on page load and orientation change
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
*
* Modified by
* (c) Tony Schneider
*
* MIT License
*/
(function( win ){
#!/usr/bin/env ruby
require 'raptor'
class Posts
end
class Users
end
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 November 17, 2011 22:11 — forked from bostonaholic/RECEIVE_REFUND.bas
how to receive a refund, basically
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 November 9, 2011 15:56 — forked from hay/gist:1351230
Enterprisify your Java Class Names!
<!doctype html>
<html>
<head>
<title></title>
<style>
body {
background: white;
text-align: center;
padding: 20px;
font-family: Georgia, serif;
# Original definition
class Whatever
def initialize
end
end
# Redefinition
class Whatever
alias_method :old_initialize, :initialize
def initialize(*args, &block)
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 October 2, 2011 03:45 — forked from hoguej/User.rb
For Jon Hogue
roles do
role :admin, [:read, :write, :execute]
role :user do |r|
action :read
end
end
@isaacsanders
isaacsanders / gist:1107078
Created July 26, 2011 15:53
Tim's Methods
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