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
| // A tiny, dependency-free TypeScript REPL for Node. | |
| // | |
| // node ts-repl.mjs | |
| // | |
| // Needs Node 22.13+ (24 recommended). No install, no ts-node, no build — it | |
| // augments Node's OWN `repl` instead of reimplementing one. We start the real | |
| // REPL and override only `eval` to type-strip each entry (via Node's built-in | |
| // `module.stripTypeScriptTypes`) before handing it to Node's default eval. That | |
| // means the line editor, history, tab-completion, `_` last value, top-level | |
| // await, multiline, and error display are all Node's, for free. We add three |
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 chunkedUrl = 'https://jigsaw.w3.org/HTTP/ChunkedScript'; | |
| fetch(chunkedUrl) | |
| .then(processChunkedResponse) | |
| .then(onChunkedResponseComplete) | |
| .catch(onChunkedResponseError) | |
| ; | |
| function onChunkedResponseComplete(result) { | |
| console.log('all done!', 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
| <!doctype html> | |
| <body> | |
| <script src="https://unpkg.com/lodash/lodash.min.js"></script> | |
| <script src="https://unpkg.com/platform/platform.js"></script> | |
| <script src="https://unpkg.com/benchmark/benchmark.js"></script> | |
| <pre id="output"></pre> | |
| <script> | |
| function log(message) { | |
| document.getElementById("output").innerHTML += message + '\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
| /** | |
| * Given an image URL, return a base64-encoded data URI. | |
| * @param {String} url|uri|image The URL for the image to be converted. | |
| * @param {String} [callback|cb] Name of the function you want to be called. | |
| * @returns {Object} JSON | |
| * @returns {String} JSON.data The data URI for the image | |
| * @returns {Object} JSON.meta | |
| * @returns {Number} JSON.meta.width The width of the image, in pixels. | |
| * @returns {Number} JSON.meta.height The height of the image, in pixels. | |
| * @returns {Object} JSON.http |
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
| // Uses [request](https://github.com/mikeal/request) | |
| // /?url=http://nodejs.org/logo.png | |
| // /?uri=http://nodejs.org/logo.png | |
| // /?url=http://nodejs.org/logo.png&cb=cbName | |
| // /?url=http://nodejs.org/logo.png&callback=cbName | |
| var fs = require('fs'); | |
| var url = require('url'); | |
| var http = require('http'); | |
| var request = require('request'); |
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> | |
| <head> | |
| <meta charset=utf-8 /> | |
| <title>Holy Grail</title> | |
| <style> | |
| /* some basic styles. nothing to do with flexbox */ | |
| header, footer, | |
| nav, article, aside { | |
| border: 1px solid black; |
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 image2canvas = (function ( global, document, undefined ) | |
| { | |
| // parseUri 1.2.2 | |
| // (c) Steven Levithan <stevenlevithan.com> | |
| // MIT License | |
| function parseUri (str) | |
| { | |
| var o = parseUri.options, | |
| m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), | |
| uri = {}, |
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
| // Forked from paul irish's https://gist.github.com/601751 | |
| // desire: localStorage and sessionStorage should accept objects | |
| // in fact they do according to spec. | |
| // http://code.google.com/p/chromium/issues/detail?id=43666 | |
| // but so far that part isnt implemented anywhere. | |
| // so we duckpunch set/getItem() to stringify/parse on the way in/out | |
| // this seems to work in chrome |
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
| license: unlicense |
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
| // from http://www.w3.org/TR/WCAG20/#relativeluminancedef | |
| function relativeLuminanceW3C(R8bit, G8bit, B8bit) { | |
| var RsRGB = R8bit/255; | |
| var GsRGB = G8bit/255; | |
| var BsRGB = B8bit/255; | |
| var R = (RsRGB <= 0.03928) ? RsRGB/12.92 : Math.pow((RsRGB+0.055)/1.055, 2.4); | |
| var G = (GsRGB <= 0.03928) ? GsRGB/12.92 : Math.pow((GsRGB+0.055)/1.055, 2.4); | |
| var B = (BsRGB <= 0.03928) ? BsRGB/12.92 : Math.pow((BsRGB+0.055)/1.055, 2.4); |
NewerOlder