Skip to content

Instantly share code, notes, and snippets.

View garyharan's full-sized avatar
🎯
Focusing

Gary Haran garyharan

🎯
Focusing
View GitHub Profile
@garyharan
garyharan / args
Created April 6, 2011 00:50
fudging args
#!/usr/bin/ruby
require 'net/http'
def url(*args)
if args.length == 1
"/#{1}/#{args[0]}.json"
else
"/#{1}/#{args.shift.to_s}.json?#{parametrize args}"
end
end
@garyharan
garyharan / _mixins.scss
Created May 5, 2011 15:46
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@garyharan
garyharan / compilemacvim.sh
Created May 13, 2011 13:04
How I compiled macvim
./configure --with-features=huge --enable-cscope --enable-pythoninterp --enable-rubyinterp --enable-perlinterp --enable-gui=macvim --with-mac-arch=intel --enable-multibyte --enable-clipboard=yes --enable-xterm_clipboard=yes
@garyharan
garyharan / jquery.placeholder.js
Created May 20, 2011 14:47
Make older browsers act as do modern browsers in regards to placeholder in inputs
$(function(){
if ("placeholder" in document.createElement( "input" )){ return }
$('input[placeholder]').each(function(){
$(this).val($(this).attr('placeholder')).css('color', '#999')
}).focus(function(){
var placeholder = $(this).attr('placeholder')
$(this).val( placeholder == $(this).val() || $(this).val() == '' ? '' : $(this).val() ).css('color', '#333')
}).blur(function(){
var placeholder = $(this).attr('placeholder')
@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);
}
@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 / 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 / install_ruby_debug_1.9.3.sh
Created March 15, 2012 23:23
Installing ruby-debug with ruby 1.9.3
# After installing ruby-debug19, run this file.
#
# References:
# http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
# http://stackoverflow.com/questions/8087610/ruby-debug-with-ruby-1-9-3
echo "Installing ruby-debug with $MY_RUBY_HOME ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
# 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 / 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 }