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
| #!/usr/bin/env node | |
| require('fs').readFile(process.argv[2], (err, data) => { | |
| if (err) return; | |
| const content = data.toString().trim(); | |
| const re = /^\[(.+?)\]\s+<(.+?)>\s(.*)$/gm; | |
| const chat = []; | |
| let current = {}; | |
| while (match = re.exec(content)) { | |
| if (match[2] !== current.name) { |
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 paint = function(rAF){ 'use strict'; | |
| return function paint(before) { | |
| before(); | |
| return rAF(before), { | |
| then: function (after) { | |
| return rAF(rAF.bind(null, after)), this; | |
| } | |
| }; | |
| }; | |
| }( |
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
| #!/usr/bin/env bash | |
| if [ -f /usr/lib/jsc ]; then | |
| /usr/lib/jsc "$@" | |
| elif [ -f /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc ]; then | |
| /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc "$@" | |
| fi |
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
| const clone = (() => { | |
| /*! (c) Andrea Giammarchi - WTFPL */ | |
| const toString = {}.toString; | |
| const flags = ['global', 'ignoreCase', 'multiline', 'sticky', 'unicode']; | |
| const prime = obj => typeof obj === 'object' ? new obj.constructor(obj.valueOf()) : obj; | |
| const through = obj => { | |
| const descriptors = Object.getOwnPropertyDescriptors(obj); | |
| Reflect.ownKeys(descriptors).forEach(key => { | |
| const descriptor = descriptors[key]; | |
| if ('value' in descriptor) { |
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
| function fixEslintAllman(code) { | |
| return code.replace(/^{/mg, function ($0, $1) { | |
| var newLine = code.lastIndexOf('\n', $1 - 2); | |
| var spaces = code.slice(newLine + 1, $1 - 1).match(/^(\s*)/)[1]; | |
| return spaces + '{'; | |
| }); | |
| } |
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
| function removeColumn($0) { | |
| let tr = $0.closest('tr'); | |
| const index = [].indexOf.call(tr.querySelectorAll($0.nodeName), $0); | |
| $0.remove(); | |
| tr = tr.closest('thead').nextElementSibling.querySelector('tr'); | |
| do { | |
| let td = tr.querySelectorAll('td'); | |
| if (td.length) td[index - 1].remove(); | |
| else tr.querySelectorAll('th')[index].remove(); | |
| } while (tr = tr.nextElementSibling); |
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
| document.documentElement.appendChild( | |
| document.createElement('style') | |
| ).textContent = ` | |
| .executable { | |
| transition: all .3s; | |
| } | |
| .executable:hover { | |
| cursor: pointer; | |
| background: #fff !important; | |
| }`; |
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
| // used to retrieve template content | |
| const templates = new WeakMap; | |
| // used to retrieve node updates | |
| const updates = new WeakMap; | |
| // hyperHTML, the nitty gritty | |
| function hyperHTML(chunks, ...interpolations) { | |
| // if the static chunks are unknown |
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
| const JSONChannel = (Private => class JSONChannel { | |
| // (c) Andrea Giammarchi - @WebReflection (ISC) | |
| constructor(secret=Array.from( | |
| crypto.getRandomValues(new Uint8Array(8)) | |
| ).map(i => i.toString(36)).join('')) { | |
| const listener = e => this.emit('message', null, e.detail); | |
| document.addEventListener(`${secret}:gjs`, listener); | |
| Private.set(this, { | |
| secret, listener, | |
| fn: Object.create(null) |
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
| (function (document, TEMPLATE) { | |
| var container = document.createElement(TEMPLATE); | |
| if ('content' in container) return; | |
| var createElement = document.createElement; | |
| var descriptor = { | |
| get: function () { return this.content ? this.content.innerHTML : ''; }, | |
| set: function (html) { | |
| var el = createElement.call(document, TEMPLATE); | |
| if (/^[^\S]*?<(t(?:head|body|foot|r|d|h))/i.test(html)) { | |
| var selector = RegExp.$1; |