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
/* Cocoa application event loop implementation for NodObjC. | |
* Code created for https://github.com/TooTallNate/NodObjC/pull/56 | |
* Working as of 2015-Jan-11 on Mac OS 10.10, Node 0.10.35, NodObjC 1.0.0 | |
* | |
* Copyright (c) 2015, Shane Holloway | |
* | |
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
*/ |
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 json_canonical(obj) { | |
return JSON.stringify(obj, (key, value) => { | |
if ('object' !== typeof value) | |
return value // it is a value of some kind | |
if (value instanceof Array) | |
return value // Arrays are (already) ordered | |
// normalize into new object initializing via sorted keys | |
let 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
'use strict' | |
/* | |
* Adapted from: https://github.com/rpsirois/icosindexer | |
* Who aadapted it from: Lee, Michael and Samet, Hanan. (April 2000). | |
* Navigating through Triangle Meshes Implemented as Linear Quadtrees. | |
* ACM Transactions on Graphics, Vol. 19, No. 2. | |
* Retrieved from https://pdfs.semanticscholar.org/a5c8/8b53174405e5ff512ff5ffa8a56df3c8e2df.pdf | |
* | |
* Authors: | |
* - [Robert Sirois](https://github.com/rpsirois) |
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 speakeasy = require('speakeasy') | |
const totp_obj = { label: 'gist-totp-demo', algorithm: 'sha256', | |
secret: 'some secret string', encoding: 'base64'} | |
const otp_url = speakeasy.otpauthURL(totp_obj) | |
const qr_image = require('qr-image') | |
const png_buffer = qr_image.imageSync(otp_url, {type: 'png'}) | |
const svg = qr_image.imageSync(otp_url, {type: 'svg'}) | |
const svg_buffer = Buffer.from(svg) |
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
class Rectangle :: | |
constructor(height, width) :: | |
this.height = height; | |
this.width = width; | |
toString() :: | |
return `(${this.height} ${this.width})`; |
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
## docker stack deploy -c docker-stackfile.yml gist_demo | |
version: "3.8" | |
services: | |
playground: | |
image: node:alpine | |
hostname: '{{.Task.Name}}' | |
environment: | |
SWARM_TASK: '{{.Task.Name}}' | |
SWARM_PEERS: "tasks.{{.Service.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
#!/bin/bash | |
node -e 'require("http").createServer((req,res) => {res.end([[req.method, req.httpVersion, req.url], ["On host:", require("os").hostname()], []].map(l=>l.join(" ")).join("\n"))}).listen(3001, "0.0.0.0", ()=> {})' |
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 promiseSome(promises) :: | |
// a cross between Promise.all and Promise.race | |
promises = Array.from(promises).filter(e => e) | |
return new Promise @ resolve => :: | |
const result = [] | |
result.done = new Promise @ done => :: | |
let count = promises.length | |
if 0 === count :: | |
resolve(result) | |
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
node_modules/ | |
*/node_modules/ | |
*/build | |
*/dist | |
./yarn.lock | |
./package-lock.json |
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 () { | |
'use strict'; | |
function createCommonjsModule(fn, module) { | |
return module = { exports: {} }, fn(module, module.exports), module.exports; | |
} | |
/* | |
object-assign | |
(c) Sindre Sorhus |