Skip to content

Instantly share code, notes, and snippets.

View iczelia's full-sized avatar
❤️‍🔥

Kamila Szewczyk iczelia

❤️‍🔥
View GitHub Profile
@iczelia
iczelia / apt-log.txt
Created August 6, 2025 07:59
the world is a circus and i am the butt of the joke
#8 0.241 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#8 0.242
#8 0.442 Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
#8 0.524 Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
#8 0.525 Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
#8 1.352 Get:4 http://deb.debian.org/debian bookworm/main s390x Packages [8458 kB]
#8 2.105 Get:5 http://deb.debian.org/debian bookworm-updates/main s390x Packages [6928 B]
#8 2.883 Get:6 http://deb.debian.org/debian-security bookworm-security/main s390x Packages [241 kB]
#8 6.985 Fetched 8960 kB in 7s (1358 kB/s)
#8 6.985 Reading package lists...
@iczelia
iczelia / lz4-dec.c
Created August 2, 2025 21:38
my [losing] 40th ioccc entry, lz4 decoder supporting the cli tool frame format.
#define f(k)if(k==a)\
do k+=*p;while(*p++==a*a+30)
unsigned char*b,*m,*d,*p;k,c,y,x
,a=15,v,z=1<<31;g(){for(b=p;c=*p++
,k=c>>4,x=c&a,1;){f(k);d=mempcpy(d,
p,k);if(( p+=k)>=b+v)
break;y=*p ++;y|=*p\
++<<8;f(x)
;for(m=d-y
,x+=4;x--; *d++=*m++
@iczelia
iczelia / autocache
Created June 9, 2025 15:02
Cache autotools configurations.
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <mode> [configure-args...]"
exit 1
fi
SCRIPT="$0"
case "$SCRIPT" in
/*) DIR=$(dirname "$SCRIPT") ;;
*) DIR=$(cd "$(dirname "$SCRIPT")" && pwd) ;;
esac
@iczelia
iczelia / rfsb509.c
Created April 19, 2025 23:29
A high performance (~500MB/s) implementation of "Really fast syndrome-based hashing" (RFSB-509) by D. J. Bernstein, T. Lange, C. Peters, and P. Schwabe.
#include <emmintrin.h>
#include <stdint.h>
#include <stddef.h>
static const uint8_t matrix[16384] = {
0x66, 0xe9, 0x4b, 0xd4, 0xef, 0x8a, 0x2c, 0x3b, 0x88, 0x4c, 0xfa, 0x59, 0xca, 0x34, 0x2b, 0x2e, 0x47, 0x71, 0x18, 0x16, 0xe9, 0x1d, 0x6f, 0xf0, 0x59, 0xbb, 0xbf, 0x2b, 0xf5, 0x8e, 0x0f, 0xd3, 0xbc, 0xf1, 0x76, 0xa7, 0xea, 0xad, 0x80, 0x85, 0xeb, 0xac, 0xea, 0x36, 0x24, 0x62, 0xa2, 0x81, 0x4f, 0xfc, 0x69, 0x77, 0x2e, 0xd5, 0xa3, 0x36, 0xf4, 0x61, 0x5b, 0x45, 0x03, 0xc3, 0x48, 0x14,
0xf8, 0x32, 0x1c, 0xf1, 0x8e, 0xf5, 0xfe, 0x72, 0x7d, 0xd8, 0x2a, 0x5c, 0x1e, 0x94, 0x51, 0x41, 0x2f, 0x16, 0x48, 0xbc, 0x9d, 0x95, 0xc3, 0x7f, 0xee, 0x0f, 0xd7, 0x53, 0x79, 0xfb, 0x7e, 0x59, 0x97, 0x45, 0xd7, 0xb2, 0x19, 0x72, 0xb1, 0x0b, 0x39, 0x93, 0xcc, 0x5d, 0x2f, 0xdd, 0x78, 0x8c, 0xd2, 0x61, 0xfd, 0x7d, 0x57, 0x9b, 0x0d, 0x40, 0x33, 0xba, 0xf0, 0x6d, 0x4e, 0x35, 0xb9, 0x0e,
0x29, 0x2c, 0x02, 0xc5, 0xcb, 0x91, 0x63, 0xc8, 0x0a, 0xc0, 0xf6, 0xcf, 0x1d, 0xd8, 0xe9, 0x2d, 0xef, 0xcd, 0x22, 0x90, 0xb9, 0xae, 0xe1, 0x86, 0
#include <stdio.h>
#include <time.h>
void f(long u) {
char*ms="SunMonTueWedThuFriSatJanFebMarAprMayJunJulAugSepOctNovDec";
int t=u%86400,od=u/86400,y,d=od,m,a,mp;if(d>11016)y=100,d++;y+=(d=(4
*d+2877875)%146097|3)/1461;a=(d=d%1461/4+1)-307;m=((d*=5)-3)/153;if(
(mp=m+2)>11)mp-=12,y++;printf("%02d:%02d:%02d (UTC), %.3s %02d %.3s"
" %d (day %d)",t/3600,(t/60)%60,t%60,ms+3*((od+4)%7),(d+2-153*m)/5-1
,ms+21+3*m,y+1900,(a>=0?a:a+365)+(!(y&3)&&a<0)); }
int main(void) { f(time(NULL)); }
@iczelia
iczelia / kcrypt3.c
Last active January 26, 2025 20:50
// ---------------------------------------------------------------------------
// KCrypt3 - 3rd iteration of the KCrypt algorithm.
// Written on Sunday, 26th of January 2025 by Kamila Szewczyk.
// ---------------------------------------------------------------------------
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdlib.h>
// Feeling overwhelmed by "find the words in a grid" tasks for preschoolers?
// Look no further!
#include <leptonica/allheaders.h>
#include <tesseract/baseapi.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
@iczelia
iczelia / clos.cpp
Created November 15, 2024 00:44
kludge to convert a cpp-style closure into a c pointer, retains data in an external structure
namespace {
template <typename F, int I, typename L, typename R, typename ...A>
inline F convert(L&& l, R (*)(A...) noexcept(noexcept(::std::declval<F>()(::std::declval<A>()...)))) {
static thread_local L l_(::std::forward<L>(l));
static thread_local bool full;
if (full) {
l_.~L();
new (static_cast<void*>(&l_)) L(::std::forward<L>(l));
} else
@iczelia
iczelia / pgn.l
Created November 4, 2024 20:15
Flex scanner for PGN files.
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
enum {
TAG = 0x100, COMMENT, REGULAR_MOVE, PROMOTION_MOVE, SHORT_CASTLE, LONG_CASTLE,
R1_0, R0_1, R12_12, RSTAR, CONTINUATION_MOVE_NUMBER, MOVE_NUMBER
};
@iczelia
iczelia / ccg.c
Last active September 9, 2024 10:45
Compact Cyclic Generator - a fast non-cryptographic random number generator based on polynomial codes.
// Public Domain.
#include <stdint.h>
#include <stdio.h>
uint32_t s, b;
void ccg_seed(uint32_t seed) {
s = (b = seed ^ 0xAAAAAAAA) | 1;
}
uint32_t ccg_next() {
uint32_t b = s >> 31;
s <<= 1, s ^= b * 0xEDB88320;