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 / 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 / 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 / Farm.md
Last active July 10, 2021 17:49
Mysticat Sugarcane Farm Optimization

Mysticat Sugarcane Farm Optimization

Using Z3 to generate a slightly more optimal Minecraft sugarcane/water block layout compared to the farm presented by Mysticat in Top 3 Minecraft Sugarcane Farms at 7:32.

Original (190 sugarcanes):

Mysticat Sugarcane Farm, Original

Optimized (200 sugarcanes):

@ion1
ion1 / weechat-idlerpg.md
Last active April 24, 2022 16:51
IdleRPG bot login automation with WeeChat

IdleRPG bot login automation with WeeChat

Log in when joining the channel

/trigger addreplace libera_idlerpg_login_join signal libera,irc_in2_353 "${text} =~ ^. #idlerpg :(.+ )?@idlebot( |$)" "" "/msg -server ${server} idlebot login user password"

Log in when idlebot gains +o

@ion1
ion1 / hash_collision.py
Last active May 29, 2021 11:57
Finding a hash collision with z3
from itertools import cycle
from z3 import *
class NameGen:
def __init__(self, prefix):
self.prefix = prefix
self.count = 0
def gen(self):
@ion1
ion1 / dct.gmic
Created January 27, 2021 00:38
G'MIC code for plotting the DCT of an image
to_rgb
dct
abs
log
cut 0,8
normalize 0,255
@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