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
// TODO: longer method name | |
Function.prototype.extractBlockCommentAsMultilineString = function() { | |
return this.toString().match(/^function \(\)\{\s*\/\*((?:[^*]|\*+[^*\/])*)\*+\/\s*\}$/)[1]; | |
}; | |
var s = function(){/* | |
STRING | |
GOES | |
HERE | |
*/}.extractBlockCommentAsMultilineString(); |
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
''' | |
"RegEx match open tags except XHTML self-contained tags" | |
<http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags> | |
The W3C grammar for an XHTML open tag is given by production "STag". This | |
production is not recursive and is in fact strictly regular. The relevant | |
portions of the XML grammar are as follows (<http://www.w3.org/TR/xml11/>): | |
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] | |
No constraints |
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
<[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF][\-.0-9:A-Z_a-z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0300-\u036F\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF]*([\u0020\u0009\u000D\u000A]+[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF][\-.0-9:A-Z_a-z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0300-\u036F\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF]*[\u0020\u0009\u000D\u000A]*=[\u0020\u0009\u000D\u000A]*("([^<&"]|&([:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\U |
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
if True: | |
pass | |
if True: | |
if True: | |
if True: | |
if True: | |
if True: | |
if True: | |
if True: | |
print("yup, syntactically valid Python") |
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
"use strict" | |
const tai = require("t-a-i") | |
for (let y = 1961; y <= new Date().getFullYear(); y++) { | |
const start = tai.unixToAtomic(Date.UTC(y, 0, 1)) | |
const end = tai.unixToAtomic(Date.UTC(y + 1, 0, 1)) | |
console.log(y, end - start) | |
} |
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
"use strict"; | |
var tai = require("t-a-i"); | |
var prevlen = undefined; | |
var prevcount = 0; | |
for(var d = Date.UTC(1961, 0, 1); d < Date.UTC(2017, 0, 1); d += 86400000) { | |
var d2 = d + 86400000; | |
var len = tai.unixToAtomic(d2) - tai.unixToAtomic(d); | |
len = Math.round(len * 10000) / 10000; |
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
/** | |
Analogous to Array.prototype.map but for objects. If you | |
REALLY don't want to modify Object.prototype you can | |
modify this into a regular function `objectMap(obj, f)` I GUESS | |
but it doesn't affect the basic idea of what happens below | |
*/ | |
Object.prototype.map = function(f) { | |
const mapped = {}; | |
Object.keys(this).forEach(key => { | |
mapped[key] = f(this[key], key, this); |
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
'use strict' | |
// <http://www.ecma-international.org/ecma-262/5.1/#sec-8> Type | |
var type = function (x) { | |
// The `typeof` operator gives us almost what we want | |
return ( | |
typeof x === 'function' ? 'object' | |
: x === null ? 'null' | |
: typeof x | |
) |
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
let P=exports.P=(t,e,r=t=>typeof t==typeof P,c,o=t=>c=t,h=(t,e)=>{try{e=t(e),l==e?c():e===Object(e)&&r(t=e.then)?t.call(e,t=>e&&h(e=>t,e=0),t=>e&&o([t],e=0)):o([e,1])}catch(t){o([t])}},l={r:(c,P)=>setTimeout(l=>r(P=c[1]?t:e)?h(P,c[0]):o(c)),then:(t,e,r=P(t,e),h=o)=>(c?r.r(c):o=t=>r.r(t,h(t)),r)})=>l |
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
(s => console.log(`${s}\n(${JSON.stringify(s)})\n`)) | |
("(s => console.log(`${s}\\n(${JSON.stringify(s)})\\n`))") |
OlderNewer