This file contains hidden or 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
this.arrayInsert = function (array, index, other) { | |
for (var i = 0; i < other.length; ++i) { | |
array.splice(i + index, 0, other[i]) | |
} | |
return array | |
}; | |
this.createStyleSheet = function (doc, url) { | |
var style = this.createElement("link"); | |
style.setAttribute("charset", "utf-8"); | |
style.setAttribute("rel", "stylesheet"); |
This file contains hidden or 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
var i, arr = [1, 2, 3, 4, 5, 6, 7, 8]; | |
for(i = 0; i < arr.length / 2; i++) { | |
var temp = arr[i]; | |
arr[i] = arr[arr.length - i - 1] | |
arr[arr.length - i - 1] = tmp | |
} | |
/* | |
passes: |
This file contains hidden or 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
'use strict' | |
$ = require('jquery') | |
Backbone = require('backbone') | |
Backbone.$ = $ | |
Marionette = require('backbone.marionette') | |
View = require('./view') | |
$ -> |
This file contains hidden or 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
## | |
# create an insanely tiny placeholder gif | |
# output in base64 | |
# | |
# i'm still working the bytes... so this is | |
# a working proto but it needs to be further | |
# edited... | |
# | |
# as much as possible in accordance to GIF spec. | |
class Dick |
This file contains hidden or 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
@MM.module 'KonamiApp', (KonamiApp, App, Backbone, Marionette, $, _) -> | |
# up, up, down, down, left, right, left, right, a, enter | |
KonamiApp.sequence = [38, 38, 40, 40, 37, 39, 37, 39, 65, 13] | |
KonamiApp.pressed = [] | |
KonamiApp.on | |
'start': -> | |
$(window).on 'keyup.konami', KonamiApp.pressedKey | |
'stop': -> | |
$(window).off '.konami' |
This file contains hidden or 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
# determine if the supplied array is filled with only | |
# numbers. | |
# | |
# App.Util.isArrayNumbers([1,2,3,4,5,6]) | |
# > true | |
# App.Util.isArrayNumbers([1, 2, 3, 4, 5, 6, 'a']) | |
# > false | |
# | |
Util.isArrayNumbers = (arr) -> | |
_.uniq(_.map arr, (num) -> |
This file contains hidden or 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
# reduce an array of numbers and return | |
# the sum | |
Util.reduceAddArray = (arr) -> | |
return unless Util.isArrayNumbers(arr) | |
_.reduce arr, (a, b) -> | |
a + b |
This file contains hidden or 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
Util.isElementInViewport = (el) -> | |
el = el[0] if el instanceof jQuery | |
return unless el? | |
rect = el.getBoundingClientRect() | |
rect.top >= 0 and | |
rect.left >= 0 and | |
rect.bottom <= (window.innerHeight or document.documentElement.clientHeight) and | |
rect.right <= (window.innerWidth or document.documentElement.clientWidth) |
This file contains hidden or 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
Util.isElementInViewOf = (el, parent) -> | |
el = el[0] if el instanceof jQuery | |
parent = parent[0] if parent instanceof jQuery | |
return unless el? and parent? | |
rect = el.getBoundingClientRect() | |
rect.top >= 0 and | |
rect.left >= 0 and | |
rect.bottom <= parent.clientHeight and |
This file contains hidden or 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
# absolute document height | |
Util.getDocumentHeight = -> | |
Math.max document.body.scrollHeight or 0, | |
document.documentElement.scrollHeight or 0, | |
document.body.offsetHeight or 0, | |
document.documentElement.offsetHeight or 0, | |
document.body.clientHeight or 0, | |
document.documentElement.clientHeight or 0 |