Skip to content

Instantly share code, notes, and snippets.

@ion1
ion1 / promise-monad.js
Last active February 11, 2024 15:36
Testing JavaScript Promise monad laws
await (async () => {
function wrap(p) {
return p.then(
(res) => ["ok", res],
(err) => ["error", err]
);
}
async function compare(title, pa, pb) {
const a = await wrap(pa);
@ion1
ion1 / Capture Video Frame.md
Last active December 26, 2023 06:47
Capture Video Frame Bookmarklet
@ion1
ion1 / irc_formatting_characters.md
Created May 26, 2012 01:35
IRC formatting characters

IRC formatting characters

\x02bold
\x03color (mIRC extension, followed by FG or FG,BG where FG and BG consist of one or two digits)
\x0freset (mIRC extension)
\x12reverse
\x1funderline
@ion1
ion1 / base_grid.py
Last active September 20, 2023 03:25
Factorio Blueprints
from enum import Enum
from draftsman.blueprintable import Blueprint, BlueprintBook
from draftsman.entity import ElectricPole, Roboport, Radar, Lamp
from draftsman.tile import Tile
def main():
book = base_grid_book()
print(book.to_string())
@ion1
ion1 / ankiHebrewParse.js
Last active May 25, 2023 21:54
Convert "Hebrew frequency list: 10,000 most commonly used words" into Anki cards
/*
* Convert "Hebrew frequency list: 10,000 most commonly used words" into Anki cards.
*
* https://www.teachmehebrew.com/hebrew-frequency-list.html
* http://web.archive.org/web/20230320182549/https://www.teachmehebrew.com/hebrew-frequency-list.html
*
* Go to the page and run this script in the developer console.
*/
/*
@ion1
ion1 / PushToMute.ahk
Last active April 26, 2023 19:32
Push-to-mute using AutoHotKey
#Warn
#SingleInstance
SetWorkingDir(A_ScriptDir)
Component := ""
Device := "Analogue 1 + 2 (Microphone)"
Mute(State) {
OldState := SoundGetMute(Component, Device)
@ion1
ion1 / pixelate-rectangle.shader
Last active November 8, 2022 02:17
Censor a part of the screen (such as a chat window) by pixelation in obs-shaderfilter
// Censor a part of the screen (such as a chat window) by pixelation in
// obs-shaderfilter.
// https://obsproject.com/forum/resources/obs-shaderfilter.775/
// https://creativecommons.org/publicdomain/zero/1.0/
// To the extent possible under law, ion has waived all copyright and related
// or neighboring rights to obs-pixelate-rectangle. This work is published
// from: Suomi.
// https://gist.github.com/ion1/0e028ad096aa6f375bc9a97334639fa3
@ion1
ion1 / gps-pps-00A0.dts
Created August 4, 2013 21:52
Beagle Bone GPS PPS via GPIO
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
part-number = "gps-pps";
version = "00A0";
exclusive-use = "P8.4", "gpio1_7";
@ion1
ion1 / registry-search-replace.ps1
Created July 30, 2022 22:00
Registry search and replace
$Search = "E:\Music Production\"
$Replace = "D:\Music Production\"
function Confirm {
for (;;) {
Write-Host "[YNQ] " -NoNewline
$Key = [System.Console]::ReadKey().Key
Write-Host ""
switch ($Key) {
"Y" { return $true }
@ion1
ion1 / PeirceLEM.hs
Last active July 10, 2022 02:24
Exercise: prove Peirce’s law <=> law of excluded middle in Haskell
-- Exercise: prove Peirce’s law <=> law of excluded middle in Haskell
{-# LANGUAGE Rank2Types #-}
import Data.Void
type Not a = a -> Void
type Peirce = forall a b. ((a -> b) -> a) -> a
type LEM = forall a. Either (Not a) a