Skip to content

Instantly share code, notes, and snippets.

View jbrown's full-sized avatar

Justin Brown jbrown

View GitHub Profile
@jbrown
jbrown / generate_keys.sh
Created September 14, 2012 21:03
Generate SSL keys
openssl genrsa -des3 -out server.key 4096
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key
@jbrown
jbrown / setup.sh
Created September 9, 2012 18:50
Setup Postgres on OS X
brew install postgresql
initdb /usr/local/var/postgres -E utf8
psql -h localhost postgres
gem install passenger
brew install --env=std nginx --with-passenger
# start
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@jbrown
jbrown / install.sh
Created August 13, 2012 20:05
Installing git from source on Redhat
# Usage: curl -kL https://raw.github.com/gist/3343750/HASH/install.sh | bash
# git dependencies
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# so we can compile git
yum install -y gcc gcc-c++
# now download git from github
# https://github.com/git/git/downloads
@jbrown
jbrown / app.js
Created January 27, 2012 15:53 — forked from adjohu/app.js
Editor.ElementView = Em.View.extend({
classNameBindings: ['isSelected'],
isSelected: function() {
var selectedElement = Editor.selectedElementController.get('content'),
content = this.get('content');
if(selectedElement === content) { return true; }
}.property('Editor.selectedElementController.content', 'content'),
@jbrown
jbrown / benchmark_quotes.rb
Created November 20, 2011 21:03
Benchmarking ruby single/double quotes
require 'benchmark'
puts "\npatchlevel: #{RUBY_PATCHLEVEL}, release_date: #{RUBY_RELEASE_DATE}, ruby_version: #{RUBY_VERSION}, ruby_platform: #{RUBY_PLATFORM}\n"
n = 1000000
Benchmark.bm do |x|
x.report("assign single") { n.times do; c = 'a string'; end}
x.report("assign double") { n.times do; c = "a string"; end}
x.report("assign interp") { n.times do; c = "a #{n} string"; end}
x.report("concat single") { n.times do; 'a string ' + 'b string'; end}
require 'fileutils'
require 'vagrant'
# require 'nokogiri'
FileUtils.mkdir_p 'tmp'
env = Vagrant::Environment.new(:cwd => File.expand_path('tmp'))
Dir.chdir 'tmp' do
env.cli 'init', 'CentOS-5.7-build'
end
env.cli 'up'
@jbrown
jbrown / packages.rb
Created October 3, 2011 15:03
Detailed package info for CentOS 5.6
require 'rubygems'
require 'nokogiri'
require 'open-uri'
@xml = Nokogiri open 'http://vault.centos.org/5.6/os/x86_64/repodata/comps.xml'
def printGroups(default = true)
puts "=== #{'Non' unless default}Default Groups ==="
@xml.xpath("//default[text()='#{default}']/..").each_with_index do |group, ix|
puts "#{ix + 1}.) #{group.at_xpath('name').text}"
cp .git/hooks/pre-commit.sample .git/hooks/pre-commit && curl https://gist.github.com/raw/799683/9be5fe0b49db3c98886ba93f994d850713e3eab3/pre-commit > .git/hooks/pre-commit
#!/bin/sh
# Check Ruby syntax and run the test suites
files=`git diff --cached --name-only`
for file in $files; do
if [[ ${file##*.} = 'rb' ]]; then
ruby -c $file
elif head -1 $file | grep 'ruby$'; then
ruby -c $file
fi
@jbrown
jbrown / pre-commit
Created January 28, 2011 01:53
.git/hooks/pre-commit
#!/usr/bin/env ruby
# Check Ruby syntax and run the test suites
exit 1 unless
system('git diff --cached --name-only | grep "\(Rakefile\|\.rb$\)" | xargs ruby -c') &&
system('rake ci')