Skip to content

Instantly share code, notes, and snippets.

@adriancb
adriancb / remove_all_gems.sh
Created May 12, 2014 18:35
Remove all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@adriancb
adriancb / convert.sh
Created January 13, 2015 15:19
FLAC to MP3
#!/bin/bash
for f in "$@"; do
[[ "$f" != *.flac ]] && continue
album="$(metaflac --show-tag=album "$f" | sed 's/[^=]*=//')"
artist="$(metaflac --show-tag=artist "$f" | sed 's/[^=]*=//')"
date="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')"
title="$(metaflac --show-tag=title "$f" | sed 's/[^=]*=//')"
year="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')"
genre="$(metaflac --show-tag=genre "$f" | sed 's/[^=]*=//')"
@adriancb
adriancb / size.rb
Created June 18, 2015 18:16
Show size of PG tables
ActiveRecord::Base.connection.execute("SELECT relname AS relation, pg_size_pretty(pg_relation_size(C.oid)) AS size FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') ORDER BY pg_relation_size(C.oid) DESC LIMIT 100;").each {|c| puts c}
require 'rubygems'
require 'sinatra'
require 'mongoid'
configure do
Mongoid.configure do |config|
name = "demo"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.slaves = [
@adriancb
adriancb / burning_man
Created August 11, 2014 21:58
burning_man
- Vinegar for Playa Dust
- Prepare for all types of weather, Rain is the worst
- Mallet
- Duct Tape
- Rebar for tents and shelters - pegs will not do it, winds are very strong - Home Depot
- Shade cloths
- 1.5 gallons of water per person per day
- Greywater (esky water), spray it around the camp to keep the dust down
- Electrolytes
- Spray bottles for bathing
Object.new.method(:foo).source_location
@adriancb
adriancb / zshrc
Created January 24, 2013 16:34
Standard ZSH conf
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="geoffgarside"
# Set to this to use case-sensitive completion
@adriancb
adriancb / aliases.sh
Last active December 11, 2015 15:59
Standard Aliases conf
# Ruby
alias be="nocorrect bundle exec"
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
@adriancb
adriancb / gitconfig.sh
Created January 24, 2013 16:38
Standard Gitconfig conf
[user]
name =
email =
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
@adriancb
adriancb / sshmultikey.sh
Created January 24, 2013 16:39
SSH Multi-Key
touch ~/.ssh/config
chmod 600 ~/.ssh/config
echo "IdentityFile ~/.ssh/id_rsa.work" >> ~/.ssh/config
echo "IdentityFile ~/.ssh/id_rsa.misc" >> ~/.ssh/config