Skip to content

Instantly share code, notes, and snippets.

💙
Coding Go

Peter Hellberg peterhellberg

💙
Coding Go
Block or report user

Report or block peterhellberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lonemodell_with_json.rb
module Athega
class LonemodellWithJSON < Lonemodell
def to_json(*args)
Yajl::Encoder.encode(to_hash)
end
end
end
@peterhellberg
peterhellberg / blunderbuss.sh
Created Apr 5, 2011
Launch shotgun, listening to the first IP
View blunderbuss.sh
function blunderbuss {
if [ -z "$1" ]; then
PORT=9393
else
PORT=$1
fi
IP=`ifconfig | grep -m 1 broadcast | awk '{print $2}'`
shotgun -s thin -o $IP -p $PORT
}
@peterhellberg
peterhellberg / fun_with_the_ruby_19_stl.rb
Created Apr 7, 2011
Fun with the Ruby 1.9 Standard Library
View fun_with_the_ruby_19_stl.rb
require 'set'
# Sorted list of random numbers
pp 10.times.each_with_object(SortedSet.new) { |n, s| s << Random.new.rand(1..100) }
# Associative arrays
aoa = ('a'..'l').each_slice(2).to_a
Hash[aoa] #=> {"a"=>"b", "c"=>"d", "e"=>"f", "g"=>"h", "i"=>"j", "k"=>"l"}
@peterhellberg
peterhellberg / button_press.rb
Created Apr 7, 2011
Playing with Lego Mindstorms (NXT 2.0)
View button_press.rb
require 'serialport'
require 'nxt'
# Connect to the Lego NXT
nxt = NXT.new
# Get the touch sensor
ts = TouchSensor.new(nxt)
while true
@peterhellberg
peterhellberg / sass-watch.sh
Created Apr 14, 2011
Converting SCSS to CSS when a new file is saved.
View sass-watch.sh
function sass-watch {
if [ -z "$3" ]; then
SASS_IN='all.scss'
CSS_OUT='all.css'
SASS_WATCH_PATH='.'
else
SASS_IN=$1
CSS_OUT=$2
SASS_WATCH_PATH=$3
fi
@peterhellberg
peterhellberg / first.rb
Created Apr 23, 2011
Test: Multiple files in the same Gist
View first.rb
puts "first file"
@peterhellberg
peterhellberg / reset_fan_speed.sh
Created Dec 13, 2011
Control the fan speed of the Macbook Air
View reset_fan_speed.sh
#!/bin/sh
smc=/Applications/smcFanControl.app/Contents/Resources/smc
min_hex=$(python -c "print hex("2000" << 2)[2:]")
max_hex=$(python -c "print hex("6500" << 2)[2:]")
${smc} -k F0Mn -w ${min_hex}
${smc} -k F0Mx -w ${max_hex}
@peterhellberg
peterhellberg / .rvmc
Created Jan 9, 2012
ArgumentError after include Goliath::TestHelper
View .rvmc
rvm --create use 1.9.3@goliath-wrong-number-of-arguments
@peterhellberg
peterhellberg / Guardfile
Created Jan 12, 2012
External JSON API testing (using minitest/spec, rest-client and yajl-ruby)
View Guardfile
guard 'shell' do
watch(/relation_tree_spec\.rb/) { `clear && ruby relation_tree_spec.rb` }
end
@peterhellberg
peterhellberg / .bash_profile
Created Feb 23, 2012
Small .bash_profile and .vimrc for a brand new server
View .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
You can’t perform that action at this time.