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
shell = Components.classes["@mozilla.org/browser/shell-service;1"] | |
.getService(Components.interfaces.nsIShellService); | |
var ios = Components.classes["@mozilla.org/network/io-service;1"] | |
.getService(Components.interfaces.nsIIOService); | |
var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] | |
.getService(Components.interfaces.nsIScriptSecurityManager); | |
var dsm = Components.classes["@mozilla.org/dom/storagemanager;1"] | |
.getService(Components.interfaces.nsIDOMStorageManager); | |
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
function truncate(str, maxlength) { | |
return (str.length > maxlength) ? str.slice(0, maxlength - 1) + '…' : str; | |
} | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
function getRandomKey(arr) { | |
return arr[getRandomInt(0, arr.length - 1)]; |
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
// Usage | |
var workerFibo = createPromiseWorker(function(x){ | |
return (function fibo(n){ | |
if (n > 1) { | |
return fibo(n - 1) + fibo(n - 2); | |
} else { | |
return 1; | |
} | |
})(x) | |
}); |
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
_appsHash = {} | |
_appsArr = [] | |
getAll = -> _appsArr | |
getAppById = (appId) -> _appsHash[appId] | |
_fetch = (apps) -> | |
appsHash = {} | |
_appsArr = apps.map (item) -> | |
appsHash[item.id] = _appsHash[item.id] or assign({}, item) |
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
category = [ | |
{id: "animals", parent: null} | |
{id: "mammals", parent: "animals"} | |
{id: "cats", parent: "mammals"} | |
{id: "dogs", parent: "mammals"} | |
{id: "alliance", parent: null} | |
{id: "labrador", parent: "dogs"} | |
{id: "chihuahua", parent: "dogs"} | |
{id: "siamese", parent: "cats"} | |
{id: "persian", parent: "cats"} |
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 initialFirst = 0; | |
var initialLast = 1; | |
var index = 0; | |
var calcFib = function selfCall (num) { | |
if (num < 1) return; | |
index++; | |
var result = initialFirst + initialLast; | |
initialFirst = initialLast; | |
initialLast = result; |
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
// https://stackoverflow.com/questions/9260501/html5-video-background-on-ipad-iphone | |
var cvpHandlers = { | |
canvasClickHandler: null, | |
videoTimeUpdateHandler: null, | |
videoCanPlayHandler: null, | |
windowResizeHandler: null | |
}; | |
var CanvasVideoPlayer = function(options) { |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<title>Site Title</title> | |
<link rel="stylesheet" href="/assets/css/style.min.css"> |
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 OnScroll = (function () { | |
function OnScroll(config) { | |
if (!config) { | |
config = {} | |
} | |
this.listeners = []; | |
this.timeout = config.timeout || 300; | |
var handler = _scrollHandler.bind(this); | |
if (window.addEventListener) { |
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
/** | |
* @example for (let {key, val} of listeners) { console.log("2", key, val); } | |
*/ | |
const listeners = {}; | |
listeners[Symbol.iterator] = function () { | |
const keys = Object.keys(this); | |
const self = this; | |
var current = 0; | |
var last = keys.length; |
OlderNewer