Skip to content

Instantly share code, notes, and snippets.

View krisk0's full-sized avatar

Dagoth Ur krisk0

  • Valenvaryon, Nirn
View GitHub Profile
@krisk0
krisk0 / file_with_holes.py
Created July 1, 2026 05:37
Find files with zeroes inside, that occupy less space than they should
#!/usr/bin/python3
import os, sys
def find_sparse_files(start_path, top_n=50):
results = []
for dirpath, _, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
@krisk0
krisk0 / files_size.c
Created July 1, 2026 05:35
Calculate sum of files sizes, ingoring symbolic links
#define _XOPEN_SOURCE 500
#include <ftw.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static uint64_t total_size = 0;
static uint64_t file_count = 0;
@krisk0
krisk0 / dl_via_IO.pl
Created June 1, 2026 14:22
download file via perl IO module
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket::INET;
use IO::Socket::SSL;
my $proxy_host = 'proxy.boss.com';
my $proxy_port = 3128;
my $dest_host = 'github.com';
@krisk0
krisk0 / dl_via_LWP.pl
Created June 1, 2026 14:21
download file via perl LWP module
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $url = 'https://github.com/AUTHOR/REPOSITORY/archive/refs/heads/master.zip';
my $filename = '/tmp/main.zip';
my $ua = LWP::UserAgent->new;
@krisk0
krisk0 / private_key_via_hkdf.py
Created April 23, 2026 12:06
hkdf used to generate private key
import binascii, bit, hkdf
def make_key(seed: str):
kdf = hkdf.Hkdf(b'smth', seed.encode()).expand(b'else', 32)
private_key_hex = binascii.hexlify(kdf).decode()
key = bit.Key.from_hex(make_key('password'))
@krisk0
krisk0 / gist:f57c2d594534b8e37395bd264259e985
Created January 14, 2026 12:19
Unpack CK3 modification, only .txt and yml. Get rid of mod_files/
#!/bin/bash
[[ $2 == "" ]] && exit 1
[[ -s "$1" ]] || exit 1
7z x "$1" -o$2 -r '*.txt' '*.yml'
cd $2
for x in `find -type d -name mod_files` ; do
(
@krisk0
krisk0 / get_serial.py
Created December 2, 2025 09:13
Python subroutine that returns hard disk serial no
def get_serial():
# TODO: find where root is mounted (mmcblk1p2), get mmcblk1 by cutting off
# 2-byte tail
f = '/sys/block/mmcblk1/device/serial'
if os.path.isfile(f):
with open(f, 'rb') as i:
n = i.read().rstrip()
if n[:2] == b'0x':
n = n[2:]
return n
@krisk0
krisk0 / CK3_bugs_discovered_by_krisk0.md
Last active November 21, 2025 12:12
List of bugs in Crusder Kimngs III scripts discovered by me

List of bugs in CK3 discovered by me.

Note to Paradox Development Studio

I attempted to report bugs via paradoxplaza. Unfortunately forum admin or forum robot did not let me in, presumably because of my IP address geo-location. I therefore report problems here.

How I discovered the bugs

I did not intentionally analyze base game scripts. I found some bugs when creating my mods.

@krisk0
krisk0 / 3001.patch
Created November 7, 2025 11:49
patch to CK3 1.18.0.2 script courtier_guest_management_events.txt
diff -purN a/courtier_guest_management_events.txt b/courtier_guest_management_events.txt
--- a/courtier_guest_management_events.txt 2025-11-07 14:38:00.000000000 +0300
+++ b/courtier_guest_management_events.txt 2025-11-07 14:43:52.000000000 +0300
@@ -918,10 +918,7 @@ courtier_guest_management.3001 = {
add = 150
}
modifier = {
- OR = {
- any_relation = { type = soulmate always = yes }
- is_married = yes
@krisk0
krisk0 / CK3_MOD_DRESS
Last active May 28, 2026 14:38
Automate CK3 .mod creation
#!/bin/bash
game_version=1.18
file_name=`find -maxdepth 1 -type d|grep -v '\.$'`
file_name=${file_name##./}
mod_name=`echo $file_name|sed 's:_: :g'`
mod_name=${mod_name^}