Skip to content

Instantly share code, notes, and snippets.

View jschairb's full-sized avatar

Josh Schairbaum jschairb

View GitHub Profile
We couldn’t find that file to show.
@jschairb
jschairb / gist:71709
Created February 27, 2009 21:28
Grab Password from 1Password
# Grab a password out of the 1Password keychain...finding it by "name"
def password_for_hostname(name)
password_info = `security 2>&1 >/dev/null find-generic-password -gs passwords.Password:#{name} 1Password.keychain`
password = password_info.match(/\"\:\"(.+)\"\}\"/)[1] rescue nil
end
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites want to give yourself
# access to only during certain times of day.
#
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#
# this goes in the $HOME dir
# needs mislav-rspactor v0.3.2 and RSpec 1.2
Rspactor::Runner.class_eval do
class << self
alias old_formatter_opts formatter_opts
def formatter_opts
# update this path to where you saved unicode_formatter.rb
old_formatter_opts + " -r /Users/mislav/Projects/unicode_formatter -f UnicodeFormatter"
end
@jschairb
jschairb / httpdump
Created April 4, 2009 16:36 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
# http://www.jamesbritt.com/2007/12/18/sending-mail-through-gmail-with-ruby-s-net-smtp
# http://d.hatena.ne.jp/zorio/20060416
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
@jschairb
jschairb / 0what.md
Created August 30, 2009 20:20 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

# I know there are 80 issues associated with this project
page_one = RedmineClient::Issue.find(:all, :params => { :project_id => @project_id, :page => 1 } )
# returns 1st 25 records
page_five = RedmineClient::Issue.find(:all, :params => { :project_id => @project_id, :page => 5 })
# returns 1st 25 records
@jschairb
jschairb / pivotmine.rb
Created October 15, 2010 19:39
Simple script to paginate issues in Redmine and load them into Pivotal Tracker.
#!/usr/bin/env ruby
require 'rubygems'
require 'active_resource'
require 'redmine_client'
require 'pivotal-tracker'
require 'yaml'
ActiveResource::Base.logger = Logger.new(STDOUT)
ActiveResource::Base.logger.level = Logger::DEBUG
#!/bin/sh
aptitude update
aptitude safe-upgrade -y
apitude install ruby-full git-core mysql-server mysql-client apache2-mpm-worker libmysql-ruby -y
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar xzvf rubygems-1.3.7.tgz
cd rubygems-1.3.7