Skip to content

Instantly share code, notes, and snippets.

View garyharan's full-sized avatar

Gary Haran garyharan

View GitHub Profile
@garyharan
garyharan / pcb
Created August 16, 2013 14:22
We use a convention where each branch is created from an issue. This converts the branch to a pull request in a single command.
cp pcb ~/bin/ # where bin is in your $PATH
chmod +x ~/bin/pcb
@garyharan
garyharan / .vimrc
Created July 26, 2013 21:23
Run a single spec block in vim using a named pipe.
" Of course this can be edited to run whatever you want instead of spring and rspec
map <leader>l :w\|:silent exe "! echo \"spring rspec " . "%" . ":" . line('.') . "\" > test-commands"<cr>
@garyharan
garyharan / colorize.rb
Last active June 3, 2024 15:06
Simple rails logging output colorize
#!/usr/bin/env ruby -w
# SETUP:
# (assumes ~/bin/ is in your path)
# cp colorize.rb ~/bin/colorize
# chmod +x ~/bin/colorize
# USAGE:
# tail -f log/development.log | colorize
class String
@garyharan
garyharan / everything_is_an_object.rb
Created May 6, 2013 13:51
Just to show a few students a little more about objects
# encoding: UTF-8
#
# I realized objects were hard to grasp
# You already understood the building blocks of programs(String, Fixnumb, Array, Hash)
#
# Look at the following to see what you can learn:
s1 = 'String is an object'
s2 = String.new('String is an object')
@garyharan
garyharan / .vimrc
Created May 2, 2013 16:59
my .vimrc
set nocompatible " no more legacy
set laststatus=2 " show status lines 2 lines up so I see it
" Vundle specifics
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
" Bundle 'less.vim'
Bundle 'groenewege/vim-less'
@garyharan
garyharan / dot_pryrc
Created June 18, 2012 14:23
Awesome Print + Pry == Awesome Pry
require "rubygems"
require "awesome_print"
Pry.print = proc { |output, value| output.puts value.ai }
# thanks to cmer for this
if Rails.env.development?
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
@garyharan
garyharan / jquery.sample.coffee
Created September 13, 2011 16:19
Sample coffeescript jquery plugin
(($) ->
default_options =
color: 'red'
$.fn.samplePlugin = (options = default_options) ->
hello()
@each ->
$(this).css
background: options.color
@garyharan
garyharan / aliases.sh
Created June 20, 2011 18:42
Bash functions for rails 2/3
#!/bin/sh
# script/server with Rails 3 support
ss() {
if [ -f ./script/rails ]; then
./script/rails server $@
else
./script/server $@
fi
}
@garyharan
garyharan / larger_checkboxes.css
Created May 20, 2011 18:40
How to make checkboxes bigger in Safari/Webkit browsers
input[type="checkbox"] {
-webkit-transform: scale(1.2, 1.2);
}