Skip to content

Instantly share code, notes, and snippets.

View isotopp's full-sized avatar

Kristian Koehntopp isotopp

View GitHub Profile
@isotopp
isotopp / apps.php
Created December 12, 2013 09:45
I cut and pasted my https://play.google.com/store/account?purchaseFilter=apps into a text file, and got a file of the format #0: Trees for Cars by Leo Grand #1: 0,99 $ #2: December 11, 2013 #3: Complete #4: Android Apps #5: Transportation What I wanted were stats. Here we go...
#! /usr/bin/php
<?php
class AndroidApp {
#0: Trees for Cars by Leo Grand
#1: 0,99 $
#2: December 11, 2013
#3: Complete
#4: Android Apps
#5: Transportation
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();
@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
@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 / 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 / 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 / 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
#! /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 / 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
@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()