Skip to content

Instantly share code, notes, and snippets.

View AlexJWayne's full-sized avatar
🌈

Alex Wayne AlexJWayne

🌈
View GitHub Profile
loadSpecs = (paths...) ->
# expand all spec paths to full cache busted file paths
paths = for path in paths
"spec/#{path}_spec.js?#{new Date().getTime()}"
# Load the specs with head.js, and start a spec run 1 second after they load.
head.js paths..., ->
setTimeout ->
jasmine.getEnv().addReporter(new jasmine.TrivialReporter())
jasmine.getEnv().execute()
var Package;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
Package = {};
var Bar, Foo, bar;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
Foo = (function() {
Function::include = (otherClass) ->
for name, method of otherClass::
this::[name] = method
return
class Bar
b: -> console.log 'b'
class Foo
@include Bar
@AlexJWayne
AlexJWayne / accurate_interval.coffee
Created December 4, 2011 20:30
accurateInterval() is a dop in replacement for setInterval() that does not drift over long periods of time.
# Accurate Interval, guaranteed not to drift!
# (Though each call can still be a few milliseconds late)
window.accurateInterval = (time, fn) ->
# This value is the next time the the timer should fire.
nextAt = new Date().getTime() + time
# Hold a reference to the timer ID so it can be canceled.
timeout = null
class @A
my_function: => alert 'my function!'
A_Function_Alias: @::my_function
usage_of_alias: =>
@A_Function_Alias()
# some other code...
$ brew doctor
Warning: gettext was detected in your PREFIX.
The gettext provided by Homebrew is "keg-only", meaning it does not
get linked into your PREFIX by default.
If you `brew link gettext` then a large number of brews that don't
otherwise have a `depends_on 'gettext'` will pick up gettext anyway
during the `./configure` step.
->{a = 123} == ->{b = 123} #=> true
a = :a
b = :b
->{a = 123} == ->{b = 123} #=> false
@AlexJWayne
AlexJWayne / echnest-analyze.json
Last active December 12, 2015 02:28
Sample output of Echonest Analyze API.
{
"beats": [
{
"start": 0.06643,
"duration": 0.467,
"confidence": 0.83
},
{ "more": "beat data..." }
],
@AlexJWayne
AlexJWayne / main.coffee
Last active December 12, 2015 02:28
Example of a very simple Echotron layer
# The Constructor/Class that is your layer needs
# to be assigned to module.exports in node.js style.
module.exports = class Example extends Echotron.Echo
# Setup up the layer. Called for you when the
# layer is created.
initialize: ->
# Make a mesh that is a simple cube.
@mesh = new THREE.Mesh(