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 / ascii-plist.sublime-syntax
Created July 7, 2025 06:22
Sublime Syntax definition of ASCII ("Old-Style") Property List, converted via ST4 from textmate/property-list.tmbundle
%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: Property List (Old-Style)
file_extensions:
- plist
# from: https://github.com/textmate/property-list.tmbundle/blob/master/Syntaxes/Property%20List%20(Old-Style).tmLanguage
# warning: pop pattern contains \G, this will not work as expected if it's intended to refer to the begin regex: (?!\G)
@andy0130tw
andy0130tw / nonblock.rs
Last active June 14, 2025 06:59
I just found the argubly very first complete Rust program I wrote from scratch. And there were no LLMs involved at that time of writing. Anyway.
use std::task::{Poll, Context};
use std::future::Future;
use std::pin::Pin;
use tokio::io::{Error, Interest, unix::AsyncFd};
struct PollTarget {
inner: AsyncFd<i32>,
}
impl PollTarget {
#!/bin/sh
PATH_TO_FWTOOL=/home/qbane/system-apps/framework-system/target/debug/framework_tool
if [ $# -eq 0 ]; then
exec $PATH_TO_FWTOOL --help
fi
# if this does not work (like using a kernel before 6.12), you might need "--driver=portio" extra arg
exec sudo $PATH_TO_FWTOOL "$@"
@andy0130tw
andy0130tw / blog-yorkxin-org.userscript.js
Created May 11, 2025 14:06
yorkxin blog link replacer
// ==UserScript==
// @name yorkxin
// @version 1
// @match https://blog.yorkxin.org/*
// @grant none
// ==/UserScript==
const links = Array.from(document.querySelectorAll('a[href]'))
let cnt = 0
@andy0130tw
andy0130tw / expr.ts
Last active May 7, 2025 12:26
Some gibberish on TS parsing format strings
import type { GreaterThanOrEqual, Merge } from 'type-fest'
import { BuildTuple, Whitespace } from 'type-fest/source/internal'
// TODO: trim comments
type TrimWS<S extends string> =
S extends `${Whitespace}${infer R}` ? (
R extends `${Whitespace}${infer RR}` ? (
RR extends `${Whitespace}${infer RRR}` ? (
RRR extends `${Whitespace}${infer RRRR}` ? TrimWS<RRRR> : RRR
) : RR) : R) : S

How to update the bundled TypeScript package version in LSP-TypeScript in Sublime Text?

# Suppose you are at path xxx
mkdir tmp
cp ~/Library/Application\ Support/Sublime\ Text/Installed\ Packages/LSP-typescript.sublime-package .
cd tmp                                   # now at: xxx/tmp
unzip ../LSP-typescript.sublime-package  # extracts to the current dir
cd typescript-language-server            # now at: xxx/tmp/typescript-language-server
@andy0130tw
andy0130tw / iv-template-line-parser.ts
Last active February 19, 2025 06:03
Mostly finished
import { blockFunctionNameSet } from './names'
interface InputConfig {
debug?: boolean
locations?: boolean
allowServiceRules?: boolean
}
type IVLanguageVersion = '1.0' | '2.0' | '2.1'
@andy0130tw
andy0130tw / cm-draggable-gutter.js
Last active October 1, 2024 18:39
Draggable gutter for selecting lines
import {
StateField,
StateEffect,
EditorSelection,
StateEffectType,
} from '@codemirror/state'
import { EditorView, ViewPlugin } from '@codemirror/view'
/** @import { Text, Line } from '@codemirror/state' */
/** @import { PluginValue, BlockInfo } from '@codemirror/view' */
@andy0130tw
andy0130tw / cm-single-line.js
Last active October 1, 2024 18:21
Sample single line setup CodeMirror; note that you need to tweak the default keymap
import { minimalSetup } from 'codemirror'
import { EditorState } from '@codemirror/state'
import { EditorView, keymap } from '@codemirror/view'
import { insertNewlineAndIndent, insertBlankLine } from '@codemirror/commands'
function removeNewlineCommands(exts) {
const newlineCommands = [insertNewlineAndIndent, insertBlankLine]
return exts.map(ext => {
if (ext?.facet == keymap) {
@andy0130tw
andy0130tw / cm-enhanced-search-field.js
Last active October 8, 2024 07:02
CodeMirror with a search field that is another CodeMirror instance!
import { basicSetup, minimalSetup } from 'codemirror'
import { Prec } from '@codemirror/state'
import { EditorView, keymap, placeholder } from '@codemirror/view'
import { search, findNext, findPrevious } from '@codemirror/search'
const SearchPanel = (() => {
const searchConfigFacet = search({})[0].facet