Skip to content

Instantly share code, notes, and snippets.

@andrewbroman
andrewbroman / gist:3054198
Created July 5, 2012 15:01
HTML: Starting template
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title></title>
<link rel="stylesheet" href="style.css">
</head>
<body>
@andrewbroman
andrewbroman / gist:3054241
Created July 5, 2012 15:07
CSS: Image Replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@andrewbroman
andrewbroman / scope.coffee
Created July 5, 2012 18:41
CoffeeScript: global variable
root = (exports ? window)
root.courseTopic = courseTopic
@andrewbroman
andrewbroman / mock.rb
Created July 10, 2012 15:37
Ruby: on-the-fly mock
# Thanks to tenderlove on Peepcode play by play
tc = self
klass = Class.new(Client) do
define_method(:get) do |username|
tc.assert_equal 'foobar', username
sample
end
end
@andrewbroman
andrewbroman / checksum.rb
Created July 12, 2012 16:16
Ruby: create checksum on hash
# Thanks to tenderlove on Peepcode play by play
require 'digest/md5'
def fetch username
records = JSON.parse get username
records.each do |hash|
checksum = Digest::MD5.hexdigest Marshal.dump(hash)
hash['checksum'] = checksum
end
@andrewbroman
andrewbroman / ancestors.rb
Created August 11, 2012 18:23
Ruby: return array of ancestors
def ancestors(obj)
anc = []
klass = obj.class
until klass.nil? do
anc << klass
klass = klass.superclass
end
anc
end
@andrewbroman
andrewbroman / antispam.html
Created August 13, 2012 17:49
HTML: anti-spam form idea
<input type="text" id="not_human" name="name" />
<input type="text" name="actual_name" />
<style>
#not_human { display: none }
</style>
=begin
Plugin: Github Logger
Version: 1.1
Description: Logs daily Github activity for the specified user
Author: [Brett Terpstra](http://brettterpstra.com)
Configuration:
github_user: githubuser
github_tags: "#social #coding"
Notes:
APP_VERSION = `git describe --tags --abbrev=0`.strip unless defined? APP_VERSION
295 Predicate Return Value Part 2