Skip to content

Instantly share code, notes, and snippets.

View isotopp's full-sized avatar

Kristian Koehntopp isotopp

View GitHub Profile
@isotopp
isotopp / bootstrap-prompt.txt
Created May 27, 2024 09:47
Storytelling ChatGPT instructions
You are a story writing assistant.
I will first give you a few facts about the persons and their situation and ask you to derive a few ground rules.
We will then plan story and character development options.
When I approve a plan of action by saying "Write it out", you will write the scene.
Craft a narrative using a minimalist style that emphasizes smooth narrative flow.
Employ simple, direct sentences, avoiding adverbs and complex syntactical structures.
Center the description on the protagonist's interaction with their environment,
aiming to subtly convey their emotional state through these interactions.
Descriptions should be concise, prioritizing observable details that suggest rather than elaborate on the character's feelings.
@isotopp
isotopp / keks.py
Created April 29, 2024 19:13
Unwrap Python
#! /usr/bin/env python3
from contextlib import contextmanager
class Keks:
def __init__(self):
self.a = 42
self.b = "Hallo Welt"
keks = Keks()
@isotopp
isotopp / mojibake.sql
Last active February 19, 2024 16:09
Fix Mojibake
--- the table.the_field contains mojibake
update the_table
set the_field =
case
-- conversion may fail, returning NULL. In this case, retain original data
when convert(cast(convert(the_field using latin1) as binary) using utf8mb4) is null then the_field
-- conversion success -> choose the demojibaked data
else convert(cast(convert(the_field using latin1) as binary) using utf8mb4)
end
#! /usr/bin/python3
import json
import pprint
count=0
with open("data.jsonl", "r") as f:
while (line := f.readline()) and count<3:
d = json.loads(line)
pprint.pprint(d)
@isotopp
isotopp / gist:1faafbd186666c39c9ba05602484d5d1
Created November 24, 2020 23:14
Trying to debug Hugo and my site
Rendering blog.koehntopp.info now takes 400s in Jekyll. That's too slow.
I can import the entire thing into hugo with `hugo import jekyll ~/Source/isotopp.github.io isotopp`
and get a hugo version of all.
That leaves me with the work to port Type-on-Strap to Hugo. But I do not
even understand how Hugo applies Templates and it is hard to debug.
kris@server:~/hugo/isotopp$ ~/Source/hugo/hugo version
Hugo Static Site Generator v0.79.0-DEV/extended linux/amd64 BuildDate: unknown
@isotopp
isotopp / s-lock-exploder.sql
Last active August 2, 2020 20:25
with referential integrity we get an s-lock explosion.
CREATE TABLE `c` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`parent` bigint unsigned DEFAULT NULL,
UNIQUE KEY `id` (`id`),
KEY `parent` (`parent`),
CONSTRAINT `c_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `c` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1
INSERT INTO `c` VALUES (1,NULL),(2,1),(3,1),(4,2),(5,2),(6,3),(7,3),(8,3);
@isotopp
isotopp / tree.sql
Created August 2, 2020 15:52
How can I collect a path?
mysql> show create table c\G
*************************** 1. row ***************************
Table: c
Create Table: CREATE TABLE `c` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`parent` bigint unsigned DEFAULT NULL,
UNIQUE KEY `id` (`id`),
KEY `parent` (`parent`),
CONSTRAINT `c_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `c` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1
@isotopp
isotopp / tasmota-configure.sh
Created June 9, 2020 14:34 — forked from ixs/tasmota-configure.sh
Tasmota mass configuration
#!/bin/bash
#
# Do initial configuration of a SP111 plug on your local wifi
#
# Licensed under the GPLv3+
#
TEMPLATE='{"NAME":"SP111 v1.1","GPIO":[56,0,158,0,132,134,0,0,131,17,0,21,0],"FLAG":0,"BASE":45}'
function uriencode {
@isotopp
isotopp / test.pl
Created January 7, 2019 15:18
Perl: Loop controls without loops
#! /usr/local/bin/perl --
#
# [kris:~] $ ./test.pl
# f1 start
# f2 start
# f3 start
# Exiting eval via next at ./test.pl line 26.
# Exiting subroutine via next at ./test.pl line 26.
# Exiting subroutine via next at ./test.pl line 26.
# f1 end
function filterByHeader(search, hdr_regex, labelname) {
var label = GmailApp.getUserLabelByName(labelname);
var cnt = 0;
var threads = GmailApp.search(search);
for (var j=0; j<threads.length; j++) {
thd = threads[j];
msgs = thd.getMessages();