This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'webrick' | |
require 'webrick/httpproxy' | |
callback = proc do |request, response| | |
if response.content_type =~ /jpe?g|png|gif/ | |
f = Tempfile.new("upside-down") | |
f.write(response.body) | |
f.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'webrick' | |
require 'webrick/httpproxy' | |
callback = proc do |request, response| | |
if response.content_type =~ /jpe?g|png|gif/ | |
f = Tempfile.new("upside-down") | |
f.write response.body | |
f.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2010 07 09 10:30 | |
Galois Tech Talk: Requirements and Performance of Data Intensive, Irregular Applications | |
Iavor S. Diatchki | |
Pacific NW National Laboratory | |
Analytics | |
Security | |
Anomaly detection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bandlimited interpolation simulation, as described by Eq 1 of | |
# https://ccrma.stanford.edu/~jos/resample/Theory_Ideal_Bandlimited_Interpolation.html | |
Fs = 44100.0 # sampling rate | |
Ts = 2.26757369614512e-05 # sampling interval (1/Fs) | |
def interp(samps, t) | |
(0...samps.size).inject(0) { |sum, n| | |
sum + samps[n] * hs(t - n * Ts) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def times_for_period(date) | |
days = work_days_for_period(date) | |
regular_hours_by_week = Hash.new(0) | |
out = { :regular_hours => 0, :other_hours => Hash.new(0) } | |
days.inject(out) { |results, day| | |
times = day.times | |
{ :regular_hours => results[:regular_hours] + times[:regular_hours] | |
:other_hours => results[:other_hours].merge(times[:other_hours]) { |_,a,b| a+b }} | |
}.merge(:weekly_hours => regular_hours_by_week.values_at(*regular_hours_by_week.keys.sort)) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Additive | |
attr :value | |
def initialize(value) | |
@value = value | |
end | |
def mappend(m) Additive.new(@value + m.value) end | |
end | |
class Multiplicative | |
attr :value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Val < Struct.new(:val) | |
def fold(rules) | |
rules[self.class].(val) | |
end | |
end | |
class Var < Struct.new(:lbl) | |
def fold(rules) | |
rules[self.class].(lbl) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'audio_toolbox' | |
include AudioToolbox | |
player = MusicPlayer.new | |
sequence = MusicSequence.new | |
player.sequence = sequence | |
sequence.midi_endpoint = CoreMIDI.get_destination(ARGV.shift.to_i) | |
tempo = sequence.tracks.tempo | |
tempo.add 0.0, ExtendedTempoEvent.new(:bpm => 120.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'audio_toolbox' | |
class DrumMachine | |
include AudioToolbox | |
def initialize | |
@player = MusicPlayer.new | |
@sequence = MusicSequence.new | |
@track = MusicTrack.new(@sequence) | |
@track.add 0.0, MIDIProgramChangeMessage.new(:channel => 10, :program => 26) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ % sudo gem1.9 install ffi | |
Password: | |
Building native extensions. This could take a while... | |
ERROR: Error installing ffi: | |
ERROR: Failed to build gem native extension. | |
/usr/local/bin/ruby1.9 extconf.rb install ffi | |
checking for ffi_closure_alloc() in -lffi... no | |
creating Makefile | |
creating extconf.h |