Skip to content

Instantly share code, notes, and snippets.

# My attempt to recreate the OSCon Keynote "The Concert Programmer"
# by Andrew Sorensen using Sonic-Pi.
use_bpm 120
use_synth :fm
$root = 52
$key = :major
live_loop :metro do
sleep 1
@danreedy
danreedy / gist:a0f0aa1ec2eb275c55a2
Created April 16, 2015 14:39
Frozen - Let it Go - Sonic Pi
# Let it Go - Pi Version
use_bpm 34
use_synth :pretty_bell
quaver = 0.125 #Eight note
crotchet = 0.25 #Quarter note
minim = 0.5 #Half note
semibreve = 1 #Whole note
in_thread(name: :rh) {rightHand}
comment do
# transcribed from the MML notation here: http://www.mmlshare.com/tracks/view/403
#
# Sonic Pi currently has a size limit of about 9k which is a known issue (#102).
# I've kept the comments up here to get around that as comment blocks don't get
# sent to the interpreter. Some of the layout here is an exercise in reducing bytes.
# I'm using Ruby's stabby lambda syntax ( -> { ... } ) in case you want to google it :)
#
# THIS HAS ONLY BEEN TESTED ON A MAC - on an RaspberryPi you might want to change it to
# use_bpm 60
<img id="webcam" src="https://www.webcam-4insiders.com/current/medium/14082-Webcam-Leysin-Wetter.jpg" alt="LAS Gym Construction">
<script type="text/javascript">
var refreshImage = function() {
var refreshInterval = 600000; // This is time in milliseconds; 60,000 = 10 minutes
var source = "https://www.webcam-4insiders.com/current/medium/14082-Webcam-Leysin-Wetter.jpg?time=" + new Date().getTime();
document.getElementById('webcam').src = source;
setTimeout(refreshImage, 600000);
}
refreshImage();
</script>
@danreedy
danreedy / hash_deep_fetch.rb
Last active August 29, 2015 14:13
The code and tests for the "Deep Fetch" by Dan Reedy
#!/usr/bin/env ruby
require 'minitest/autorun'
Hash.class_eval do
def deep_fetch(*keys, default: nil)
keys.reduce(self) do |memo, key|
memo.fetch(key)
end
rescue KeyError
@danreedy
danreedy / gist:6f4c2fdcabc027d35757
Created December 24, 2014 10:49
jingle_bells.rb
#!/usr/bin/env ruby
class JingleBells
def initialize
@jingle_count = 0
end
def can_jingle?
@jingle_count < 2
end
@danreedy
danreedy / OSCon
Created October 3, 2014 14:16
Sketches on an OSCon
use_bpm 120
use_synth :fm
$root = 52
$key = :major
define :metro do
cue :tick
sleep 1
end
@danreedy
danreedy / current_users.rb
Last active March 4, 2016 22:33
Puppet Facter Custom Facts
require 'facter'
Facter.add(:current_users) do
setcode do
output = Facter::Util::Resolution.exec(%q{/usr/bin/w -h | grep console | /usr/bin/awk -F" " '{ print $1 }'})
output.gsub(/\n/,'::').split('::').uniq.join(',') # Convert the individual line output to a comma list w/ unique values
end
end
#!/usr/bin/env python
# Quick and dirty demonstration of CVE-2014-0160 by
# Jared Stafford (jspenguin@jspenguin.org)
# Modified so that it finds cookies
import sys
import struct
import socket
import time
import select
@danreedy
danreedy / keybase.md
Created April 6, 2014 17:42
keybase.md

Keybase proof

I hereby claim:

  • I am danreedy on github.
  • I am reedy (https://keybase.io/reedy) on keybase.
  • I have a public key whose fingerprint is BF04 8002 9242 1D14 869E 0689 7F1F A7D7 22DD 2BA3

To claim this, I am signing this object: