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
/** Normally you provide all signers (private keys) at once with an spl-token multisig. | |
* This is of course useless. | |
* Here is how you can get the signatures one-by-one without having all the private keys. | |
* (For example, you'd send the tx over the network and get a signature back from the other party.) | |
*/ | |
import { createMint, createMultisig, getAccount, getOrCreateAssociatedTokenAccount, mintTo, TokenInstruction, TOKEN_PROGRAM_ID, transferInstructionData } from '@solana/spl-token'; | |
import { Connection, Keypair, PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js'; | |
import nacl from 'tweetnacl'; | |
const log = console.log; |
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
<script type="module"> | |
import { h, Component, render } from 'https://unpkg.com/preact?module'; | |
import htm from 'https://unpkg.com/htm?module'; | |
// Initialize htm with Preact | |
const html = htm.bind(h); | |
function App (props) { | |
return html`<h1>Hello ${props.name}!</h1>`; | |
} |
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
for f in "$@"; do | |
now=$(date +%Y-%m-%d--%H-%M-%S) | |
bn=$(basename $f) | |
if [ "$f:e" = "mov" ]; then | |
say "compressing video" | |
ffmpeg -i "$f" -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus "$HOME/docs/compressed-shots/$now.webm" | |
say "compressed" | |
fi | |
if [ "$f:e" = "png" ]; then |
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
import { Loader } from 'pixi.js' | |
export function loadSingleAsset(url: string) { | |
return new Promise(resolve => | |
new Loader().add(url).load(() => resolve(null)) | |
) | |
} |
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
"problemMatcher": { | |
"pattern": [ | |
{ | |
"regexp": "\\[(ERROR)\\] (.*)", | |
"severity": 1, | |
"message": 2 | |
}, | |
{ "regexp": "" }, | |
{ | |
"regexp": "(.*?):(\\d+):(\\d+)", |
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
// public domain: https://gist.github.com/qpwo/0d91803074290167e40f79908038f3cb | |
import https from 'https'; | |
export async function fetchJson(url) { | |
return await new Promise(resolve => https | |
.get(url, res => { | |
let body = ''; | |
res.on('data', chunk => (body += chunk)); | |
res.on('end', () => { | |
try { | |
resolve(JSON.parse(body)); |
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
function import-ts-repl() { ( | |
set -e | |
file=$1 | |
rm -f ${file}.js ${file}.js.map | |
esbuild ${file} --target=node14 --format=cjs --sourcemap --outfile=${file}.js --platform=node --bundle | |
node -r ${file}.js | |
rm -f ${file}.js ${file}.js.map | |
); } |
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
// problem: canvas burns your CPU because you redraw everything every frame | |
// solution: just re-draw stuff that's changed or shares a layer & overlap with something changed | |
// inspired by mithril | |
function Counter() { | |
let x = 0 | |
let y = 0 | |
const width = 100 | |
const height = 100 | |
return { | |
state: () => {x, y}, // checked for equality to run render |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "build & run ts", | |
"program": "${file}.js", | |
"envFile": "${fileDirname}/.env", | |
"preLaunchTask": "esbuild-current-file", |
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
function deepEquals(e,r){if(e===r||Number.isNaN(e)&&Number.isNaN(r))return!0;if(typeof e!=typeof r||"object"!=typeof e||null===e||null===r)return!1;const t=Array.isArray(e),n=Array.isArray(r);if(t!==n)return!1;if(t&&n)return e.length===r.length&&e.every((e,t)=>deepEquals(e,r[t]));const s=Object.keys(e),u=Object.keys(r);return s.length===u.length&&(s.sort(),u.sort(),!!s.every((e,r)=>e===u[r])&&s.every(t=>deepEquals(e[t],r[t])))} |