Skip to content

Instantly share code, notes, and snippets.

View hyrious's full-sized avatar
💤
lazy

hyrious hyrious

💤
lazy
View GitHub Profile
// Reference: https://github.com/SukkaW/react-compiler-webpack
import fs from 'node:fs'
import babel from '@babel/core'
import BabelPluginReactCompiler from 'babel-plugin-react-compiler'
/** @returns {import('esbuild').Plugin} */
export function reactCompiler(options = {}) {
const filter = options.filter || /\.[jt]sx$/
const reactCompilerConfig = options.reactCompilerConfig || {}
@hyrious
hyrious / restore-desktop-ini.md
Last active May 10, 2024 00:10
restore desktop.ini if some guy messed them up

Take %UserProfile%\Desktop\desktop.ini for example.

  1. Create a desktop.ini file with content below and saved in UTF-16 LE with BOM. Hopefully notepad.exe has such choice to use the right encoding.
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21769
IconResource=%SystemRoot%\system32\imageres.dll,-183
@hyrious
hyrious / nodejs-on-exit.js
Created November 22, 2020 05:04
how to do something before exit in NodeJS
// only works when there is no task running
// because we have a server always listening port, this handler will NEVER execute
process.on("beforeExit", (code) => {
console.log("Process beforeExit event with code: ", code);
});
// only works when the process normally exits
// on windows, ctrl-c will not trigger this handler (it is unnormal)
// unless you listen on 'SIGINT'
process.on("exit", (code) => {
@hyrious
hyrious / index.js
Created January 24, 2019 09:47
electron exit to tray
const {
app,
BrowserWindow,
Menu,
Tray,
nativeImage,
ipcMain
} = require("electron");
let win, tray;
@hyrious
hyrious / lazy-load-pwsh-module.ps1
Created February 14, 2021 07:19
lazy load in powershell
$LazyLoadProfile = [PowerShell]::Create()
[void]$LazyLoadProfile.AddScript(@'
Import-Module posh-git
'@)
$LazyLoadProfileRunspace = [RunspaceFactory]::CreateRunspace()
$LazyLoadProfile.Runspace = $LazyLoadProfileRunspace
$LazyLoadProfileRunspace.Open()
[void]$LazyLoadProfile.BeginInvoke()
@hyrious
hyrious / subl-replace-comma.py
Created March 26, 2024 02:52
Replace chinese comma "," with ", " seaminglessly.
import sublime, sublime_plugin
have_a_rest = False
class FixCjkCommaListener(sublime_plugin.TextChangeListener):
def on_text_changed(self, changes):
global have_a_rest
if len(changes) != 1 or have_a_rest: return
c = changes[0]
if c.str != ',': return
@hyrious
hyrious / require-to-import.mjs
Last active March 23, 2024 02:33
plugin to get rid of '__require' in esbuild
var RequireToImportPlugin = {
name: 'require-to-import',
setup({ onResolve, onLoad, esbuild }) {
function matchBrace(text, from) {
if (!(text[from] === '(')) return -1;
let i, k = 1;
for (i = from + 1; i < text.length && k > 0; ++i) {
if (text[i] === '(') k++;
if (text[i] === ')') k--;
}
@hyrious
hyrious / Lezer.sublime-syntax
Created March 8, 2024 01:31
Lezer Parser Grammar in Sublime Text for Itself
%YAML 1.2
---
# - https://www.sublimetext.com/docs/syntax.html
# - https://lezer.codemirror.net/docs/guide/#writing-a-grammar
# - https://github.com/lezer-parser/generator/blob/main/src/parse.ts
file_extensions:
- grammar
name: Lezer
@hyrious
hyrious / RPGXP.txt
Last active February 18, 2024 06:48
RPG Maker Clipboard Data Dump
c246: RPGXP MAP (2142 bytes)
| Z\b<0><0><0x4>\b[\ao:\rRPG::Map<0x10>:\t@bgmo:<0x13>RPG::AudioFile\b:\f@volumeii:\n@name"<0>:\v@pitchii:<0x10>@tileset_idi<0x6>:\f@events{<0>:\t@bgso;\a\b;\biU;\t"<0>;\nii:<0x12>@autoplay_bgmF:\n@datau:\nTable<0x2><0x1c>\a<0x3><0><0><0><0x14><0><0><0><0xf><0><0><0><0x3><0><0><0><0x84><0x3><0><0><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x80><0x1><0x
@hyrious
hyrious / renew-gpgkey.md
Created January 23, 2024 08:44
Renew expired GPG key
$ gpg --list-secret-keys --keyid-format=long
sec   rsa4096/0123456789ABCDEF 2020-12-22 [SC] [expired: 2021-12-22]
      0123456789ABCDEF0123456789ABCDEF12345678
uid                 [ expired] hyrious <hyrious@outlook.com>

$ # ok, they key 0123456789ABCDEF has expired, let's edit it
$ gpg --edit-key 0123456789ABCDEF
gpg> expire