Skip to content

Instantly share code, notes, and snippets.

View seven1m's full-sized avatar

Tim Morgan seven1m

View GitHub Profile
#!/bin/bash
# Redirect output to stderr.
exec 1>&2
egrep -r --exclude=spec/spec_helper.rb ":focus|focus:|fdescribe|fcontext|fit ['\"]" spec
if [[ $? == 0 ]]; then
echo "Thou must not :focus"
exit 1
fi
@seven1m
seven1m / onebody_import.rb
Last active March 22, 2016 01:39
Terminal script to sync data with OneBody using a CSV file
#!/usr/bin/env ruby
#
# NOTE: Your version of OneBody must be 3.5.0 or higher for this to work.
#
# This is a very simple script you can use to automate syncing of data with OneBody.
# To use, first:
#
# gem install rest-client
#
# Then, edit the USER_EMAIL, USER_KEY, and URL constants just below. To get your USER_KEY,
@seven1m
seven1m / cow.rb.py.php
Created August 19, 2015 18:43
Prints a cow in Ruby, Python, and PHP
#<?php
print("\n (__)\n (uu)\n /-------\\/\n / | ||\n* ||----||\n ~~ ~~\n");
@seven1m
seven1m / .watchr
Created June 26, 2015 01:29
.watchr config for watchr/observr
# run the specs when anything changes
watch('.*') do
cmd = IO.popen('rspec spec 2>&1')
print cmd.getc until cmd.eof?
end
@seven1m
seven1m / test.rb
Last active August 29, 2015 14:05
Bug in ActiveRecord where(...).create() -- see https://github.com/rails/rails/issues/16668
require 'active_record'
require 'sqlite3'
require 'rspec'
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
ActiveRecord::Base.logger = Logger.new(STDOUT)
@seven1m
seven1m / fix_find_all.rb
Last active August 29, 2015 14:04
Fix old Rails 1.x finder syntax.
#!/usr/bin/env ruby
# A script to convert old Rails 1.x finder syntax, e.g. find(:all, ...) and find(:first, ...)
# to use where() and friends.
# gem install parser unparser
# cd path/to/rails_app
# ruby fix_find_by.rb
require 'parser/current'
@seven1m
seven1m / Vagrantfile.local
Created July 5, 2014 16:43
Tweaks to my Vagrantfile for OneBody, to make things run faster
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", type: "nfs"
@seven1m
seven1m / PlusOne.user.js
Last active August 29, 2015 14:02
GreaseMonkey (or TamperMonkey) script that adds a +1 button to GitHub Pull Requests. (Click "Raw" to install.)
// ==UserScript==
// @name GitHub Pull Request Enhancements
// @namespace http://tannermar.es
// @version 0.2
// @description Add "Plus One" and "Retest" buttons to PR pages. Automatically add and remove "+1", "+2", and "NOT READY!" labels bast on comment contents. Included on all of github because pushState.
// @include https://github.com/*
// @copyright 2014+, @tannermares
// ==/UserScript==
var emojiPlusOnes = function() {
@seven1m
seven1m / fix_find_by.rb
Last active August 29, 2015 14:01
Change find_by_ and find_all_by_ AR finder calls to where+first and where+all.
#!/usr/bin/env ruby
# A script to convert old dynamic finder syntax to new where+first and where+all.
# Used to do the grunt work for this PR: https://github.com/churchio/onebody/pull/63
# gem install parser unparser
# cd path/to/rails_app
# ruby fix_find_by.rb
require 'parser/current'
@seven1m
seven1m / to_rspec.rb
Last active August 29, 2015 14:01
Really dumb script for converting from MiniTest::Unit to RSpec. This will get 80% of the grunt work done for you.
#!/usr/bin/env ruby
# This is a crude script to convert MiniTest::Unit files to RSpec files.
# To use:
#
# cd path/to/your/railsapp
# gem install parser unparser
# ruby to_rspec.rb
# rspec spec --fail-fast
#