Skip to content

Instantly share code, notes, and snippets.

View codatory's full-sized avatar

Alex Conner codatory

View GitHub Profile
@codatory
codatory / server.rb
Created December 27, 2013 15:22
HTTP Terminator and Dumper
require 'webrick'
server = WEBrick::HTTPServer.new :Port => 8000
server.mount_proc '/' do |req, res|
puts req.inspect
res.body = nil
end
trap 'INT' do server.shutdown end
@codatory
codatory / distcc-ccache-setup.sh
Created December 24, 2013 17:52
Ubuntu distcc & ccache setup script
#!/bin/bash
apt-get install -y distcc distcc-pump ccache
sed -ie 's/STARTDISTCC="false"/STARTDISTCC="true"/' /etc/default/distcc
sed -ie 's/ALLOWEDNETS="127.0.0.1"/ALLOWEDNETS="192.168.0.0\/16 172.16.0.0\/12 10.0.0.0\/8"/' /etc/default/distcc
sed -ie 's/LISTENER="127.0.0.1"/LISTENER="0.0.0.0"/' /etc/default/distcc
sed -ie "s/JOBS=\"\"/JOBS=\"`grep processor /proc/cpuinfo | wc -l`\"/" /etc/default/distcc
sed -ie 's/ZEROCONF="false"/ZEROCONF="true"/' /etc/default/distcc
{
"binary_file_patterns":
[
"*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf",
"*.tga", "*.dds", "*.ico", "*.eot", "*.pdf",
"*.swf", "*.jar", "*.zip"
],
"caret_style": "phase",
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",
"detect_indentation": false,
@codatory
codatory / benchmark.rb
Created December 11, 2013 16:07
String Performance
# Load benchmark from stdlib
require 'benchmark'
# Pre-compute 10 million integers, return nothing to stdout in IRB
a = (0..9999999).to_a; nil
# Run the test 10x to isolate any fluctuation
(0..9).each do
Benchmark.bm do |x|
x.report("Double Quotes") { a.each {"This is a string"} }
require 'ap'
options = Hash.new(nil)
key = nil
ARGV.each do |arg|
arg = arg.dup
if arg.gsub!(/^--/, '')
key = arg.to_sym
options[key] = true
@codatory
codatory / package.json
Created October 4, 2013 17:44
Node.js based irc bot that checks spelling and corrects people. Highly annoying, but by request.
{
"author": "Alex Conner <[email protected]>",
"name": "spellbot",
"dependencies": {
"wordsworth": ">=0.1.0",
"irc": ">=0.3.6"
}
}
#!/bin/bash
echo '
GIT_REPO=$HOME/site
TMP_GIT_CLONE=$HOME/tmp/site
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
CodeStation:learnrust codatory$ rust run iteration.rs
iteration.rs:5:10: 5:11 error: expected `;` or `}` after expression but found `x`
iteration.rs:5 foreach x in xs.iter() {
@codatory
codatory / ownership.sh
Created August 2, 2013 14:33
"One Liner" to list code ownership of a Rails project tracked with Git. Change the filetypes for other projects.
git ls-tree --name-only -r HEAD | egrep -i '\.(scss|css|js|coffee|rb|html|haml|erb|rake)$' | egrep -v '^vendor' | xargs -o -n1 git blame --line-porcelain | grep "^author " | sed 's/author //' | sort | uniq -c | sort -nr
@codatory
codatory / gist:6140314
Created August 2, 2013 14:32
"One Liner" to list code ownership of a Rails project tracked with Git. Change the filetypes for other projects.
git ls-tree --name-only -r HEAD | egrep -i '\.(scss|css|js|coffee|rb|html|haml|erb|rake)$' | egrep -v '^vendor' | xargs -o -n1 git blame --line-porcelain | grep "^author " | sed 's/author //' | sort | uniq -c | sort -nr