Skip to content

Instantly share code, notes, and snippets.

View mlafeldt's full-sized avatar

Mathias Lafeldt mlafeldt

View GitHub Profile
@mlafeldt
mlafeldt / gist:2689644
Created May 13, 2012 18:31
[Ruby] Thread perf test
loop_count = 100_000_000
threads = 2
threads.times.collect do
Thread.new do
loop do
time = Time.now
i = loop_count
i -= 1 until i.zero?
puts "#{Thread.current}: #{Time.now - time} seconds for looping " +
"#{loop_count} times"
@mlafeldt
mlafeldt / Vagrantfile
Created June 10, 2012 17:30
Vagrantfile for PS2 development
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "ps2dev"
config.vm.box_url = "https://github.com/downloads/mlafeldt/ps2toolchain/ps2dev.box"
end
@mlafeldt
mlafeldt / app.rb
Created July 11, 2012 15:41
Skeleton for Ruby command-line app
#!/usr/bin/env ruby
#/ SYNOPSIS
#
# Run `CMD --help` for full documentation.
#
# Written by NAME
require 'optparse'
options = {
@mlafeldt
mlafeldt / .gitignore
Created July 13, 2012 14:39
Example of a modular and self-contained Sinatra app
/.bundle
/bin/
/vendor/gems/
@mlafeldt
mlafeldt / Vagrantfile
Created July 20, 2012 12:37
Provisioning Ubuntu 12.04 + pbuilder with Vagrant
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.customize ["modifyvm", :id, "--memory", 1500]
config.vm.provision :shell, :path => "pbuilder.sh"
end
@mlafeldt
mlafeldt / shellconfig.py
Created July 23, 2012 12:28
Access shell config files from Python
#!/usr/bin/env python
#
# inspired by ConfigParser.py
#
import sys
import re
class ParsingError(Exception):
"""Raised when a file does not follow legal syntax."""
@mlafeldt
mlafeldt / gist:3378736
Created August 17, 2012 13:37
Serve folder in home with nginx
# /etc/nginx/sites-enabled/home
server {
listen 8080;
root /home/mlafeldt/www;
index index.html index.htm;
server_name localhost;
location / {
autoindex on;
}
}
@mlafeldt
mlafeldt / draft.md
Created September 12, 2012 10:55
RSpec JUnit Formatters
@mlafeldt
mlafeldt / post.md
Created September 17, 2012 09:06
ChefSpec cookbook dependencies

Works:

mkdir cookbooks
cd cookbooks/
git clone git://github.com/mlafeldt/ps2dev-cookbook.git ps2dev
git clone git://github.com/opscode-cookbooks/build-essential.git
git clone git://github.com/opscode-cookbooks/git.git
rspec .
@mlafeldt
mlafeldt / README.md
Created September 19, 2012 19:52
Process metadata of Chef cookbooks
We couldn’t find that file to show.