Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View chetan's full-sized avatar
🙌
like my work? sponsor me!

Chetan Sarva chetan

🙌
like my work? sponsor me!
View GitHub Profile
@felixrabe
felixrabe / s
Last active August 29, 2015 14:03
Reliable subl wrapper
#!/usr/bin/env bash
if [[ $# -eq 0 ]] ; then
subl -w . &
else
subl -w "$@" &
fi
sleep 1
kill $!
# http://unicorn.bogomips.org/SIGNALS.html
rails_env = ENV['RAILS_ENV'] || 'production'
rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
God.watch do |w|
w.name = "unicorn"
w.interval = 30.seconds # default
# unicorn needs to be run from the rails root
# This will ride alongside god and kill any rogue memory-greedy
# processes. Their sacrifice is for the greater good.
unicorn_worker_memory_limit = 300_000
Thread.new do
loop do
begin
# unicorn workers
#
@mguymon
mguymon / gist:981589
Created May 19, 2011 19:56
Buildr uberjar task using one-jar
# XXX: Set the deps you want
deps = []
deps << "com.thoughtworks.xstream:xstream:jar:1.3.1"
deps << "org.quartz-scheduler:quartz:jar:1.8.5"
task :uberjar => :package do |t|
assembly_dir = "target/assembly"
FileUtils.mkdir_p( "#{assembly_dir}/lib" )
@kimsterv
kimsterv / gist:1040741
Created June 22, 2011 18:23
Clean bad gzips
#!/bin/bash
for i in `hadoop fs -lsr /flume/incoming/2011/04 | awk '{print $8}'`; do
echo $i; hadoop fs -cat $i | gzip -t
if [ $? -ne 0 ] && [ -n "`echo \"$i\" | grep 'gz$'`" ]; then
`echo hadoop fs -rmr -skipTrash $i`
fi
done
@chetan
chetan / install_cpanm_oneliner.sh
Created December 22, 2011 21:23
install cpanm in oneline
## don't screw around with cpan! just just cpan-minus!!
##
## run as root!
cd /usr/local/bin; curl -fsSLO http://xrl.us/cpanm; chmod 755 cpanm
## then install away!
## -q = queit, -n no test (who needs those pesky things?!)
cpanm -qn Moose
@eungjun-yi
eungjun-yi / gfm.coffee
Created April 10, 2012 08:53
Coffeescript port of gfm at https://gist.github.com/118964
crypto = require 'crypto'
gfm = (text) ->
# Extract pre blocks
extractions = {}
text = text.replace /<pre>(\n|.)*?<\/pre>/gm, (match) ->
md5 = crypto.createHash('md5').update(match).digest('hex')
extractions[md5] = match
'{gfm-extraction-' + md5 + '}'
@div
div / 0-readme.md
Created October 3, 2012 09:49 — forked from sj26/0-readme.md
ruby-1.9.3-p327 cumulative performance patch.

Patched ruby 1.9.3-p327 for 30% faster rails boot + with support of utf-8 console input

What is?

This script installs a patched version of ruby 1.9.3-p327 with patches for boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@evanphx
evanphx / gist:3830137
Created October 3, 2012 21:55
Rubygems.org outage - Post Mortem

Context

The rubygems.org infrastructure has been under heavier and heavier load and the need to move to something that handles the load better was well established.

Migration to new setup

On October 3rd, I opted to begin the migration to a setup based on RackSpace Cloud I had been working on for the last few weeks. This setup uses different instances for load balancers, application servers, and database and is designed to be able to deal better with the load that rubygems.org generates.

Upon coordinating with other developers in #rubygems on irc.freenode.net, at 13:56 PT we (the rest of the rubygems.org team) were all happy with the new setup and begin the transition.

@dblock
dblock / api_new_relic_instrumenter.rb
Created November 29, 2012 17:12
NewRelic Instrumentation for Grape API DSL
class ApiNewRelicInstrumenter < Grape::Middleware::Base
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
def call_with_newrelic(&block)
trace_options = {
:category => :rack,
:path => "#{route_path}\##{route_method}",
:request => request
}