Skip to content

Instantly share code, notes, and snippets.

function install_clock() {
var clock = document.createElement("canvas");
clock.width = 250;
clock.height = 250;
$("#results > div.time > div.clock > div").append(clock);
if (!Modernizr.canvas) G_vmlCanvasManager.initElement(clock);
var ctx = clock.getContext("2d");
var radius = 78;
var center_x = clock.width / 2;
var center_y = clock.height / 2;
@danscotton
danscotton / TimerSpec.coffee
Created January 10, 2012 16:36
Jasmine specs for new game timer.
describe "Timer", ->
beforeEach ->
@timer = new Timer()
describe "a new instance", ->
it "should return 0 for getTotalSeconds()", ->
(expect @timer.getTotalSeconds()).toEqual(0)
@danscotton
danscotton / gist:1817316
Created February 13, 2012 14:36
weather module
<div class="module-weather">
<div class="timeslot timeslot-main">
<a href="/weather">
<span class="forecast">Sunny</span>
<h3>Shrewsbury</h3>
<span class="temperature">11<abbr title="Degrees celsius">&deg;C</abbr></span>
<strong class="time">Now</strong>
</a>
</div>
<div class="timeslot timeslot-sub">
var bootstrap = {
pubsub: pubsub,
$: function(selector) {
return bonzo(qwery(selector));
},
bind: function(el, event, fn) {
el[0].addEventListener(event, fn, false);
}
};
// ---------------------------------------
// BLQ
// ---------------------------------------
#blq-container {
background: @site-background;
// imports
.i(@device);
}
// ---------------------------------------
// BLQ
// ---------------------------------------
#blq-container {
background: @site-background;
compact({
background: red;
});
tablet(
// ---------------------------------------
// BLQ
// ---------------------------------------
#blq-container {
background: @site-background;
// ---------------------------------------
// IMPORTS
// ---------------------------------------
// ---------------------------------------
// BLQ
// ---------------------------------------
#blq-container {
background: @site-background;
core {
// core
}
compact {
@danscotton
danscotton / gist:2853184
Created June 1, 2012 16:00
Config singleton
define(function() {
// Config object
var Config = function( initialSettings ) {
var store = (initialSettings && typeof initialSettings === 'object') ? initialSettings : {};
return {
get: function( key ) {
if(key) return store[key];
return store;
// device.config.js
define(['module/config/config'], function( config ) {
// some logic up somewhere
var device;
switch(true) {
case (screen.width > 1200): device = 'wide'; break;
case (screen.width > 640): device = 'tablet'; break;
...
}