Skip to content

Instantly share code, notes, and snippets.

@bkeepers
bkeepers / frameworks.md
Created May 14, 2013
Frameworks for building HTML+CoffeeScript+[CSS-preprocessor] sites.
@bkeepers
bkeepers / .gitconfig
Created Feb 19, 2013
Git aliases to make new commits that fixup or are squashed into previous commits
View .gitconfig
[alias]
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase -i --autosquash $REV^' -
squash = !sh -c 'REV=$(git rev-parse $1) && git commit --squash $@ && git rebase -i --autosquash $REV^' -
@bkeepers
bkeepers / usage.coffee
Last active Jun 25, 2021
Keep two HTML5 video elements in sync.
View usage.coffee
videos = document.getElementsByTagName('video')
new VideoSync(videos[0], videos[1])
View cucumber.textile

This post has sat as a draft on my computer for well over a year now. I always intended to finish it, but am beyond caring. So I’m just going to publish it in its current form in hopes that it sparks some interesting conversation and avoids beating a dead horse.

Cucumber is a divisive tool. Some people absolutely love it and have an irrational dedication to using it for every single project. Others hate it, either because they haven’t tried it, or tried it on one project and ended up with a steaming pile of sh…step definitions.

I’ve been using cucumber since one of the first few releases. While I have been burned by it on projects, I also have a great appreciation for it.

What’s wrong with cucumber? Technically, nothing. It’s a brilliant tool for creating DSLs to test our applications. The problem with cucumber is YOU: you don’t understand why to use it, when to use it or how to use it. Don’t worry, though, it’s not entirely your fault. Many people are responsible f

@bkeepers
bkeepers / iframe.html
Created Apr 4, 2012
demo of window.sendMessage
View iframe.html
<html>
</html>
View gist:1909309
# puts (1..100).to_a.shuffle.inspect
class Array
def shuffle
size.downto(1) { |n| swap(n - 1, rand(n)) }
self
end
def swap(x, y)
self[x], self[y] = self[y], self[x]
end
@bkeepers
bkeepers / gist:1901470
Created Feb 24, 2012
Spine Collections
View gist:1901470
class Message extends Spine.Model
@configure 'Message', 'text'
class Mentions extends Spine.Collection
@configure Message
@extend Spine.Model.Ajax
@url: '/messages/mentions'
@bkeepers
bkeepers / plugin.rb
Created Sep 30, 2011
Theoretical plugin API for Qu
View plugin.rb
module AutoRetry
include Qu::Plugin
configure do
def autoretry(*errors)
self.config = {:limit => 3}.merge!(errors.extract_options!)
errors << Exception if errors.empty?
config[:errors] = errors
@bkeepers
bkeepers / gist:1197658
Created Sep 6, 2011
:in and :from associations in MongoMapper
View gist:1197658
class List
include MongoMapper::Document
key :user_ids, Array, :typecast => ObjectId
many :users, :in => :user_ids
end
class User
include MongoMapper::Document