Skip to content

Instantly share code, notes, and snippets.

# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
@joeyAghion
joeyAghion / .bash_profile
Created November 17, 2011 00:17
helpful bash and environment snippets
# Display current git branch, nicely colored, in the prompt (with a * if there are changes)
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\u:\[\033[31;40m\]\w\[\033[0;33m\]$(parse_git_branch)\[\e[0m\]$ '
export EDITOR='mate -w'
@joeyAghion
joeyAghion / benchmark.bash
Created December 8, 2011 23:11
benchmark of .where(:_id.in => [...]) vs. multiple .find MongoDB/Mongoid queries
$ bex rails benchmarker 1000 "Artwork.where(:_id.in => [<...100 doc ids...>]).map(&:title)" "[<...100 doc ids...>].map{|id| Artwork.find(id) }.map(&:title)"
user system total real
#1 112.410000 1.470000 113.880000 (116.483996)
#2 151.740000 4.310000 156.050000 (166.557997)
[cache]
LOCAL_DATA_DIR = /opt/graphite/storage/whisper/
# Specify the user to drop privileges to
# If this is blank carbon runs as the user that invokes it
# This user must have write access to the local data directory
USER = www-data
# Limit the size of the cache to avoid swapping or becoming CPU bound.
# Sorts and serving cache queries gets more expensive as the cache grows.
@joeyAghion
joeyAghion / git-unmerged
Created May 30, 2012 20:34
Script for reporting what local branches haven't been merged into master. Slightly adapted from http://www.mutuallyhuman.com/blog/2009/07/02/finding-unmerged-commits-with-git-unmerged/
#!/usr/bin/env ruby
require 'rubygems'
gem 'term-ansicolor', '=1.0.3'
require 'term/ansicolor'
class GitCommit
attr_reader :content
@joeyAghion
joeyAghion / cpi_historical.json
Last active July 11, 2017 19:05
Historical Consumer Price Index (CPI) data, by month. Originally sourced from http://www.alyz.com/oldrates/cpiu.data. Updates borrowed from http://www.inflationdata.com/Inflation/Consumer_Price_Index/HistoricalCPI.aspx.
[
[1913,1,9.8],
[1913,2,9.8],
[1913,3,9.8],
[1913,4,9.8],
[1913,5,9.7],
[1913,6,9.8],
[1913,7,9.9],
[1913,8,9.9],
[1913,9,10.0],
@joeyAghion
joeyAghion / app.rb
Created July 9, 2012 02:40
Example files implementing the log-driven slideshow described in "Spend time with your site" post (http://artsy.github.io/blog/2012/07/05/spend-time-with-your-site/).
require 'rubygems'
require 'sinatra'
require 'json'
get '/latest' do
# This is where the [ugly] magic happens. Grep an appropriate path from the _end_ of the incoming log file,
# excluding office IP range and paying special attention to escaping...
line = `tac /var/log/heroku.log | grep ".*GET [^\?]*/home\/[^/ \\"]*" | grep -v "controls\\|pending\\|99\\.99\\." -m 1`
if match = line.match(/\/home\/([a-z0-9\-]*)/i)
return match[1].to_json
@joeyAghion
joeyAghion / benchmark.rb
Created November 30, 2012 19:45 — forked from panthomakos/benchmark.rb
Benchmark Your Bundle
#!/usr/bin/env ruby
# Set the CHECK_RAILTIE environment variable to star (*) gems without Railties (warning: SLOW).
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
@joeyAghion
joeyAghion / benchmark_bundle.rb
Created December 3, 2012 00:28 — forked from bdurand/benchmark_bundle.rb
Benchmark Your Bundle
#!/usr/bin/env ruby
# Set the CHECK_RAILTIE environment variable to star (*) gems without Railties (warning: SLOW).
require 'bundler'
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
#!/usr/bin/env ruby
# I don't remember where I found this, but all credit goes to them.
require 'rubygems'
gem 'term-ansicolor', '=1.0.3'
require 'term/ansicolor'
class GitCommit
attr_reader :content