Skip to content

Instantly share code, notes, and snippets.

# Path to your oh-my-zsh configuration.
export 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.
export ZSH_THEME="prose"
# Set to this to use case-sensitive completion
@brianstorti
brianstorti / prose.zsh-theme
Created July 8, 2011 02:18
Prose theme for zsh
if [ "x$OH_MY_ZSH_HG" = "x" ]; then
OH_MY_ZSH_HG="hg"
fi
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
function hg_prompt_info {
$OH_MY_ZSH_HG prompt --angle-brackets "\
@brianstorti
brianstorti / http_traffic.rb
Created July 12, 2011 16:02
Ruby Script to Capture HTTP traffic
# extracted from http://www.thekua.com/atwork/2011/07/ruby-script-to-capture-http-traffic/
require 'webrick'
include WEBrick
class Simple < WEBrick::HTTPServlet::AbstractServlet
def do_POST(request, response)
puts "Body: " + request.body
puts "Header: " + request.raw_header.to_s
@brianstorti
brianstorti / gist:1081829
Created July 14, 2011 02:17
Delete on zsh
#add to .zshrc
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
@brianstorti
brianstorti / gist:1105142
Created July 25, 2011 20:43
Oracle kill user session
# connected as sys
SELECT * FROM V$SESSION WHERE USERNAME LIKE 'CODEIT_BRIANSTORTI'
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
@brianstorti
brianstorti / gist:1106722
Created July 26, 2011 13:12
Oracle unlock user
ALTER USER <<USERNAME>> ACCOUNT UNLOCK
@brianstorti
brianstorti / gist:1107445
Created July 26, 2011 18:25
Add swap Ubuntu
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo mkswap /swapfile
gksu gedit /etc/fstab
add to the end:
/swapfile none swap sw 0 0
reboot
@brianstorti
brianstorti / speadsheet.rb
Created August 5, 2011 02:26
Ruby spreadsheet example
require 'spreadsheet'
Spreadsheet.client_encoding = 'UTF-8'
TEST_FILE = "test.xls"
MODIFIED_FILE = "modified.xls"
def inspect_sheet sheet
sheet.each do |row|
if row[1].is_a? Spreadsheet::Formula
@brianstorti
brianstorti / deploy.rb
Created August 8, 2011 02:17
Simple deploy script
# Just drop this code in lib/tasks/deploy.rake and now a simple '$ rake deploy' will push your changes live.
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
@brianstorti
brianstorti / generate_monkey_code.rb
Created August 22, 2011 16:00
Generate monkey code
require 'rubygems'
require 'spreadsheet'
TEMPLATE = "template.xls"
LOCAL_FILE_NAME = "generated.txt"
Spreadsheet.client_encoding = 'UTF-8'
def inspect_sheet sheet
File.open(LOCAL_FILE_NAME, 'w') {|f|