Skip to content

Instantly share code, notes, and snippets.

View jwaldrip's full-sized avatar
:octocat:

Jason Waldrip jwaldrip

:octocat:
View GitHub Profile
@jwaldrip
jwaldrip / .zsh_config
Created January 25, 2013 04:59
Added this to my .zsh_config
alias yolo!=git add . && git commit -m "YOLO!!!" && git push --force origin master
class ApplicationController < ActionController::Base
def session
@session ||= SessionHijacker.new(super, request)
end
def session=(session)
"------ SESSION WAS REPLACED!!!"
super(session)
end
class AppBuilder < Rails::AppBuilder
include Thor::Actions
include Thor::Shell
def test
append_test_gems
rspec_install
spork_init
guard_init
end
@jwaldrip
jwaldrip / mod_hash.rb
Created February 27, 2013 22:05
Converts all ruby files in the directory to use the 1.9+ hash syntax.
Dir["**/*.rb"].each do |file|
replacements = File.open(file).read.gsub /:([a-z_]+)(\s+)?=>(\s+)?/, '\1: '
file = File.open file, 'w' do |f|
f.write replacements
end
end
require 'benchmark'
def int_pal?(num)
n = num
reverse = 0
while (num > 0)
dig = num % 10
reverse = reverse * 10 + dig
num = num / 10
end
@jwaldrip
jwaldrip / .pryrc
Last active December 16, 2015 20:59
place in $HOME/.pryrc
#!/usr/bin/env ruby
[Method, UnboundMethod].each do |klass|
klass.class_eval do
def rubymine
path = source_location.join(':')
`mine #{path}`
nil
class BasicObject
def self.local_methods
return methods unless superclass
methods - superclass.methods
end
def self.local_method(sym)
method self.local_methods.find { |i| i == sym }
end
@jwaldrip
jwaldrip / .railsrc
Last active December 17, 2015 02:48
A rails 3.2.x/4.x template, with GitHub integration.
--database=postgresql
--skip-test-unit
--skip-bundle
--template=https://gist.github.com/jwaldrip/5538342/raw/rails-template.rb
# Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files
# for Pry binding references
#
# Installation
#
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
#
# Based on
#
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
class FeedItem < ActiveRecord::Base
# hstore is data
def self.field(name)
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}=(val)
self.data[:#{name}] = val
end