Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
+++ bind.c 2010-10-28 23:09:12.788260925 +0200
@@ -1508,6 +1508,9 @@
static int sv_histsize PARAMS((const char *));
static int sv_isrchterm PARAMS((const char *));
static int sv_keymap PARAMS((const char *));
+static int sv_vi_insert_prompt PARAMS((const char *));
+static int sv_vi_command_prompt PARAMS((const char *));
+static int sv_vi_mode_changed_bin PARAMS((const char *));
static const struct {
@johnbintz
johnbintz / helper.coffee
Created June 14, 2011 20:32
Make Backbone report validation errors, much like @model.save! in Rails
class Backbone.ValidatingModel extends Backbone.Model
_performValidation: (attrs, options = {}) ->
_options = _.clone(options)
_options.error = (model, error, opts) ->
throw new Error(error)
super(attrs, _options)
@johnbintz
johnbintz / assets.yml
Created June 8, 2011 19:57
Using haml-js with Jammit
compress_assets: off
gzip_assets: off
template_function: Haml
template_extension: js.haml
javascripts:
common:
- public/javascripts/haml.js
- app/views/**/*.js.haml
@johnbintz
johnbintz / my_spec.coffee
Created June 6, 2011 21:07
Modular extensions to Jasmine specs using CoffeeScript & Underscore
describe 'A thing', ->
it 'should make an other thing', ->
this.utilityFunction("test")
expect(this.otherThing).toEqual("test")
@johnbintz
johnbintz / guard-rails.rb
Created May 27, 2011 18:24
Use Guard to restart Rails development server when important things change
def rails
system %{sh -c '[[ -f tmp/pids/development.pid ]] && kill $(cat tmp/pids/development.pid)'}
system %{rails s -d}
end
guard 'shell' do
watch(%r{config/(.*)}) { rails }
watch(%r{lib/(.*)}) { rails }
end
@johnbintz
johnbintz / script-hooks-pre-commit.sh
Created May 10, 2011 20:54
A way to distribute git hooks with a Rails app and have them easily installed
#!/bin/bash
rspec spec
if [ $? -ne 0 ]; then exit 1; fi
@johnbintz
johnbintz / Running watchr.sh
Created May 10, 2011 18:42
Running RSpec and jasmine-headless-webkit using watchr
# all tests, run all at start
ACCEPTANCE=true watchr test.watchr
# all tests, don't run at start
ACCEPTANCE=true watchr test.watchr -- -f
# skip acceptance (the slow ones)
watchr test.watchr
@johnbintz
johnbintz / scss.lang
Created May 4, 2011 20:19
Super-basic SCSS formatting for SHJS
# language definition for scss style sheets
include "c_comment.lang"
string = '#[a-f0-9]{3,6}'
keyword = '[\#\.]+(?=\{)'
selector = '[#\.][[:word:]]+'
keyword = '\$([^ :;]+)'
@johnbintz
johnbintz / autotest.rb
Created April 15, 2011 14:05
Basic Autotest mapping/exception configuration bits
# Actually .autotest and lives at the root of your project, from where you execute autotest
# this is all done in a hook, like this:
Autotest.add_hook :initialize do |at|
# i don't like the default exceptions, get rid of them!
at.clear_exceptions
# exclude stuff that changes between each test, like log
at.add_exception('log/')
@johnbintz
johnbintz / remote_site_watchr.rb
Created February 22, 2011 14:56
Use with watchr to reload pages on a remote site periodically to check for changes.
require 'net/http'
require 'mechanize'
class RemoteSiteWatchr
def initialize(host, urls, &block)
@host = host
@urls = urls
@block = block
@agent = Mechanize.new