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 / 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

How to fix the f(???)ing tlmgr on Debian/Ubuntu

When you see:

tlmgr: Local TeX Live (2021) is older than remote repository (2023).
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
See https://tug.org/texlive/upgrade.html for details.
@andy0130tw
andy0130tw / svelte-cli.js
Last active April 29, 2023 06:10
It's dangerous to SSR alone. Take this!
import fs from 'fs'
import sade from 'sade'
import { walk } from 'estree-walker'
import { rollup } from 'rollup'
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'))
const prog = sade('svelte-cli').version(pkg.version)
import {
compile,
@andy0130tw
andy0130tw / apt.py
Created April 17, 2023 16:44
Enable all apt sources previously disabled from upgrading. Authored on 2019/5/7.
#! /usr/bin/python3
import aptsources.sourceslist as sl
import lsb_release
codename = lsb_release.get_distro_information()['CODENAME']
sources = sl.SourcesList()
for source in sources.list:
if source.comment.lower().find("因升級至") >= 0:
@andy0130tw
andy0130tw / GF_simplify.py
Created March 20, 2023 18:44
My sh*tting code to simplify a symbolic expression in SageMath over GF(p)
import sage
from sage.all_cmdline import * # import sage library
from sage.symbolic.operators import add_vararg, mul_vararg
def GF_simplify(_expr, p=2):
expr = expand(_expr)
if expr.operator() != add_vararg:
raise Exception('Can only simplify a sum over products.')
result = None
@andy0130tw
andy0130tw / squirrel.custom.yaml
Last active February 3, 2023 09:34
My customization for Squirrel, a input method framework on Mac. Patching https://github.com/rime/squirrel/blob/fbd430de6debb6b349b6ba529e097dea518faad1/data/squirrel.yaml.
patch:
# blocking: not using for Squirrel handling left/right keys incorrectly
# in horizontal mode (16.1)
# style/text_orientation: horizontal
# style/candidate_list_layout: linear
style/font_point: 14
style/border_width: 8
style/border_height: 4
style/spacing: 8
@andy0130tw
andy0130tw / converter.py
Last active January 7, 2023 21:22
Rime dictionary for terra-pinyin converted from McBopomofo
import math
from operator import itemgetter
HEADER = '''\
# Rime dictionary
# encoding: utf-8
#
# Data converted from McBopomofo
---
@andy0130tw
andy0130tw / IBus-1.0.gir
Last active November 29, 2022 16:10
ibus 1.5.26
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GLib" version="2.0"/>
<include name="GObject" version="2.0"/>
@andy0130tw
andy0130tw / 50-emoji.conf
Last active October 19, 2022 08:20
Experimental fontconfig setup for color emoji
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<selectfont>
<rejectfont>
<pattern>
<patelt name="family">
<string>Symbola</string>
</patelt>
</pattern>
@andy0130tw
andy0130tw / RedBlack.agda
Last active August 21, 2022 08:00
Red black tree in Agda (FLOLAC 2022)
-- open import Prelude
--- Products
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
outl : A
outr : B outl