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
var ZERO = new BigInteger("0"); | |
var ONE = new BigInteger("1"); | |
function modInverse(a, b) { | |
// http://en.wikipedia.org/wiki/Modular_multiplicative_inverse#Extended_Euclidean_algorithm | |
// http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Iterative_method_2 | |
var m = b.abs(); | |
var aSign = a.compareTo(ZERO); | |
var x = ZERO; | |
var lastx = ONE; | |
var tmp = null; |
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
<?php | |
/* usage: | |
$db = new Database("mysql:host=" . Config::$dbHost . ";dbname=" . Config::$dbName . ";", Config::$dbName, Config::$dbUser, Config::$dbPass); | |
$db->changeVersion("", "1", function ($tx) { | |
$tx->executeSql("CREATE TABLE IF NOT EXISTS `examples` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`example` mediumtext, | |
PRIMARY KEY (`id`) |
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
setTimeout(function () { | |
var x = new XMLHttpRequest(); | |
var url = "http://www.enhanceie.com/test/stream.aspx?" + Math.random(); | |
x.open("GET", url, true); | |
x.responseType = "ms-stream"; | |
var reader = new MSStreamReader(); | |
reader.onload = function (e) { | |
var s = reader.result; | |
console.log(s); |
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
var cJSON = { | |
parse: function (text) { | |
var lastVisitedIndex = -1; | |
var results = JSON.parse(text); | |
var f = function (index) { | |
var x = results[index]; | |
if (index <= lastVisitedIndex) { | |
return x; | |
} | |
lastVisitedIndex = index; |
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
// TextEncoder/TextDecoder polyfills for utf-8 - an implementation of TextEncoder/TextDecoder APIs | |
// Written in 2013 by Viktor Mukhachev <vic99999@yandex.ru> | |
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. | |
// You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | |
// Some important notes about the polyfill below: | |
// Native TextEncoder/TextDecoder implementation is overwritten | |
// String.prototype.codePointAt polyfill not included, as well as String.fromCodePoint | |
// TextEncoder.prototype.encode returns a regular array instead of Uint8Array | |
// No options (fatal of the TextDecoder constructor and stream of the TextDecoder.prototype.decode method) are supported. |
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
<!DOCTYPE html> | |
<style> | |
.f { | |
width: 105px; | |
} | |
.f > div { | |
overflow-y: scroll; | |
border-left: 1px solid blue; | |
width: 24%; |
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 (global) { | |
"use strict"; | |
// Math.nextUp | |
// Note: | |
// Math.nextDown = function (x) { return -Math.nextUp(-x); }; | |
// Math.nextAfter = function (x, y) { return y < x ? -Math.nextUp(-x) : (y > x ? Math.nextUp(x) : (x !== x ? x : y)); }; | |
// Math.ulp = function (x) { return x < 0 ? Math.nextUp(x) - x : x - (-Math.nextUp(-x)); }; | |
var EPSILON = Math.pow(2, -52); |
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
// https://bugzilla.mozilla.org/show_bug.cgi?id=697151 | |
(function () { | |
var s = []; | |
var url = "https://cors-test.appspot.com/test"; | |
setTimeout(function () { | |
s.push('? - setTimeout'); | |
}, 0); |
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 getStep(min, max, intervals) { | |
var range = max - min; | |
var a = range / (intervals - 1); | |
var b = range / (intervals - 2); | |
// a <= nice < b | |
// -2 -1 0 1 2 3 4 | |
// 10^-1; 10^0 / 2; 10^0; 10^1 / 2; 10^1; 10^2 / 2; 10^3; ... | |
function f(i) { |
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 () { | |
"use strict"; | |
var base = 1e7; | |
var size = 6; | |
var data = []; | |
var i = -1; | |
while (++i < size) { | |
data[i] = 0; | |
} |