Skip to content

Instantly share code, notes, and snippets.

View algmyr's full-sized avatar

Anton Älgmyr algmyr

  • Zürich
View GitHub Profile
@algmyr
algmyr / descramble.py
Last active July 1, 2023 09:54
descramble.py
import heapq
from collections import defaultdict
from dataclasses import dataclass
import sys
from typing import DefaultDict, Optional
import numpy as np
from PIL import Image, ImageDraw
CELL_WIDTH = 96
@algmyr
algmyr / sd.py
Last active April 21, 2023 18:43
SD web api
import base64
import sys
from io import BytesIO
import requests
from PIL import Image
class Client:
struct FastI {
char cur;
char tmp[1 << 8];
#ifdef _WIN32
char nextChar() {
return cur=_getchar_nolock();
}
#else
static constexpr int BUFSIZE = 1<<14;
import json
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.lines as mlines
import seaborn as sns
sns.set(style="dark")
# Data
@algmyr
algmyr / table.py
Created April 19, 2019 20:07
Python table
class Content:
def __init__(self, *args):
self.data = args
def sizes(self):
return [len(str(x)) for x in self.data]
def __len__(self):
return len(self.data)
class Header(Content):
def layout(self, style):
@algmyr
algmyr / test.sh
Created October 23, 2018 21:14
Simple hackable test script
#!/bin/bash
mode="$1"
if [[ "$mode" == "perf" ]]; then
cmd="$2"
i=0
while true
do
echo "Test $((i+=1))"
python gen.py > gendata
@algmyr
algmyr / pdf.rb
Last active July 27, 2018 10:31
Kramdown syntax highlighting hack
# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#
require 'prawn'
@algmyr
algmyr / keybase.md
Created August 21, 2016 02:16
keybase.io

Keybase proof

I hereby claim:

  • I am algmyr on github.
  • I am algmyr (https://keybase.io/algmyr) on keybase.
  • I have a public key whose fingerprint is 55EA 962C DA3D 118E B919 03F5 EB61 05ED 9DA2 5435

To claim this, I am signing this object: