Skip to content

Instantly share code, notes, and snippets.

View audionerd's full-sized avatar

Eric Skogen audionerd

View GitHub Profile
# A demonstration of Ruby mixins, in response to:
# http://www.deftflux.net/blog/post/A-good-design-for-multiple-implementation-inheritance.aspx
module BarkingBehavior
def bark
puts "Bark!"
end
end
module MeowingBehavior
#!/usr/bin/env ruby
#
# autoreload
# reload webkit whenever files in the current directory are modified
#
# requires:
# * RubyCocoa (bundled with Leopard)
# * gem install fsevents (http://github.com/ymendel/fsevents/tree/master)
#
require 'fsevents'
// "Laugh Track" -- an attempt at laugh synthesis
// For SuperCollider 3.2 -- requires FormantTable
(
#f, a, q = FormantTable.get(\altoA);
e = Env(
[ 1.6315789222717, 2.8684210777283, 0, 1.1526317596436, 0, 0.63157892227173, 0, 0, 0.39473664164831, 0.41710549016785, 0, 0.33685091589462, 0.3538348548878, 0, 0.10526323318481, 0 ],
[ 0.099179289557717, 0.029608596454967, 0.070896452123469, 0.015656579624523, 0.045265132730657, 0.08636364069852, 0.027344267630401, 0.021196740851856, 0.025568173912275, 0.020519098486223, 0.029819674626466, 0.025645296259773, 0.057419430367461, 0.18465909090909, 0.16357317837802 ]
);
w = SCWindow("Laugh Editor", Rect(200,200,400,300));
v = SCEnvelopeEdit(w, w.view.bounds.moveBy(20,20).resizeBy(-40,-140), e, 20).resize_(5);
// FormantTable demo in SuperCollider
// boot the server
s.boot;
// Saw freq is controlled by mouse X position
// BBandPass filter is controlled by
// FormantTable data (frequencies, resonances, amplitudes)
(
SynthDef(\formantVoice, { arg
// JSONP.Request for Prototype
// based on: http://github.com/kangax/protolicious/blob/master/get_json.js
JSONP = { count: 0 };
JSONP.Request = Class.create({
initialize: function(url, options) {
this.options = {
timeoutInSeconds: 5,
onSuccess: Prototype.emptyFunction,
onFailure: Prototype.emptyFunction
};
/* via http://www.simonwhatley.co.uk/ */
Twitter = {
format: function(tweet) {
return Twitter.formatHashtag(Twitter.formatUsername(Twitter.formatURL(tweet)));
},
formatURL: function(string) {
return string.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(url) {
return url.link(url);
});
},
require 'mongo'
include Mongo
FIRST = 1
SECOND = 2
THIRD = 3
FOURTH = 4
db = Connection.new('localhost').db('test_safe_updates')
// modularity-in-virtual-analog-synth-design-with-supercollider.rtf
// i'm splitting up a few pieces into inline functions (osc_pitch_from, vco, vcf)
// mainly for legibility and ease of modification
// synthesis is modelled a bit after mda jx10 and juno 106
(
SynthDef(\jx10, {
@audionerd
audionerd / gist:758229
Created December 29, 2010 05:52
jammit – add a failing test to illustrate missing route for "namespaced" javascript
---
test/unit/test_jammit_controller.rb | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/test/unit/test_jammit_controller.rb b/test/unit/test_jammit_controller.rb
index 914c612..25b6a72 100644
--- a/test/unit/test_jammit_controller.rb
+++ b/test/unit/test_jammit_controller.rb
@@ -66,4 +66,19 @@ class JammitControllerTest < ActionController::TestCase
Jammit.reload!
diff --git a/chapter_09/soap/amazon_search_wsdl.rb b/chapter_09/soap/amazon_search_wsdl.rb
index 53af668..a2e0cf7 100644
--- a/chapter_09/soap/amazon_search_wsdl.rb
+++ b/chapter_09/soap/amazon_search_wsdl.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
require 'savon'
require 'hmac'
require 'hmac-sha2'
@@ -9,7 +8,9 @@ class AmazonProductAdvertisingAPI