Skip to content

Instantly share code, notes, and snippets.

View Spike-Leung's full-sized avatar
🙈
My other car is cdr

Spike Spike-Leung

🙈
My other car is cdr
View GitHub Profile
@Spike-Leung
Spike-Leung / org-protocol.user.js
Last active January 11, 2025 03:45
org-protocol.user.js
// ==UserScript==
// @name org-protocol
// @namespace https://gist.github.com/Spike-Leung/19986df42333b6419b2eadaa73526d7b
// @version 0.0
// @description Use Alt + l for Org: capture and use Alt + h for Org: capture-html
// @author Spike-Leung
// @match *://*/*
// @grant none
// ==/UserScript==
@Spike-Leung
Spike-Leung / org-protocol.reg
Last active January 9, 2025 02:38
setup-org-protocol-on-window
REGEDIT4
[HKEY_CLASSES_ROOT\org-protocol]
@="URL:Org Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\org-protocol\shell]
[HKEY_CLASSES_ROOT\org-protocol\shell\open]
[HKEY_CLASSES_ROOT\org-protocol\shell\open\command]
@="\"C:\\Windows\\System32\\wsl.exe\" /snap/bin/emacsclient \"%1\""
@Spike-Leung
Spike-Leung / check-font-is-loaded.js
Last active December 15, 2023 09:22
Check if font has loaded
// see: https://www.zhangxinxu.com/wordpress/2022/04/js-font-face-load/
// see: https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace
import fontUrl from 'fonts/SourceHanSansSC-Regular.otf'
function check() {
try {
const font = new FontFace('SourceHanSansSC-Regular', `url(${fontUrl})`)
await font.load()
// load success
} catch (e) {
@Spike-Leung
Spike-Leung / zip.md
Last active December 4, 2023 17:56
zip

zip recursively and encrypt and ignore node_modules, .git and some other files

# exclude files should be full path to the files if PATH_TO_SOURCE_FILES is not the root path of exclude files
$ zip -re PATH_TO_TARGET PATH_TO_SOURCE_FILES  -x "node_modules/*" ".git/*"

# example
$ zip -re "$HOME/git/demo.zip" .  -x "node_modules/*" ".git/*" "test/*" ".husky/*"
@Spike-Leung
Spike-Leung / json-convert-xlsx.ts
Last active March 10, 2023 07:09
Convert json to xlsx
/**
* input.json looks like:
*
* { "name": "name" }
*/
// @deno-types="https://cdn.sheetjs.com/xlsx-0.19.2/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-0.19.2/package/xlsx.mjs';
import { readFileSync } from "https://deno.land/[email protected]/node/fs.ts";
// 读取 JSON 文件
const data = readFileSync('./input.json', 'utf-8')