Skip to content

Instantly share code, notes, and snippets.

View jschairb's full-sized avatar

Josh Schairbaum jschairb

View GitHub Profile
@jschairb
jschairb / rdhcpd.rb
Created May 7, 2012 21:08 — forked from telamon/rdhcpd.rb
Pure ruby DHCP server
' Copyright (c) 2007, Tony Ivanov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <[email protected]>
# Copyright:: 2007-2010 The Authors
@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?

# 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 / 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.
# 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
#!/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
#
@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