Skip to content

Instantly share code, notes, and snippets.

View bobthecow's full-sized avatar

Justin Hileman bobthecow

View GitHub Profile

This is for RESTful PATCH awesomeness:

var myModel = new Backbone.Model({
  title:   "Current title",
  content: "Content",
  bonus:   42
});
@bobthecow
bobthecow / gist:4774286
Last active December 12, 2015 12:48 — forked from smkelly/gist:4774258
# if you want an icon, add it to your attributes:
# menu_link('Foo', '/foo/', icon: 'bar')
def menu_link(text, target, attributes={})
# Prepend the icon, if supplied
if icon = attributes.delete(:icon)
text = "<i class='#{icon}'></i>#{text}"
end
# Build a link
@bobthecow
bobthecow / tenkey.markdown
Created November 3, 2012 18:51
Mechanical USB numeric keypad landscape
<?php
// load n classes from the filesystem
if (count($argv) !== 3) {
throw new InvalidArgumentException('usage: php apc.php numtemplates size');
}
$numtemplates = $argv[1];
$templatesize = $argv[2];
@bobthecow
bobthecow / gist:3866586
Created October 10, 2012 16:06
A proposal for the Nanoc 4.0 Rules DSL

A proposal for the Nanoc 4.0 Rules DSL

I'd love to see something very much like this:

# Rules

compile '/article/*' do
  filter :erb
<?xml version="1.0"?>
<root>
<item>
<name>Truly Ergonomic Keyboard</name>
<!--
DIP switch settings:
1 2 3 4 5
last_response.body.should match_json({
user: {
id: :user_id,
username: 'chancancode',
full_name: 'Godfrey Chan',
email: 'godfrey@example.com',
type: 'Administrator',
points: Fixnum,
homepage: /\Ahttps?\:\/\/.*\z/i,
created_at: WILDCARD_MATCHER,
@bobthecow
bobthecow / match_json.rb
Created July 10, 2012 22:15
match_json
require 'json_expressions'
RSpec::Matchers.define :match_json do |expected|
unless JsonExpressions::Matcher === expected
expected = JsonExpressions::Matcher.new(expected)
end
match do |actual|
actual = JSON.parse(actual) if String === actual
expected =~ actual
@bobthecow
bobthecow / fishfish.rb
Created June 13, 2012 15:59
brew install fishfish
require 'formula'
class Fishfish < Formula
homepage 'http://ridiculousfish.com/shell'
url 'https://github.com/fish-shell/fish-shell.git'
depends_on 'autoconf' => :build
depends_on 'readline'
skip_clean 'share/doc'
#!bash
#
# nanoc-completion
# ================
#
# Bash completion support for nanoc
#
#
# Installation
# ------------