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 isMobile = { | |
tests:[ | |
function() { | |
return navigator.userAgent.match(/Android/i); | |
}, | |
function() { | |
return navigator.userAgent.match(/BlackBerry/i); | |
}, | |
function() { | |
return navigator.userAgent.match(/iPhone|iPad|iPod/i); |
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
AJAXRequest: function(url, action){ | |
/* ---------------------- | |
Small AJAX Library | |
------------------------- */ | |
xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function(){ | |
// check if the request is ready and the status is ok | |
if (xhr.readyState === 4 && xhr.status === 200){ |
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 slots = [], num = 1000; for(var i = 0; i < num; i++) setTimeout(function(s, d, done){ slots[s] = Date.now() - d; done(); }, 1000, i, Date.now(), function(){ if(!--num) { console.log("Mean:", slots.reduce(function(p, c, i) { var d = c - p; return p + d / i; })); } }); |
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(global){ | |
var exeQueue = []; | |
exeQueue.insertOrdered = function(val) { | |
var l = this.length, | |
order = val.order; | |
while(l--) { | |
if(this[l].order > order) break; | |
} |
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
// Wisp: | |
(fn sum | |
"Return the sum of all arguments" | |
{:version "1.0"} | |
([] 0) | |
([x] x) | |
([x y] (+ x y)) | |
([x & more] (more.reduce (fn [x y] (+ x y)) 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
// ==UserScript== | |
// @name Tatoeba Flexible Linker | |
// @namespace http://userscripts.org/users/515236 | |
// @description Inserts a box below a Tatoeba sentence that the user can fill with the number or URL of a sentence, as well as buttons that allow the user to visit the new sentence or link it to the first one. Extends Zifre's "Tatoeba Linker" script. | |
// @author AlanF_US | |
// @include http://tatoeba.org/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js | |
// @version 1.0 | |
// ==/UserScript== | |
// NOTE: All functions used in the script must be added to the line below |
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 width = null; | |
var height = null; | |
window.onload = function () { | |
var windowSize = getSize(); | |
width = windowSize['width']; | |
height = windowSize['height']; | |
window.onscroll = function(){ alert("Hello"); } | |
}; |
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
> jm???in | |
Here's what I found: | |
[ 'jamming' ] | |
> |
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
// current scope is global.. | |
function Test(n) { | |
this.test = n; | |
var bob = function (n) { | |
this.test = n; | |
}; | |
this.fn = function (n) { |
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 deepCopy = (function () { | |
var funcBlacklist = ['caller', 'arguments', 'prototype' ], | |
primitiveCloner = makeCloner(clonePrimitive), | |
cloneFunctions = { | |
'[object Null]': primitiveCloner, | |
'[object Undefined]': primitiveCloner, | |
'[object Number]': primitiveCloner, | |
'[object String]': primitiveCloner, | |
'[object Boolean]': primitiveCloner, | |
'[object RegExp]': makeCloner(cloneRegExp), |