Skip to content

Instantly share code, notes, and snippets.

View hyrious's full-sized avatar
💤
lazy

hyrious hyrious

💤
lazy
View GitHub Profile
import * as vscode from 'vscode';
import redent from 'redent';
export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('selfhost.pasteWithIndent', async () => {
const text = await vscode.env.clipboard.readText()
if (!text) return;
const editor = vscode.window.activeTextEditor
if (editor) {
@hyrious
hyrious / fs_watch.c
Created October 25, 2025 15:22
LLM wrote this.
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <stdio.h>
#define BUFFER_SIZE 4096
int main(int argc, char *argv[]) {
HANDLE hDir;
DWORD bytesReturned;
char buffer[BUFFER_SIZE];
// Chrome - NW.js
[
"navigation",
"event",
"onbeforexrselect",
"onbeforeinput",
"onbeforematch",
"onbeforetoggle",
"oncommand",
"oncontentvisibilityautostatechange",
@hyrious
hyrious / Default (OSX).sublime-keymap
Last active August 8, 2025 02:13
Copy diff without leading +
[
{ "keys": ["super+c"], "command": "copy_diff", "context": [{ "key": "selector", "operand": "source.diff", "operator": "equal", "match_all": true } ] }
]
@hyrious
hyrious / esbuild-plugin-scss-module.ts
Created August 3, 2025 14:58
Simple esbuild plugin to bundle ".module.scss" files.
import { Plugin } from 'esbuild'
import { default as Postcss } from 'postcss'
import { default as PostcssModulesPlugin } from 'postcss-modules'
import { compile, Options } from 'sass'
export type CSSModulesOptions = Parameters<typeof PostcssModulesPlugin>[0]
export interface CSSOptions {
/// https://github.com/css-modules/postcss-modules
modules?: CSSModulesOptions
@hyrious
hyrious / Default.sublime-commands
Created June 25, 2025 06:33
Add custom commands in Sublime Merge
[
{
"caption": "Cleanup Repo",
"command": "git",
"args": {"argv": ["gc"]}
},
{
"caption": "Sync main to origin/main",
"command": "git",
"args": {"argv": ["branch", "-f", "main", "origin/main"]}
@hyrious
hyrious / Merge.sublime-theme
Created June 23, 2025 13:26
Change theme font of Sublime Merge
{
"variables": {
"font_face": "更纱黑体 UI SC"
}
}
/// <reference types="vite/client" />
// The contents of index.html:
// <script src="./node_modules/source-map/dist/source-map.js"></script>
// <script type="module" src="/using-source-map-in-browser.ts"></script>
import * as esbuild from 'esbuild-wasm/esm/browser.js'
import wasmURL from 'esbuild-wasm/esbuild.wasm?url'
import sourceMapWasmURL from 'source-map/lib/mappings.wasm?url'
require "json"
require "fileutils"
require "cgi"
include FileUtils::Verbose
folder = 'C:\Users\hyrious\OneDrive\Apps\Violentmonkey' # <-- change to your backup folder place
index_file = 'Violentmonkey'
target = File.join __dir__, 'ViolentmonkeyExport'
mkdir_p target
@hyrious
hyrious / win32_scale.cpp
Last active June 7, 2025 12:22
Get Windows scale correctly (like 150%).
#pragma comment(lib, "user32")
#pragma comment(lib, "gdi32")
#pragma comment(lib, "shcore")
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <ShellScalingApi.h>
#include <Windows.h>
#include <cstdio>