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
/** | |
* First loop will run few hundred times slower | |
*/ | |
var i, limit = 100000; | |
var time = +new Date; | |
for (i = 0; true; ++i) { | |
if (i > limit) { |
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> | |
<title>Gecko 450418 bug</title> | |
<style> | |
* { margin: 0; padding: 0; } | |
fieldset { | |
width: 200px; height: 200px; background: #ddd; border: 0; | |
position: relative; padding: 20px; | |
} | |
div { | |
width: 100px; height: 100px; background: red; |
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 slice = Function.prototype.bind.bind(Array.prototype.slice); | |
var p = function (fn, args) { | |
var d = defer(); | |
fn.apply(this, slice(arguments, 1).concat(function (error, result) { | |
d.resolve((error == null) ? result : error); | |
})); | |
return d.promise; | |
}; |
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 path = require('path') | |
, fs = require('fs') | |
, deferred = require('deferred'), delay = deferred.delay | |
, promisify = deferred.promisify | |
, lstat = promisify(fs.lstat), unlink = promisify(fs.unlink), readdir = promisify(fs.readdir) | |
, rmdir = promisify(fs.rmdir) | |
var timeout = 0; | |
var rimraf = module.exports = function (p, opts) { | |
opts = opts || {}; |
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 randomString (bits) | |
// #### @bits {integer} The number of bits for the random base64 string returned to contain | |
// randomString returns a pseude-random ASCII string which contains at least the specified number of bits of entropy | |
// the return value is a string of length ⌈bits/6⌉ of characters from the base64 alphabet | |
// | |
helpers.randomString = exports.randomString = function (bits) { | |
var chars, rand, i, ret; | |
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-'; |
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 slice = (function (slice) { | |
return function (list, start, end) { | |
return slice.call(list, start, end); | |
}; | |
}([].slice)); |
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
// Constructor way: | |
var Class = function (value) { | |
this.value = value; | |
}; | |
Class.prototype = { | |
property: 'value', | |
method: function () {} | |
}; | |
var obj = new Class(value); |
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 files = input.files; | |
var fd = new FormData(); | |
var xhr = new XMLHttpRequest(); | |
fd.append('file[0]', file[0]); | |
fd.append('file[1]', file[1]); | |
xhr.open('POST', '/upload', true); | |
xhr.send(fd); |
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
// http://old.nabble.com/Re%3A-UUIDs--p33511279.html | |
(~~(Math.random() * 1e9)).toString(36) + Date.now() |
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
// ES6: | |
var Foo = { | |
getValue: () => "Foo value", | |
somethingUseful: () => this.getValue(); | |
} | |
// same in ES5: | |
var Foo = { | |
getValue: function () { return "Foo value"; } | |
}; |
OlderNewer