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
#!/usr/bin/env node | |
const FS = require('fs') | |
const URL = require('url') | |
const Child_process = require('child_process') | |
const all = FS.readFileSync('pww.txt', {encoding:'utf8'}) | |
const regex = /\n(?:"([^"]*)")?\t"([^"]*)"\t"([^"]*)"\t"([^"]*)"\t"([^"]*)"\t(?:"([^"]*)")?/mg | |
while (true) { | |
const match = regex.exec(all) | |
if (!match) break |
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
#!/bin/bash | |
# | |
# Cache nix-shell environment | |
# | |
# - watches shell.nix (or default.nix), ~/.direnvrc and .envrc | |
# - based on https://github.com/direnv/direnv/wiki/Nix | |
# | |
use_nix() { | |
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix) | |
if [[ ! -f "$shell_file" ]]; then return; fi |
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
Assert.rejects = async function rejects (blockOrPromise, error, message) { | |
return new Promise((resolve,reject) => { | |
if (typeof blockOrPromise === 'function') { | |
blockOrPromise = blockOrPromise() | |
} | |
blockOrPromise.then(x => { | |
reject(Error('Should fail, not return ' + x)) | |
}).catch(async err => { | |
if (typeof error === 'function') { | |
err = (await error(err)) || err |
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 this with an overmind Procfile like this: | |
geth: geth --dev --rpc console | |
jest: pnpx jest --watchAll | |
*/ | |
const ChildProcess = require('child_process') | |
const Web3 = require('web3') | |
const Assert = require('assert') | |
function addressOf(contract) { | |
return contract.options.address |
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
package main | |
import ( | |
"context" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" |
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
#!/bin/bash | |
# | |
# Cache nix-shell environment | |
# | |
# - watches shell.nix (or default.nix), ~/.direnvrc and .envrc | |
# - based on https://github.com/direnv/direnv/wiki/Nix | |
# | |
use_nix() { | |
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix) | |
if [[ ! -f "$shell_file" ]]; then return; fi |
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
#!/usr/bin/env node | |
const QR = require("qr-image"); | |
const arrayOf = (len, filler) => new Array(len).fill(filler); | |
const text = process.argv[2]; | |
const matrix = QR.matrix(text, "L"); | |
const topBottomPad = arrayOf(4, arrayOf(matrix[0].length, 0)); | |
const rowPad = arrayOf(4, 0); |
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
/* | |
MIT License | |
Copyright (c) 2018 Lionello Lunesu | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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
/** | |
* Wrap an Express middleware or handler for async support. | |
* @param {function} fn The middleware or handler to wrap | |
* @returns {function} Wrapped function | |
*/ | |
exports.wrap = function(fn) { | |
if (fn.length === 4) { | |
// Wrap error handler | |
return (err, req, res, next) => { | |
const r = fn(err, req, res, next) |
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
#!/usr/bin/env bash | |
usage () { | |
echo "Usage: $(basename $0) [--direnv] [--shell] [--default] -p|--packages packages... [--test]" | |
exit 0 | |
} | |
error () { | |
echo "Error: $1" | |
exit 1 |