Skip to content

Instantly share code, notes, and snippets.

View unarist's full-sized avatar

unarist unarist

View GitHub Profile
@unarist
unarist / audit.sc
Created August 1, 2024 16:22
npm audit の結果を依存パスと共に表示するやつ
//> using scala 3.3.1
//> using toolkit default
import os.RelPath
import upickle.default.*
opaque type PackageName = String
opaque type PackageVersion = String
opaque type Severity = String
opaque type ModulePath = String
@unarist
unarist / README.md
Last active June 4, 2024 06:00
NodeJSのWriteStreamで、細かいチャンク(というか空)を大量に書き込む前後で、rssとheapTotalの差が36MBから2.5GBに広がる話。

実行例

$ uname -a
Linux docker-desktop 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ node --version
v20.14.0
$ node mem.js
before write: rss: 40.05MB, heapTotal: 4.20MB, heapUsed: 3.53MB, external: 1.33MB
writing 0: rss: 42.77MB, heapTotal: 4.45MB, heapUsed: 3.87MB, external: 1.45MB
// ==UserScript==
// @name Toggl - Quick import
// @description (<mm><dd> )?(<hh><mm>(<description><hh><mm>)+ )+
// @namespace https://github.com/unarist/
// @version 0.1
// @author unarist
// @match https://www.toggl.com/app/timer
// @grant GM_registerMenuCommand
// @downloadURL https://gist.github.com/unarist/559e02233b5e5dc4859885041c076190/raw/toggl-quickimport.user.js
// ==/UserScript==
// structures are based on https://github.com/dotnet/runtime/blob/v6.0.7/src/libraries/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs
struct CodePageHeader {
char16 codePageName[16];
u16 version[4];
u16 codePage;
u16 byteCount;
u32 offset;
u16 unicodeReplace;
u16 byteReplace;
@unarist
unarist / index.html
Last active March 12, 2022 13:00
SpaceMouseを押すと青く光って音がなるやつ。要WebHID=Chromeのみ。
<ol>
<li>音声ファイルを選ぶ: <input type="file"></li>
<li><button>connect</button> を押してSpaceMouseを選んで接続する</li>
<li>押すと光って音がなる(Windowsとかだと Stop 3DxWare してからやるといい感じ)</li>
</ol>
<script>
let audioUrl = undefined;
document.querySelector('input').onchange = ({target}) => {
const file = target.files[0];
audioUrl = file ? URL.createObjectURL(file) : undefined;
@unarist
unarist / hid-inputs-viewer.html
Created February 22, 2022 13:17
WebHIDでInputReportをReportID別に眺めるやつ
<!-- inspired by https://nondebug.github.io/webhid-explorer/ -->
<!-- license: CC0 -->
<button>Connect HID device</button>
<script>
const t = (e,p) => Object.assign(document.createElement(e), p);
const addSection = (title) => {
const header = t("h3", {textContent: title});
const textarea = t("textarea", {
open System
open System.Windows.Automation
module Screen =
open System.Windows.Forms
open System.Drawing
let workingAreaFor (rect: System.Windows.Rect) =
let rect = new Rectangle(int rect.X, int rect.Y, int rect.Width, int rect.Height)
let workingArea = (Screen.FromRectangle rect).WorkingArea
new System.Windows.Rect(float workingArea.X, float workingArea.Y, float workingArea.Width, float workingArea.Height)
// ==UserScript==
// @name github - indent lines
// @namespace https://github.com/unarist/
// @version 0.1
// @description Tab/Shift+Tabでカーソル位置・選択行をインデント・アンインデント
// @author unarist
// @match https://github.com/*
// @grant none
// @downloadURL https://gist.github.com/unarist/a184bf5d936c82bed14007a56e8abfae/raw/github-indent-lines.user.js
// @run-at document-idle
@unarist
unarist / parse-ebml.ts
Last active February 7, 2021 18:39
DenoでEBMLパース
import { DOMParser, Element } from "https://deno.land/x/[email protected]/deno-dom-wasm.ts";
// https://github.com/ietf-wg-cellar/ebml-specification/blob/master/specification.markdown#ebml-header-elements
let elementDefs = [
{ path: "\\EBML", id: 0x1A45DFA3, type: "master" },
{ path: "\\EBML\\EBMLVersion", id: 0x4286, type: "uinteger" },
{ path: "\\EBML\\EBMLReadVersion", id: 0x42F7, type: "uinteger" },
{ path: "\\EBML\\EBMLMaxIDLength", id: 0x42F2, type: "uinteger" },
{ path: "\\EBML\\EBMLMaxSizeLength", id: 0x42F3, type: "uinteger" },
{ path: "\\EBML\\DocType", id: 0x4282, type: "string" },
// ==UserScript==
// @name gh - show approvals
// @namespace https://github.com/unarist
// @version 0.3
// @author unarist
// @match https://github.com/*
// @grant none
// @downloadURL https://gist.github.com/unarist/c45bd5e8102afe7ce27d757a87819ea4/raw/github-show-approvals.user.js
// @run-at document-idle
// @noframes