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
require('traceur').require.makeDefault(function(filename){ | |
return filename.endsWith('traceur.js'); | |
}); | |
module.exports = require('./index.traceur.js'); |
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 lcs(x, y) { | |
var symbols = {}, | |
r = 0, p = 0, p1, L = 0, idx, | |
m = x.length, n = y.length, | |
S = new Array(m < n ? n : m); | |
p1 = popsym(0); | |
for (i = 0; i < m; i++) { | |
p = (r === p) ? p1 : popsym(i); | |
p1 = popsym(i + 1); | |
idx = (p > p1) ? (i++, p1) : p; |
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
'send': function (data) { | |
var virtualDOMTree = document.createElement('html'); | |
virtualDOMTree.innerHTML = data; | |
['head', 'body'].forEach(function (tagName) { | |
var virtualRoot = virtualDOMTree.querySelector(tagName), | |
realRoot = document.querySelector(tagName); | |
if (!realRoot) { | |
document.documentElement.appendChild(realRoot = document.createElement(tagName)); | |
} | |
var diff = LCSdiff(realRoot.childNodes, virtualRoot.childNodes); |
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
/** | |
* As close as possible transfer of https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overview_of_the_code | |
*/ | |
const dataView = new DataView(new ArrayBuffer(8)); | |
const intVars = new Int32Array(4); | |
const floatVars = new Float32Array(4); | |
const intConsts = new Int32Array(1); | |
const floatConsts = new Float32Array(2); |
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
import {Server} from 'http'; | |
const server = new Server(); | |
server.listen(8080); | |
server.on('request', async function (req, res) { | |
req.pause(); | |
res.statusCode = 200; | |
req.on('end', () => res.end('OK')); | |
const length = message.headers['content-length']; |
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 createRestFactory(name, path, r){ | |
rest.factory(name, function($resource, $cacheFactory){ | |
var c=$cacheFactory(name); | |
var res = $resource(path, {}, r); | |
return (function(resource, routes, cache) { | |
var o={}; | |
angular.forEach(routes, function(value, key) { | |
o[key]=(function(r) { | |
var request=r; | |
return function(attrs) { |
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 link_processor = function () { | |
var link_selector = 'a[href^="/"], a[href^="' + document.location.origin + '"]'; | |
$('body').on('click', link_selector, function () { | |
var target, all_of_type, target_path; | |
target = $(this); | |
if (target.attr('href')) { | |
target_path = target.attr('href').replace(document.location.origin, ''); | |
var chunks = target_path.split('.'); | |
if ((chunks.length == 1) || (chunks.length > 1 && (chunks[chunks.length - 1] == "htm") && (chunks[chunks.length - 1] == "html"))) { |
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
CacheFactory = (function () { | |
function compareThings() { | |
var names = [ | |
arguments[0]["name"].toLowerCase(), | |
arguments[1]["name"].toLowerCase() | |
]; | |
if (names[0] < names[1]) { | |
return -1; | |
} | |
if (names[0] > names[1]) { |
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 brightnessProperty = { | |
get: function () { | |
var canvas = document.createElement('canvas'); | |
canvas.width = 1; | |
canvas.height = 1; | |
var context = canvas.getContext('2d'); | |
context.drawImage(this, 0, 0, 1, 1); | |
var data = context.getImageData(0, 0, 1, 1).data; | |
return Math.floor((data[0] + data[1] + data[2]) / 3) | |
}, |
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 (rarDetected) { | |
function detectRar(blob, callback) { | |
var reader = new FileReader; | |
reader.readAsBinaryString(blob); | |
reader.onload = function () { | |
callback(reader.result.indexOf('Rar!') != -1) | |
} | |
} | |
function getBlob(url, callback) { |
OlderNewer