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 / Logic.agda
Created August 18, 2022 10:08
DTP (Agda) questions for FLOLAC 2022
------ Minimal definitions for questions; extracted from DTP logic ------
variable A B : Set
-- Conjunction corresponds to product/pair types:
data _×_ (A B : Set) : Set where
_,_ : A → B → A × B
infix 3 _×_
@andy0130tw
andy0130tw / proxy.js
Last active July 31, 2022 20:46
naive LSP-over-websocket bidirectional channel
import { WebSocketServer } from 'ws'
import net from 'net'
const wss = new WebSocketServer({
port: 5566,
})
let lastWs = null
wss.on('connection', ws => {
@andy0130tw
andy0130tw / jsonvue-dark-mode.css
Last active June 30, 2022 16:30
My naive dark mode theme for JSONVue
@font-face{
font-family: 'Fira Mono';
src: url('https://rawcdn.githack.com/mozilla/Fira/e1b58cc66962d24caaa7ebe2e2e9a50125f20d51/woff2/FiraMono-Regular.woff2') format('woff2');
font-weight: 400;
font-style: normal;
}
@font-face{
font-family: 'Fira Mono';
src: url('https://rawcdn.githack.com/mozilla/Fira/e1b58cc66962d24caaa7ebe2e2e9a50125f20d51/woff2/FiraMono-Bold.woff2') format('woff2');
@andy0130tw
andy0130tw / plist_to_json.py
Created May 20, 2022 16:01
Convert ASCII plist (e.g., Glyphs source file) to JSON
import sys
import json
import openstep_plist
with open(sys.argv[1], 'r') as fp:
data = openstep_plist.load(fp, use_numbers=True)
text = json.dumps(data, sort_keys=True, indent=2)
print(text)
@andy0130tw
andy0130tw / snes-ppu-utils.c
Created March 22, 2022 17:26
Try to optimize setWindowPattern for simpler cases
#include <stdint.h>
#include <stdbool.h>
// fill x with the bit pattern 0...01...10...0,
// where i-th bit is set iff i is in [a, b]
void ppu_setWindowPattern(uint8_t x[32], int a, int b) {
for (int i = 0; i < 32; i++) {
int begin = i * 8;
int end = begin + 8;
// [PackageDev] target_format: plist, ext: tmLanguage
{ "name": "Cryptoline",
"scopeName": "source.cryptoline",
"fileTypes": [".cl"],
"uuid": "af276db7-b1e4-4fe4-b0f6-712121d6f4c2",
"patterns": [
{ "include": "#common" },
{ "include": "#constant-decl" },
{ "include": "#proc-decl" },
@andy0130tw
andy0130tw / bose-activate.sh
Last active November 4, 2021 11:16
Activate your Bose Resolve Soundlink on Linux after each time you plug it in
#!/bin/bash
# FYI: https://askubuntu.com/questions/1104726/bose-revolve-soundlink-usb-output-no-sound
# usage: ./bose-activate.sh [VOLUME]
CARDS=$(LANG= aplay -l)
HAS_BOSE=$(echo "$CARDS" | grep "card 1: SoundLink \[Bose Revolve SoundLink\]")
echo $HAS_BOSE
@andy0130tw
andy0130tw / gitlab-14-sidebar-fix.userstyle.css
Created June 27, 2021 15:18
GitLab 14 refactored the sidebar to make it a usability crisis. Let's fix it.
body.sidebar-refactoring .nav-sidebar li>a, body.sidebar-refactoring .nav-sidebar li>.fly-out-top-item-container {
line-height: 1.6rem;
}
body.sidebar-refactoring .nav-sidebar a.has-sub-items+.sidebar-sub-level-items {
margin-top: 0;
}
@andy0130tw
andy0130tw / etherscan-legacy.userstyle.css
Last active June 27, 2021 15:19
Userstyle to maintain your nostalgic etherscan experience :)
body {
font-size: .8rem;
}
.container {
max-width: 1140px;
margin-left: auto;
margin-right: auto;
}
const fs = require('fs')
const htmlparser2 = require('htmlparser2')
const { WritableStream } = require("htmlparser2/lib/WritableStream")
class Store {
constructor() {
Object.assign(this, { fragments: [], content: null })
}
add(frag) {
this.fragments.push(frag)