Skip to content

Instantly share code, notes, and snippets.

@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 / ntp.erl
Created April 12, 2010 10:17
Parsing IPv4/UDP/NTP packets in Erlang
parse_ip (Packet) ->
case Packet of
<<4:4, HeaderLength:4, _DiffServ:8, _Length:16, _Identification:16,
_Flags:3, _FragOffset:13, _TTL:8, Protocol:8, _HeaderChecksum:16,
SrcAddr:32/bits, DstAddr:32/bits, OptionsAndData/bytes>>
->
OptionsLength = HeaderLength*32-160,
<<_Options:OptionsLength, Data/bytes>> = OptionsAndData,
case Protocol of
@ion1
ion1 / default.pa
Last active August 18, 2021 18:21
PulseAudio “night mode” (high-pass filter and limiter) for ~/.pulse/default.pa
.include /etc/pulse/default.pa
load-module module-ladspa-sink sink_name=ladspa_limiter sink_properties=device.description="Limiter" master=alsa_output.pci-0000_00_14.2.analog-stereo plugin=fast_lookahead_limiter_1913 label=fastLookaheadLimiter control=12,0,2
load-module module-ladspa-sink sink_name=ladspa_eq sink_properties=device.description="Equalizer\ and\ Limiter" master=ladspa_limiter plugin=mbeq_1197 label=mbeq control=-24,-24,-24,0,0,0,0,0,0,0,0,0,0,0,0
set-default-sink ladspa_eq
@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 / 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 / rtorrent.rc
Created April 22, 2010 20:40
rtorrent.rc
# http://libtorrent.rakshasa.no/wiki/RTorrentRatioHandling
ratio.enable =
ratio.min.set = 200
ratio.max.set = 0
ratio.upload.set = 0
system.method.set = group.seeding.ratio.command, d.close=, d.erase=
# Link when finished.
system.method.set_key = event.download.finished, link_finished, "execute = mkdir, -p, ../done; execute = cp, -al, --, $d.get_base_path=, ../done/"
@ion1
ion1 / 0README.md
Last active August 30, 2020 08:04
What is inside Haskell IO?

What is inside Haskell IO?

<lambdabot> shachaf says: getLine :: IO String contains a String in the same
            way that /bin/ls contains a list of files

There are multiple ways IO could be implemented internally. Here’s a demonstration of one.

MiniIO (below) implements an ADT of arbitrarily chosen primitives that represent I/O operations and a way to combine them. One can create, evaluate and manipulate MiniIO values without causing any side effects to occur. That is what example in Main.hs does. The same applies to real IO values in Haskell: you can create a big list of print "hello"s and later pick which ones to actually execute.

@ion1
ion1 / EinsteinsRiddle.hs
Created June 11, 2020 14:30
"Einstein's Riddle" in Ersatz
#!/usr/bin/env stack
{- stack
--resolver lts-15.15
script
--package ersatz
-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RecordWildCards #-}
@ion1
ion1 / DragonJoustingRiddle.hs
Last active June 7, 2020 12:03
Dragon Jousting Riddle in Ersatz
#!/usr/bin/env stack
{- stack
--resolver lts-15.15
script
--package ersatz
--package containers
-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}