Skip to content

Instantly share code, notes, and snippets.

View andy0130tw's full-sized avatar
🍌
why no 🍆

Andy Pan andy0130tw

🍌
why no 🍆
View GitHub Profile
@andy0130tw
andy0130tw / plurk_detect.user.js
Created December 16, 2023 02:19
Plurk detect hide_plurks_before
// ==UserScript==
// @name Plurk detect hide_plurks_before
// @namespace me.qbane
// @version 1
// @match https://*.plurk.com/*
// @run-at document-idle
// ==/UserScript==
const PGUSER = unsafeWindow.GLOBAL?.page_user?.hide_plurks_before
@andy0130tw
andy0130tw / ghc-wasm-setup.py
Created December 9, 2023 17:43
A slim re-implementation of setup.sh in ghc-wasm-meta
import os
import subprocess
import shlex
import shutil
import sys
import json
if shutil.which('curl') is None:
print('This script requires curl')
@andy0130tw
andy0130tw / rg-install.sh
Created December 5, 2023 02:20
How I typically install ripgrep without system package manager for a single user
# mkdir -p is your good friend
cp rg ~/.local/bin
cp doc/rg.1 ~/.local/share/man/man1
cp complete/rg.bash ~/.local/share/bash-completion
@andy0130tw
andy0130tw / wasi-preview1-api.md
Created November 30, 2023 20:25
Maybe make WASI API docs less sh*tty?

Modules

wasi_snapshot_preview1

Imports

Memory

Functions

# args_get

args_get(argv: Pointer<Pointer<u8>>, argv_buf: Pointer<u8>) → Result<(), errno>

Read command-line argument data.

@andy0130tw
andy0130tw / Everything.agda
Created November 29, 2023 15:02
agda-stdlib's Everything v1.7.3
------------------------------------------------------------------------
-- The Agda standard library
--
-- All library modules, along with short descriptions
------------------------------------------------------------------------
-- Note that core modules are not included.
{-# OPTIONS --rewriting --guardedness --sized-types #-}
@andy0130tw
andy0130tw / run.mjs
Created November 25, 2023 09:03
My WASI runtime wrapper template in Node.js (v20+)
import { readFile } from 'node:fs/promises'
import { WASI } from 'wasi'
import { argv, env } from 'node:process'
import * as path from 'node:path'
const wasmPath = path.resolve('/path/to/wasm/here.wasm')
const args = [path.basename(wasmPath), ...argv.slice(2)]
const wasi = new WASI({
@andy0130tw
andy0130tw / +server.js
Created November 15, 2023 14:29
First try on WasmFS using petersalomonsen/wasm-git with emscripten 3.1.49
// place this at src/routes/git-proxy/[...path]/+server.js
// modified from
// https://github.com/petersalomonsen/wasm-git/blob/master/examples/webserverwithgithubproxy.js
import https from 'node:https'
import { Readable } from 'node:stream'
import { error } from '@sveltejs/kit'
/**
@andy0130tw
andy0130tw / node_runtime.py.patch
Created November 11, 2023 13:12
Sublime Text LSP patch for the "correct" Node path handling in lsp_utils; useful if you use nvm/volta/...
--- node_runtime.py.orig 2023-11-11 21:03:31
+++ node_runtime.py 2023-11-11 21:03:08
@@ -217,26 +217,27 @@
print('[lsp_utils] START output of command: "{}"'.format(' '.join(args)))
print(stdout)
print('[lsp_utils] Command output END')
if error is not None:
raise Exception('Failed to run npm command "{}":\n{}'.format(' '.join(args), error))
def npm_command(self) -> List[str]:
@andy0130tw
andy0130tw / sync.js
Created August 2, 2023 18:05
SvelteKit will skip generating types if it cannot detect TypeScript environment. Therefore this ad-hoc script is born.
import child_process from 'node:child_process'
function run(cmd) {
child_process.execSync(cmd, { stdio: 'inherit' })
}
;(async () => {
let ts_patched = false
try {
@andy0130tw
andy0130tw / QUICKJS-DISASM.md
Last active May 16, 2023 03:05
Dumping opcodes from generated C code from QuickJS

QuickJS disasm

A minimal disassembler with an example on code instrumentation