Skip to content

Instantly share code, notes, and snippets.

View also's full-sized avatar

Ryan Berdeen also

View GitHub Profile
# ported from http://amix.dk/blog/viewEntry/19367
require 'digest/md5'
class ConsistentHash
def initialize(nodes=nil, replicas=100)
# Manages a hash ring.
# `nodes` is a list of objects that have a proper string representation.
# `replicas` indicates how many virtual points should be used per node,
// Calling Sound.play() after calling SoundChannel.stop() will begin playing
// with an empty buffer.
package {
import flash.display.Sprite;
import flash.events.SampleDataEvent;
import flash.external.ExternalInterface;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.utils.setTimeout;
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Panel title="SoundTouch Demo" width="100%" paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10">
<mx:HBox paddingBottom="10">
<mx:Button id="browseButton" label="Open an MP3…" click="chooseFile();"/>
</mx:HBox>
<mx:VBox width="100%">
<mx:Label text="Tempo"/>
<mx:HSlider id="tempoSlider" minimum="0.01" maximum="1.99" value="1" snapInterval="0.01" liveDragging="false" change="updateFilter();" width="100%"/>
Index: main/src/com/noteflight/standingwave2/output/AudioSampleHandler.as
===================================================================
--- main/src/com/noteflight/standingwave2/output/AudioSampleHandler.as (revision 25)
+++ main/src/com/noteflight/standingwave2/output/AudioSampleHandler.as (working copy)
@@ -115,6 +115,7 @@
var endFrame:Number;
var sample:Sample;
var length:Number;
+ var sampleLength:Number;
<!-- from http://www.p01.org/releases/20_lines_twinkle/ -->
<canvas id="tunnel" width="640" height="480"></canvas>
<script type="text/javascript">
var WIDTH = 640;
var HEIGHT = 480;
var CENTER_X = WIDTH / 2;
var CENTER_Y = HEIGHT / 2;
@also
also / test.sh
Created August 9, 2010 22:14
One file. Valid Ruby, Python, and shell script.
#!/usr/bin/env sh # ruby wants to see its name in the shebang
# valid python, ruby and bash
ignore=""" "
ignore=\
=begin
unset ignore
echo only bash sees this
python $0
<!-- make a synchronous cross-domain request to The Echo Nest API -->
<!DOCTYPE html>
<html>
<head>
<title>Echo Nest API Cross-Domain Example</title>
</head>
<body>
<h1>Echo Nest API Cross-Domain Example</h1>
<p><strong>Results:</strong></p>
import struct
import json
import sys
class RDQ(object):
def __init__(self, f):
self.f = f
self.read = f.read
function Nest(api_key) {
this.api_key = api_key;
}
Nest.prototype = {
analyzeFile: function(file, type, options) {
var form = new FormData();
form.append('api_key', this.api_key);
form.append('track', file);
form.append('filetype', type);
<!DOCTYPE html>
<html>
<head>
<title>Analyze</title>
<script src="nest.js" type="text/javascript"></script>
</head>
<body>
<h1>Analyze</h1>