This file contains 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
# Didn't realize this but Brian Adkins wrote a ruby version as well, code is almost identical to my own. | |
def words text | |
text.downcase.scan(/[a-z]+/) | |
end | |
def train features | |
model = Hash.new(1) | |
features.each {|f| model[f] += 1 } | |
return model |
This file contains 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
@variables = Object.new | |
def @variables.metaclass | |
class << self; self; end | |
end | |
def @variables.meta_eval &block | |
metaclass.instance_eval &block | |
end |
This file contains 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
# 1 dimensional list comprehension | |
module Kernel | |
def list &block | |
Comprehension::List.new &block | |
end | |
end | |
module Comprehension | |
class List |
This file contains 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
# N-Dimensional list comprehension | |
module Kernel | |
def list &block | |
Comprehension::List.new &block | |
end | |
end | |
module Comprehension | |
class List |
This file contains 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
# better list comprehension by Corban Brook | |
module Kernel | |
def list █ Comprehension::List.new █ end | |
end | |
module Comprehension | |
Dimension = Struct.new(:for, :in, :if) | |
class Context; end |
This file contains 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
var path = ""; | |
var activeSubworkers = 0; | |
if ( typeof(options.workerpath) == 'string' || options.workerpath instanceof String ) { | |
path = options.workerpath; | |
} | |
var worker = new Worker(path + "metaworker.js"); | |
worker.onmessage = function(event) { |
This file contains 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
# is a discrete fourier transform in ruby by corban http://en.wikipedia.org/wiki/Discrete_Fourier_transform | |
require 'complex' | |
TWO_PI = 2 * Math::PI | |
N = ARGV.first.to_i || 256 | |
x = Array.new(N, rand) | |
X = Array.new(N, 0) |
This file contains 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
zetagun:~ corban$ ruby DFT.rb 200 square 1720Hz | |
user system total real | |
DFT: 0.050000 0.000000 0.050000 ( 0.055424) | |
[DFT] 1720Hz squarewave / 44100.0Hz samplerate / 200 sample timesize | |
. - 0.6 | |
. | |
. - 0.5 | |
. | |
. - 0.4 |
This file contains 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
zetagun:~ corban$ ruby FFT.rb 128 square 1720Hz | |
user system total real | |
FFT: 0.020000 0.000000 0.020000 ( 0.022661) | |
64 | |
[FFT] 1720Hz squarewave / 44100.0Hz samplerate / 128 sample timesize | |
. - 41.9 | |
. | |
. - 33.5 | |
. |
This file contains 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
<html> | |
<head> | |
<script language="javascript" src="processing.min.js"></script> | |
<script language="javascript" src="init.js"></script> | |
</head> | |
<body> | |
<script type="application/processing" target="demo"> | |
// Global variables | |
float radius = 50.0; |
OlderNewer