Skip to content

Instantly share code, notes, and snippets.

View chrp's full-sized avatar
💥
Mostly harmless

Christoph Peschel chrp

💥
Mostly harmless
View GitHub Profile
@chrp
chrp / fanny.rb
Created August 12, 2013 15:21
Auto adjust fan speed of graphics card with ATI catalyst driver on Ubuntu.
#!/usr/bin/env ruby
# encoding: utf-8
# first part, get temperature
temp_str = `aticonfig --adapter=0 --od-gettemperature`
temp = temp_str.scan(/Sensor 0: Temperature - (\d+\.\d+) C/)[0][0].to_i
# determine fan speed
thresholds = [ 40, 60, 70, 80, 85 ]
speeds = [ 10, 25, 30, 35, 50 ]
@chrp
chrp / looping-and-manipulating.rb
Created October 28, 2013 10:09
An example of how to manipulate (insert, delete) an array whilst iterating over it.
a = [1,2,3,4,5,6]
i = -1
while current = a[i+=1] do
prev_one = i==0 ? nil : a[i-1]
next_one = a[i+1]
#insert before without iterating over it
if current == 3 then
@chrp
chrp / ifwatch
Created June 12, 2015 20:43
Wraps the output of ```netstat -I en0 -b``` to keep an eye on your bandwith use.
#!/usr/bin/env ruby
#ln -s $PWD/ifwatch /usr/local/bin/
LIMITS = {
red: 30*1024**2,
yellow: 20*1024**2,
green: 0
}
@chrp
chrp / rspec_callbacks.rb
Created July 13, 2015 12:27
tiny demo to show when each callback kicks in around a rspec test
describe 'describe 1' do
before(:all) do
puts '1: before all'
end
before(:each) do
puts '1: before each'
end
after(:each) do