Skip to content

Instantly share code, notes, and snippets.

Avatar
👯‍♀️
OMG

Ian Vaughan IanVaughan

👯‍♀️
OMG
View GitHub Profile
@IanVaughan
IanVaughan / gist:9187837
Created Feb 24, 2014
xray rails error with Angular view
View gist:9187837
TypeError - no implicit conversion of String into Hash:
xray-rails (0.1.12) lib/xray/config.rb:46:in `load_config'
xray-rails (0.1.12) lib/xray/config.rb:14:in `editor'
xray-rails (0.1.12) app/views/_xray_bar.html.erb:35:in `___sers_ian__rbenv_versions_______p____lib_ruby_gems_______gems_xray_rails________app_views__xray_bar_html_erb__3419748363069709208_70297798074320'
() Users/ian/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/rails-b6fc77c3368d/actionpack/lib/action_view/template.rb:145:in `block in render'
() Users/ian/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/rails-b6fc77c3368d/activesupport/lib/active_support/notifications.rb:125:in `instrument'
() Users/ian/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/rails-b6fc77c3368d/actionpack/lib/action_view/template.rb:143:in `render'
xray-rails (0.1.12) lib/xray/engine.rb:30:in `render_with_xray'
() Users/ian/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/rails-b6fc77c3368d/actionpack
@IanVaughan
IanVaughan / convert_aws_to_fog.rb
Created Apr 2, 2014
Converts AWS_CREDENTIAL_FILE to a .fog one
View convert_aws_to_fog.rb
#!/usr/bin/env ruby
require 'yaml'
unless filename = ENV['AWS_CREDENTIAL_FILE']
puts "No AWS_CREDENTIAL_FILE file found!"
exit 1
end
credentials = Hash[File.new(filename).each_line.map { |line| line.chomp.split('=') }]
@IanVaughan
IanVaughan / raise-in-users-class.rb
Created Apr 9, 2014
Example of raising in the callers class, not the where the method_missing is defined.
View raise-in-users-class.rb
class Base
def method_missing(method, *args, &block)
yield block if block_given?
super
rescue NoMethodError, NameError => e
raise e, e.exception, e.backtrace[1..-1]
end
end
class UsesBase < Base
@IanVaughan
IanVaughan / go-slow.sh
Created Oct 11, 2014
Make your internet like the 80ies
View go-slow.sh
#!/bin/bash
help() {
echo 'G o S L O W ...'
}
stop() {
sudo ipfw delete 1
sudo ipfw delete 2
sudo ipfw pipe 1 delete
@IanVaughan
IanVaughan / move_todo.rb
Created Nov 6, 2014
Move TODOs from code to GitHub
View move_todo.rb
require 'github_api'
path = '.'
USER = 'user'
REPO = 'repo'
OAUTH_TOKEN = 'xxxx'
def files(path)
(`ag TODO #{path} -l`).split
@IanVaughan
IanVaughan / upload_to_s3.rb
Last active Aug 29, 2015
Uploads a given file to S3 files.econultancy.com bucket and sets permissions to Everyone:Read/Download
View upload_to_s3.rb
#!/usr/bin/env ruby
# Uploads a given file to S3 files.econultancy.com bucket
# and sets permissions to Everyone:Read/Download
# (Default of Tech:Read/Write/Delete still set)
# Uses config in ~/.fog if present,
# otherwise falls back to using ENV vars
# export AWS_ACCESS_KEY_ID=xxx
@IanVaughan
IanVaughan / invalid_records.rb
Last active Aug 29, 2015
Finds invalid rails records
View invalid_records.rb
#!/usr/bin/env ruby
puts "Loading Rails..."
require 'ruby-progressbar'
require './config/environment'
require "csv"
puts "Booting Rails..."
Rails.application.eager_load!
View cucumber
#!/usr/bin/env ruby
args = *ARGV
if File.exists?('.zeus.sock')
puts "=> Using Zeus..."
exec "zeus cucumber #{args.join(' ')}"
else
puts "=> NOT Using Zeus..."
exec "bundle exec cucumber #{args.join(' ')}"
end
View pre-commit
#!/bin/bash
# Dont allow commits containing the addition of '@wip'
if test "$(git diff --cached | grep '\+\s*@wip')"
then
echo "Error: Attempt to commit an @wip line"
echo
echo "To skip this check, add the --no-verify option"
echo
exit 1
fi