Skip to content

Instantly share code, notes, and snippets.

View darkoverlordofdata's full-sized avatar

Bruce Davidson darkoverlordofdata

View GitHub Profile
@darkoverlordofdata
darkoverlordofdata / getter.coffee
Last active December 11, 2015 23:29
Subclassing getters and setters in coffee-script
Function::get = ($def) ->
$name = Object.keys($def)[0]
Object.defineProperty @::, $name, {get: $def[$name], configurable: yes}
@darkoverlordofdata
darkoverlordofdata / callable.coffee
Created February 17, 2013 18:43
Create callable object class
class Counter
constructor: (max) ->
count = 0
counter = () ->
if (count < counter.max) then return ++count
else return count = 1
counter.max = Math.abs(parseInt(max)) || 1
#
# Object.addSuper
#
# @see Object.getPrototypeOf
#
__addSuper = (object, prototype) ->
# wrap primitive values
object = (if object instanceof Object then object else new object.constructor(object))
@darkoverlordofdata
darkoverlordofdata / Ast.coffee
Last active December 20, 2015 05:39
Jison with CoffeeScript AST
#
# @see http://epaperpress.com/lexandyacc/calc1.html
#
#
# Var table
#
_var = {}
#
# Private Base Class
@darkoverlordofdata
darkoverlordofdata / magic.coffee
Last active December 27, 2015 20:09
Coffeescript Magic
#
# Magic
#
# Dependency injection via prototype.
#
#
# Get all methods and properties in the prototype chain
#
metadata = (klass) ->
@darkoverlordofdata
darkoverlordofdata / liquid.coffee
Last active December 30, 2015 13:39
Liquid.js wrapper for use in Node.js
#
# Liquid.js wrapper
#
# Copy your Liquid.js distro file to the same folder
#
#
fs = require('fs')
path = require('path')
LIQUID_JS = './liquid.js' # path to the Liquid.js distribution
@darkoverlordofdata
darkoverlordofdata / jQuery-plugin.coffee
Last active December 31, 2015 05:18
jQuery plugin
#
# do syntax was made for jQuery...
#
do ($ = jQuery, window, document) ->
_defaults =
color: "#556b2f"
backgroundColor: "white"
#
@darkoverlordofdata
darkoverlordofdata / config.yml
Last active December 31, 2015 07:49
Ya Sure, You Betcha - It's a Sortin' Huginn Pluginn
...
sort:
src: posts
by: date
direction: asc
dest: posts_asc
class Game extends Phaser.Game
constructor: ->
super 800, 600, Phaser.AUTO
@state.add 'Stage', Stage, false
@state.start 'Stage'
class Stage extends Phaser.State
@darkoverlordofdata
darkoverlordofdata / liquid.coffee
Created January 8, 2014 05:14
port of liquid.js to coffee
###
Copyright (c) 2005, 2006 Tobias Luetke,
JavaScript port by M@ McCray (http://www.mattmccray.com)
Requires Prototype 1.6+
http://github.com/darthapo/liquid.js/wikis
Coffeescript port of liquid.js