Skip to content

Instantly share code, notes, and snippets.

View ticking-clock's full-sized avatar

Alan Kendall ticking-clock

View GitHub Profile
@ticking-clock
ticking-clock / player.coffee
Last active November 19, 2015 21:02
OOP in JS, Part 2: Attack of the Frameworks
class Player
constructor: (@health = 10) ->
@attributes =
str: 8, int: 8, wis: 8,
dex: 8, con: 8, cha: 8
damage: (amount) ->
@health += amount
@inSameParty: (p1, p2) ->
/*---------------------------------------------------
LESS Elements 0.9
---------------------------------------------------
A set of useful LESS mixins
More info at: http://lesselements.com
---------------------------------------------------*/
.gradient(@color: #F5F5F5, @start: #EEE, @stop: #FFF) {
background: @color;
background: -webkit-gradient(linear,
@ticking-clock
ticking-clock / IE-classes-latest
Created June 20, 2014 12:05
HTML boilerplate
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
@ticking-clock
ticking-clock / App.coffee
Last active July 25, 2016 21:44
Ember.js classes for client-server web socket communication
'use strict'
@App = Ember.Application.create
LOG_TRANSITIONS: true
ready: ->
console.log "app ready, starting server"
@set 'server', App.EventedServer.create
url: '192.168.1.101:8888/game'
delegateType: App.FixtureWebSocket
@ticking-clock
ticking-clock / guid
Created August 30, 2013 16:34
CoffeeScript UUID (guid) function
# RFC1422-compliant CoffeeScript UUID function.
# Generates a UUID from a random number, which means it is not entirely unique.
# See: http://stackoverflow.com/questions/105034
guid = ->
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace /[xy]/g, (c) ->
r = Math.random() * 16 | 0
v = if c is 'x' then r else (r & 0x3|0x8)
v.toString(16)
@ticking-clock
ticking-clock / CSS media queries
Last active March 1, 2017 15:54
Common media queries with LESS
@media only screen and (max-width: 767px) {
}
@media only screen and (min-width: 768px) {
}
@media only screen and (min-width: 992px) {
}
@media only screen and (min-width: 1200px) {
@ticking-clock
ticking-clock / HTML
Created August 21, 2013 14:44
Simple Ember component example
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
@ticking-clock
ticking-clock / HTML
Created August 21, 2013 14:43
Simple Auth for Ember.js
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
@ticking-clock
ticking-clock / EventDispatcher.js
Created June 11, 2013 06:31
Change to Easeljs/events/EventDispatcher.js to support multiple space-separated event types.
var EventDispatcher = function() {
this.initialize();
};
var p = EventDispatcher.prototype;
EventDispatcher.initialize = function(target) {
target.addEventListener = p.addEventListener;
target.removeEventListener = p.removeEventListener;
target.removeAllEventListeners = p.removeAllEventListeners;
@ticking-clock
ticking-clock / computed-attributes-model.coffee
Created June 9, 2013 23:05
Backbone.Model extension that calculates dependent attributes (computed properties)
class ComputedAttributesModel extends Backbone.Model
initialize: ->
super
return if _.isUndefined(@computed)
for attr, dependencies of @computed
@bind "change:#{attr}", =>
param = {}
param["_#{attr}"] = @[attr].call @
@set(param)