Skip to content

Instantly share code, notes, and snippets.

View KushalP's full-sized avatar

Kushal Pisavadia KushalP

View GitHub Profile
@mattetti
mattetti / gist:3458669
Created August 25, 2012 01:47
Instrument ActiveRecord and push the results to Statsd
SQL_PARSER_REGEXP = /^(\w+)\s(\w+)\s\W*(\w+)/
ActiveSupport::Notifications.subscribe "sql.active_record" do |name, start, finish, id, payload|
if payload[:name] == "SQL"
if Thread.current[:stats_context] # where I store the name of the request context
payload[:sql] =~ SQL_PARSER_REGEXP # $1 will be the query type, $3 the table
Statsd.timing("#{Thread.current[:stats_context]}.sql.#{$3}.#{$1}.query_time",
(finish - start) * 1000, 1)
end
end
@flashingpumpkin
flashingpumpkin / default-app-recipe.rb
Created December 15, 2011 14:29
Pretty much what every python web dev should do when starting a new project
# Defaults that we'll need
include_recipe "apt"
package "vim"
package "screen"
package "git-core"
package "mercurial"
package "subversion"
package "python"
@petehamilton
petehamilton / gist:1341831
Created November 5, 2011 18:07
Nice way of viewing git branch in terminal
#Handy Git stuff
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function git-track {
CURRENT_BRANCH=$(parse_git_branch)
git-config branch.$CURRENT_BRANCH.remote $1
git-config branch.$CURRENT_BRANCH.merge refs/heads/$CURRENT_BRANCH
}
" Vim syntax file
" Language: LESS Cascading Style Sheets
" Maintainer: Leaf Corcoran <[email protected]>
" Modifier: Bryan J Swift <[email protected]>
" URL: http://leafo.net/lessphp/vim/less.vim
" URL: http://gist.github.com/161047
" Last Change: 2009 August 4
" LESS by Leaf Corcoran
" CSS2 by Nikolai Weibull
" Full CSS2, HTML4 support by Yeti