Skip to content

Instantly share code, notes, and snippets.

View hyrious's full-sized avatar
💤
lazy

hyrious hyrious

💤
lazy
View GitHub Profile
@hyrious
hyrious / github-raw-pdf.user.js
Created November 6, 2023 03:08
Open raw link for PDF files on GitHub.
// ==UserScript==
// @name GitHub PDF Raw Link
// @namespace raw-pdf.github.hyrious.me
// @match https://github.com/*
// @grant none
// @version 1.0
// @author hyrious
// @description Replace PDF file's link with its raw link
// @require https://cdn.jsdelivr.net/npm/selector-set@1.1.5/selector-set.js
// @require https://cdn.jsdelivr.net/npm/selector-observer@2.1.6/dist/index.umd.js
@hyrious
hyrious / mouse-wheel.c
Last active November 2, 2023 09:20
RGSS mouse wheel event through dll
// gcc -shared -Os -s -o a.dll -m32 mouse-wheel.c
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
HHOOK hook;
DWORD delta;
LRESULT CALLBACK LowLevelMouseProc(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam) {
if (wParam == WM_MOUSEWHEEL) {
MSLLHOOKSTRUCT *mouse = (MSLLHOOKSTRUCT *)lParam;
@hyrious
hyrious / inline-worker.html
Created September 14, 2023 02:24
a trick to embed javascript resource in html
<script id="worker" src="data:,">
// the empty "src" prevents code inside this block from being executed!
// this is the source code of the worker.
postMessage("Hello world!")
</script>
<script>
var blob = new Blob([document.getElementById('worker').textContent],
-Wall -Wextra -pedantic -Wimplicit-fallthrough -Wsequence-point -Wswitch-default -Wswitch-unreachable -Wswitch-enum -Wstringop-truncation -Wbool-compare -Wtautological-compare -Wfloat-equal -Wshadow=global -Wpointer-arith -Wpointer-compare -Wcast-align -Wcast-qual -Wconversion -Wwrite-strings -Wdangling-else -Wlogical-op
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="style.css">
<script src="favicon.js"></script>
<script src="theme.js"></script>
<title>Ruby Marshal Visualization</title>
<style>
import os from "node:os";
import fs from "node:fs";
import path from "node:path";
import cp from "node:child_process";
/**
* ```js
* rb_eval(`p 1`) => '1'
* ```
*/
var IDX = 256, HEX: string[] = [];
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
/**
* @param algorithm only "SHA-1", "SHA-256", "SHA-384", "SHA-512".
*
* **Note**: "SHA-1" is not recommended.
*/
export async function digestHex(algorithm: AlgorithmIdentifier, data: string | BufferSource): Promise<string> {
if (typeof data === "string") data = new TextEncoder().encode(data);
@hyrious
hyrious / env-paths-cli.mjs
Created August 22, 2023 07:10
Get env paths if a library is using `env-paths`.
console.log((await import('/usr/local/lib/node_modules/env-paths/index.js').then(e => e.default))(process.argv[2] || 'electron', {suffix: ''}))
@hyrious
hyrious / goto-npm-browser.user.js
Created August 10, 2023 09:30
Replace npm code tab with NPM Browser
// ==UserScript==
// @name Read the code in NPM Browser
// @namespace goto-npm-browser.hyrious.me
// @match https://www.npmjs.com/package/*
// @grant none
// @version 1.0
// @author hyrious
// @description Change the Code tab to goto https://hyrious.me/npm-browser
// ==/UserScript==
void function() {
@hyrious
hyrious / gh-pr-cm.sh
Last active August 8, 2023 05:20
Get current commit's PR url (to that commit)
echo "$(gh pr view --json url -q .url)/commits/$(git rev-parse --short HEAD)"