A quick scripts to support basic unit conversion in coffeescript and javascript. All you have to do is put one way conversion from one unit to another (for example: s
to ms
is 1000) and Unit.coffee handles bridging units (like converting ms
to m
) and going backwards in units. It does not yet support more complex conversions but this can be added by allowing a function to be set as the conversion factor (passing it a number, and whether it's forwards or reverse)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Notes: | |
* Methods that modify the progress of the achievement have a notify option. | |
This option tells whether or not the user should be notified about the | |
achievement by the native UI (some sort of popup in the corner and maybe | |
a sound) | |
* The plan for this API is to perform network IO asynchrnously in the | |
background while using data cached by the Pine library to make the | |
API feel synchronous. Essentially, the progress of each achievement | |
will be loaded when the game is loaded and will be used for any | |
get operations with this API. An async request is put out when an |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($){ | |
var _is = $.fn.is, _filter = $.fn.filter; | |
function visible(elem){ | |
elem = $(elem); | |
return !!(elem.width() || elem.height()) && elem.css("display") !== "none"; | |
} | |
$.fn.is = function(sel){ | |
if(sel === ":visible"){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~function(){var a=function(b,c){var d=a.resolve(b,c||"/"),e=a.modules[d];if(!e)throw new Error("Failed to resolve module "+b+", tried "+d);var f=e._cached?e._cached:e();return f};a.paths=[],a.modules={},a.extensions=[".js",".coffee"],a._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},a.resolve=function(){return function(b,c){function h(b){if(a.modules[b])return b;for(var c=0;c<a.extensions.length;c++){var d=a.extensions[c];if(a.modules[b+d])return b+d}}function i(b){b=b.replace(/\/+$/,"");var c=b+"/package.json";if(a.modules[c]){var e=a.modules[c](),f=e.browserify;if(typeof f=="object"&&f.main){var g=h(d.resolve(b,f.main));if(g)return g}else if(typeof f=="string"){var g=h(d.resolve(b,f));if(g)return g}else if(e.main){var g=h(d.resolve(b,e.main));if(g)return g}}return h(b+"/index")}function j(a,b){var c=k(b);for(var d=0;d<c.length;d++){var e=c[d],f=h(e+"/"+a);if(f)return f;var g=i(e+"/"+a);if(g)return g}var f=h(a);if(f)return f}function k(a){var b;a==="/"?b=[""]:b=d.normalize(a).split("/");var c=[];for(var e=b. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.store = function(stay){ | |
stay = require("./node-stay").store(stay); | |
var type = function(a){ | |
var t = typeof a; | |
return t === 'object' ? {}.toString.call(a).slice(8, -1).toLowerCase() : t; | |
}, | |
get = stay.get, set = stay.set, del = stay.del, exists = stay.exists | |
, it = {object:1, array:1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function btoa( | |
a, //String to encode | |
b, //Array of Base64 characters | |
c,d,e,f,g,x //Placeholder | |
){ | |
for(d=a.length, //Set d to the input's length | |
e="charCodeAt", //Shortcut for String.charCodeAt | |
f=-[,2,1][d%3], //Get how many equal signs need to be added to the end | |
x=0; //Initiate iteration variable | |
x<d; //Continue loop until x exceeds the length of the input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is(a,b,c,d){ | |
b=(!(c=(d=b.split(".")).shift().split("#"))[0]||a.nodeName==c[0].toUpperCase())&& | |
(!c[1]||a.id==c[1]) | |
for(c=d.length;b=b&&~(' '+a.className+' ').indexOf(' '+d[--c]+' ');); | |
return b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse=(function(document,r_start,r_attr,r_end,cache){ | |
return function(str){ | |
//If there is already a cached element, return its clone | |
if(cache[str]) return cache[str].cloneNode(true) | |
//frag and par are originally the same. par is the current parent and frag is the document fragment being returned | |
var frag,par=frag=document.createDocumentFragment(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D=(function(){ | |
function trigger(arr,con,args){ | |
for(var x=0;x<arr.length;x++) arr[x].apply(con||null,args||[]); | |
} | |
function d(fn){ | |
var w=[], | |
f=[], |
NewerOlder