Skip to content

Instantly share code, notes, and snippets.

contra contra

Block or report user

Report or block contra

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@contra
contra / funk.js
Created Jun 19, 2011
get da funk
View funk.js
//
// Create main view
//
A2B.createView = function() {
// create map view
A2B.mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
animate:true,
regionFit:true,
region:{latitude:33.74511, longitude:-84.38993, latitudeDelta:0.5, longitudeDelta:0.5},
@contra
contra / gist:1789699
Created Feb 10, 2012
dox AST transformer
View gist:1789699
//This function initializes the library
exports.initialize = function (wha) {
console.log("initialized " + wha);
};
//This is super complex - watch out for it!
//Serious bro
exports.coolprop = "hi";
//This function kills a process
@contra
contra / rAFshim.coffee
Created Feb 14, 2012 — forked from phated/rAFshim.coffee
window.requestAnimationFrame shim
View rAFshim.coffee
###
http://paulirish.com/2011/requestanimationframe-for-smart-animating/
http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
requestAnimationFrame polyfill by Erik Möller
fixes from Paul Irish and Tino Zijdel
Coffeescript and AMD by Blaine Bublitz
###
View gist:2141373
makeUUID = ->
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace /[xy]/g, (a, b) ->
b = Math.random() * 16
return (if a is "y" then b & 3 | 8 else b | 0).toString 16
@contra
contra / stuff.coffee
Created Apr 24, 2012
Coffeescript override __bind to track function scope
View stuff.coffee
@['__bind'] = (fn, scope) ->
nu = ->
fn.apply scope, arguments
(nu._scope?=[]).push scope
return nu
@contra
contra / stuff.coffee
Created Apr 24, 2012
Asynchronous object map Javascript/node/coffee-script
View stuff.coffee
map = (obj, cb) ->
out = {}
todo = Object.keys(obj).length
check = -> cb out if --todo is 0
for key, val of obj
if typeof val is 'function'
do (key) ->
t = val (res) ->
out[key] = res
@contra
contra / stuff.coffee
Created Apr 24, 2012
Tiny DOMReady javascript/coffee-script
View stuff.coffee
# DOM ready
window.ready ?= (fn) ->
fire = ->
unless window.ready.fired
window.ready.fired = true
fn()
return fire() if document.readyState is "complete"
# Mozilla, Opera, WebKit
@contra
contra / stuff.coffee
Created Apr 24, 2012
Tiny cookie getter/setter javascript/coffee-script
View stuff.coffee
cookie = (name, value) ->
if name and value
document.cookie = "#{name}=#{value};"
return value
else
out = {}
for cookie in document.cookie.split ";"
pair = cookie.split "="
out[pair[0]] = pair[1]
return (if name? then out[name] else out)
@contra
contra / stuff.coffee
Created Apr 24, 2012
Real function throttle javascript/coffee-script
View stuff.coffee
# Most throttles are actually just delays
# This will only call the function if it hasn't been triggered in (delay)ms
throttle = (fn, delay) ->
return fn if delay is 0
timer = false
return ->
return if timer
timer = true
setTimeout (-> timer = false), delay unless delay is -1
fn arguments...
@contra
contra / stuff.coffee
Created Apr 24, 2012
Tiny window.location parser javascript/coffee-script
View stuff.coffee
parseLocation = ->
out = {}
for key in window.location.search.substring(1).split "&"
pair = key.split "="
out[pair[0]] = pair[1]
return out
You can’t perform that action at this time.