Skip to content

Instantly share code, notes, and snippets.

View hyrious's full-sized avatar
💤
lazy

hyrious hyrious

💤
lazy
View GitHub Profile
@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>
@hyrious
hyrious / package.jsonc
Created May 13, 2025 12:28
One config to save you 8MB of eslint dependencies.
"overrides": {
"eslint": {
// Only loaded for `--mcp`.
"@modelcontextprotocol/sdk": "npm:noop-package",
"zod": "npm:noop-package"
}
}
@hyrious
hyrious / mixin.ts
Created May 7, 2025 14:10
Ruby's `include` in JavaScript/TypeScript
function mixin(cls: Function, mod: Function) {
const proto = {
__proto__: Object.getPrototypeOf(cls.prototype)
}
Object.getOwnPropertyNames(mod.prototype).forEach(field => {
if (field == 'constructor') return;
proto[field] = mod.prototype[field]
})
Object.setPrototypeOf(cls.prototype, proto)
return cls
@hyrious
hyrious / finalurl.zsh
Last active April 25, 2025 15:17
Redirect URL from command line
alias finalurl="curl -o /dev/null -sILw '%{url_effective}'"
# Example usage:
# finalurl b23.tv/ovUaDM9 | sed -e 's/?.*//'
@hyrious
hyrious / react-context-portal.tsx
Created April 16, 2025 09:27
Skip possible nested context when passing React children.
import { createContext, use, useState } from 'react';
import { createPortal } from 'react-dom';
import { createRoot } from 'react-dom/client';
const Context = createContext<string>('')
function Test() {
const theme = use(Context)
return <div>"{theme}"</div>
@hyrious
hyrious / val-n.ts
Created April 14, 2025 05:49
Value Enhancer TSX
import { compute, isVal, setValue, subscribe, type ComputeGet, type ReadonlyVal } from 'value-enhancer';
type Value<T> = T | ReadonlyVal<T>;
type ValueOrList<T> = Value<T> | ValueOrList<T>[];
type ValueOrList2<T> = ValueOrList<T> | ValueOrList<ValueOrList<T>>;
type Element = HTMLElement | SVGElement;
type Attributes<T> = Partial<{
[K in keyof T]: T[K] extends Function ? never : T[K] extends object ? Attributes<T[K]> : Value<number | T[K] | undefined | null>;
}>;
type Children = ValueOrList2<Element | string | ObserverNode | undefined>;