Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
@mattmccray
mattmccray / backbone_helper.coffee
Created October 14, 2010 08:44
Use Backbone.js classes as native CoffeeScript classes
# Backbone CoffeeScript Helpers by M@ McCray.
# Source: http://gist.github.com/625893
#
# Use Backbone classes as native CoffeeScript classes:
#
# class TaskController extends Events
#
# class TaskView extends View
# tagName: 'li'
# @SRC: '<div class="icon">!</div><div class="name"><%= name %></div>'
@mattmccray
mattmccray / Cakefile
Created October 20, 2010 19:42
CoffeeScript and LESS build tool
#
# Web App Bundler Util v1.2
# by M@ McCray
# url http://gist.github.com/637154
#
# I built this for how I like to work, so YMMV.
#
# This script defines one task: 'build'. It will assemble multiple .coffee (or .less)
# files and compile them into a single .js (or .css) file. There are two main ways
# you can use it. Define the target and list all the source files to assemble into
@mattmccray
mattmccray / render.js
Created November 1, 2010 19:44
Based on ICanHaz, this supports both Mustache.js and Handlebars.js
// Based on ICanHaz (http://github.com/andyet/ICanHaz.js/blob/master/ICanHaz.js)
// This version supports Mustache and Handlebars
// By M@ McCray
;var render = (function($, engine){
var cache = {},
methods = {};
$(function(){
$('script[type="text/html"]').each(function () {
var name = $(this).attr('id'),
@mattmccray
mattmccray / Readme.md
Created August 5, 2012 06:47
DI Experiment
@mattmccray
mattmccray / class_example.js
Created September 11, 2012 01:48
My ES6 class definition proposal
// How about another ES6 class definition proposal? :-)
// What if the the `class` block is a closure?
class Monster extends Sprite {
// This is a block/closure so this creates a local/private variable:
let hitpoints= null;
constructor(name, health=0){
this.name = name;
body
div.page
div.title page one
div.content
p A couple of lines here
p Are always fun, right?
div.page
div.title page two
div.content
p A couple of lines here
body
div.stack
div#one.view
p View One
button.next Next
div#two.view
p View Two
button.back Back
body
div.stack
div.view
p View One
button.next Next
div.view
p View Two
button.back Back
@mattmccray
mattmccray / Makefile
Created October 19, 2012 04:15
Simple comparison of several compile-to-javascript languages, including: CoffeeScript, Dart, Haxe, and TypeScript.
.PHONY: compile
time=/usr/bin/time
compile: dart typescript coffeescript haxe jsx
dart:
$(time) dart2js -ooutput/dart.js source/simple.dart
typescript:
@mattmccray
mattmccray / Q.hx
Created November 17, 2012 04:15
Stupid Haxe Tricks
package j;
import jQuery.JQuery;
// Usage:
// j.Q.uery('div');
class Q {
public static inline function uery(selector:Dynamic, ?context:Dynamic): JQuery {