Skip to content

Instantly share code, notes, and snippets.

View jwilkins's full-sized avatar

Jonathan Wilkins jwilkins

  • San Francisco, CA
View GitHub Profile
@jwilkins
jwilkins / osx-ruby-editline-to-readline.sh
Created September 30, 2011 09:18
True Readline for Ruby 1.8.7-p174 on OS X 10.6 using Homebrew
# http://andre.arko.net/2011/05/26/add-true-readline-to-ruby-on-os-x-1067/
# Install readline
brew install readline
# Download the readline extension
cd /tmp
svn co http://svn.ruby-lang.org/repos/ruby/tags/v1_8_7_174/ext/readline/
# Compile the bundle against homebrewed readline
make readline.o CFLAGS=‘-I/usr/local/Cellar/readline/6.1/include -DHAVE_RL_USERNAME_COMPLETION_FUNCTION’
@jwilkins
jwilkins / node_rlwrap
Created October 9, 2011 21:20
rlwrap for node
#http://blog.doteight.com/2011/01/16/rlwrap-and-node.html
#http://utopia.knoware.nl/~hlub/rlwrap/rlwrap.html
alias node='env NODE_NO_READLINE=1 rlwrap -p Green -S "node >>> " node'
@jwilkins
jwilkins / gist:1275507
Created October 10, 2011 14:50
clone/copy remote drives
ssh user@host "tar -zc --one-file-system -f - /" > host-partition-date.tar.gz
ssh user@host "dd if=/dev/sda | bzip2" > host-sda.dd.bz2
# http://cb.vu/unixtoolbox.xhtml
server# dd if=/dev/da0 | nc -l 4444 # Server partition image
client# nc 192.168.1.1 4444 | dd of=/dev/da0 # Pull partition to clone
client# nc 192.168.1.1 4444 | dd of=da0.img # Pull partition to file
@jwilkins
jwilkins / gist:1281976
Created October 12, 2011 17:52
dsocks osx
svn checkout http://dsocks.googlecode.com/svn/trunk/ dsocks
cd dsocks
bsdmake && sudo bsdmake install
cp dsocks.sh ~/bin/dsocks
@jwilkins
jwilkins / gist:3744272
Created September 18, 2012 16:55 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@jwilkins
jwilkins / gist:3860887
Created October 9, 2012 19:27
HMAC CLI (HMAC-SHA1 HMAC-MD5 HMAC-SHA256 HMAC-SHA512)
#!/usr/bin/env ruby
# echo -n 'asdfasdf' |./hmacsha1 --key foobar'
# 60ff950bea9d6dc7018de881909057e4bba14e26
require 'openssl'
require 'optparse'
key = 'horriblekeychangeme'
algo = 'sha512'
verbose = false
@jwilkins
jwilkins / gist:3984126
Created October 31, 2012 00:48
ack for hostnames & ip addresses in a source tree (given a domain name)
# hostnames
ack -oa '((\w+\.){1,3}domainname(\.\w+){1,3})' | cut -f3 -d':' | sort| uniq
# ipv4 addresses
ack -oa '((\d+\.){3,3}\d+(:\d+)?)' | cut -f3-4 -d':' | sort| uniq
@jwilkins
jwilkins / gist:4705147
Created February 4, 2013 05:19
Faster mysql dump import (innodb) & database size checks
(echo "SET autocommit=0; SET unique_checks=0; SET foreign_key_checks=0;"; cat database_name.sql ; echo "COMMIT;" ) | mysql database_name
# in /etc/my.cnf set:
# innodb_flush_log_at_trx_commit = 2
# innodb_file_per_table
# check size of databases:
#SELECT table_schema AS "Data Base Name",
#ROUND(SUM( data_length + index_length ) / 1024 / 1024, 2) AS "Data Base Size in MB"
#FROM information_schema.TABLES GROUP BY table_schema ;
@jwilkins
jwilkins / macvim-split-browser.rb
Created February 9, 2013 03:38
Homebrew formula for latest macvim (2012/02/08) merged with alloy's split browser patch
require 'formula'
class MacvimSplitBrowser < Formula
homepage 'https://github.com/jwilkins/macvim/'
url 'https://github.com/jwilkins/macvim/tarball/7b9e621f41ad0193336c18fe0ad239ab2c4cc15a'
version '20130208'
sha1 '8d966f95a335d34e79cf8d7d2f784718b7f1af41'
head 'https://github.com/jwilkins/macvim.git' #, :branch => 'split-browser'
@jwilkins
jwilkins / p4merge
Created February 27, 2013 21:05 — forked from henrik242/p4merge
#!/bin/bash
for arg; do [[ $arg = /* ]] || arg=$PWD/$arg; absargs+=("$arg"); done;
/Applications/p4merge.app/Contents/Resources/launchp4merge "${absargs[@]}"