Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
@johnbintz
johnbintz / Rakefile
Created August 4, 2011 13:38
Make Hydra Rake task safer and more useful
begin
require 'hydra'
require 'hydra/tasks'
if ENV['RAILS_ENV'] == 'test'
Hydra::TestTask.new('hydra:spec') do |t|
t.add_files 'spec/**/*_spec.rb'
end
else
puts "No Hydra task unless you're running with RAILS_ENV=test"
@johnbintz
johnbintz / build.sh
Created August 4, 2011 13:57
Build latest MacVim, activating and deactivating all the right things along the way
#!/bin/bash
if [ ! -z $(which ruby | grep '.rvm') ]; then
echo "Switch to system ruby!"
exit 1
fi
echo "Building latest MacVim..."
sudo port activate libiconv
@johnbintz
johnbintz / gist:1312690
Created October 25, 2011 13:17
CoverMe with HtmlAndConsole formatter for RSpec, and no browser window opening
if ENV['COVERAGE']
require 'cover_me'
class CoverMe::HtmlAndConsoleFormatter < CoverMe::HtmlFormatter
def format_index(index)
super
puts "\n\n[CoverMe] Current coverage: #{index.percent_tested}%"
end
end
CoverMe.config do |c|
@johnbintz
johnbintz / gist:1649884
Created January 20, 2012 22:08
Get all the logging and exceptions from your Capybara-driven Rails app in your Cucumber environment
# come here mr. ducky, i just want to punch you
module Capybara
class << self
def logger_target
@logger_target ||= StringIO.new
end
attr_writer :backtrace_clean_patterns
def backtrace_clean_patterns
@johnbintz
johnbintz / ingdirect.user.js
Created February 1, 2012 11:27
Get rid of that stupid-ass Rapport ad that doesn't obey "Maybe Later" like it should.
// ==UserScript==
// This fixes the most annoying thing I've ever seen on the ING DIRECT website. Sorry, ING DIRECT folks.
// @match https://secure.ingdirect.com/*
// ==/UserScript==
var waiter;
waiter = function() {
if (mask = document.getElementById('adWizardPopup_mask')) {
mask.parentNode.removeChild(mask);
@johnbintz
johnbintz / gist:1809410
Created February 12, 2012 16:15
For the lazy, how to Guard::Guard your own Guard
# Guardfile
require 'guard/guard'
class ::Guard::JohnIsAwesome < ::Guard::Guard
def start
puts "Whoa a guard."
end
def run_all
@johnbintz
johnbintz / jsmeter.js
Created February 20, 2012 19:36
Run JSMeter on your code, getting a reasonable output to start cleaning up code complexities
#!/usr/bin/env node
// npm install -g jsmeter
(function () {
var verbose = false;
var args = process.argv;
var fs = require("fs");
@johnbintz
johnbintz / pretty_step_writer.rb
Created April 18, 2012 15:27
Write out undefined Cucumber step definitions, one per file
# this writes out undefined step definitions, one per file, in the usual way that i do cucumber stuff.
# it saves a *lot* of copypaste from the terminal. still in progress as i refine the process.
# use it as a formatter: cucumber -f StepWriter --out features/step_definitions
# save it to support/env/step_writer.rb
require 'cucumber/formatter/io'
class StepWriter
include Cucumber::Formatter::Io
@johnbintz
johnbintz / flay.rb
Created April 20, 2012 19:14
Run flay on your Cucumber steps after a successful run
# run flay on your cucumber steps after a successful run. prevent bloat and
# promote reusability!
flay_exception = nil
flay_level = 32 # set me to a minimum sane level. don't go nuts refactoring!
# code should be cleaner when you're done, not become spaghetti.
After do |s|
flay_exception ||= s.exception
end
@johnbintz
johnbintz / gist:2965472
Last active October 6, 2015 08:28
ruby 1.9.3-p327 with performance patches built into a .deb package with fpm
# For Debian Squeeze + Backports + OpenSSL 1.0.0
# Part 1: Make a deb package of ruby:
# Get our deps
sudo su -c "echo deb http://backports.debian.org/debian-backports squeeze-backports main > /etc/apt/sources.list.d/squeeze-backports.list"
sudo apt-get update
sudo apt-get install -y python-setuptools python-dev build-essential dpkg-dev libopenssl-ruby ruby1.8-dev rubygems bison autoconf zlib1g zlib1g-dev libreadline6 libreadline6-dev libssl1.0.0 libssl-dev
# Get ruby
if [ ! -f ruby-1.9.3-p327.tar.gz ]; then