Skip to content

Instantly share code, notes, and snippets.

View alkemann's full-sized avatar

Alexander Morland alkemann

View GitHub Profile
@alkemann
alkemann / dataclass_basemodel.py
Created February 12, 2023 21:53
Dataclass with db in basemodel
import sqlite3
from contextlib import contextmanager
from util import BaseModel
from dataclasses import dataclass
from util import get_db
import dataclasses
from typing import Iterable
import logging
<?php
namespace alkemann\htmx;
class HtmxDetails
{
protected $is_htmx_request;
protected $is_boosted;
protected $current_url;
@alkemann
alkemann / Macros.md
Last active January 9, 2022 22:24
D100 Dungeon macros for Roll20.net

D100 macros

This strategy assumes that you have created (at least) two character sheets. You should make sure to make a "custom" character sheet for this game. You can use HTML and CSS to style it if you prefer, but it is not needed since we have the character sheet in the Google sheet ( https://docs.google.com/spreadsheets/d/1ty892ds1VMRs2l5GwFIiWR1_Ov8S5YeYdzm-bYu_e24/edit?usp=sharing ).

After having made two sheets, name one Player and the other Monster. In the sheet under the Attributes and abilities tab you can click the Add button to add any number of custom attributes. You must add all the ones that are mentioned in macros you will use, but it is perfectly ok for them to have no values (will be functionally the same as 0).

The macros look up values from both Player and Monster using a syntax like this @{ then character name then | followed by the attribute to look up and ends with }. So to look up the strength score (str) on the player, it will use @{Player|str}.

For each of the m

@alkemann
alkemann / day11.py
Created December 12, 2019 07:05
Advent of Code, a broken day 11
from lib import get_input
def intcode(input_values, ram, pos=0, rel_base=0):
p_per_op = {1: 2, 2: 2, 3: 0, 4: 1, 5: 2, 6: 2, 7: 2, 8: 2, 9: 1, 99: 0}
move_per_op = {1: 4, 2: 4, 3: 2, 4: 2, 5: 0, 6: 0, 7: 4, 8: 4, 9: 2, 99: 0}
wr_per_po = {1: True, 2: True, 3: True, 4: False, 5: False, 6: False, 7: True, 8: True, 9: True, 99: False}
while True:
op_str = str(ram[pos])
op = int(op_str[-2:])
@alkemann
alkemann / markdown.syntax.highlighter.patch
Created September 4, 2017 13:40
A Patch trying to fix markdown code blocks
Index: src/main/java/io/github/swagger2markup/markup/builder/internal/AbstractMarkupDocBuilder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/io/github/swagger2markup/markup/builder/internal/AbstractMarkupDocBuilder.java (date 1499692487000)
+++ src/main/java/io/github/swagger2markup/markup/builder/internal/AbstractMarkupDocBuilder.java (revision )
@@ -227,6 +227,20 @@
return listingBlock(replaceNewLines(text), null);
}
swagger: "2.0"
info:
version: "1.0.0"
title: "Swagger Petstore"
basePath: "/v2"
schemes:
- "http"
paths:
/pet:
post:
@alkemann
alkemann / unlocked.sh
Last active March 14, 2017 10:50
Punish people for unlocked laptops
echo '*/15 * * * * say `curl -s http://catfacts-api.appspot.com/api/facts |python -mjson.tool|grep facts -a1|tail -n1`' | crontab -
@alkemann
alkemann / FallingBodies.js
Last active March 5, 2017 00:32
P5.js with Matter.js .. click and hold to drop balls of various sizes
const engine = Matter.Engine.create(),
ground = new Ground(x = 200, y = 360, w = 600, h = 50, a = 0.2),
shelf = new Ground(x = 250, y = 150, w = 200, h = 30, a = -0.2);
var bodies = [], lastFrame, rad = 2;
function setup() {
createCanvas(400, 400);
frameRate(60);
stroke(200);
fill(150);
@alkemann
alkemann / Job.cs
Last active February 14, 2016 15:01
Worker AI picking jobs and moving to them using Coroutines without any Frame Update calls
using UnityEngine;
public class Job {
public GameObject site;
public float workload = 3f;
public Job (GameObject site, float workload) {
this.site = site;
this.workload = workload;
}
}
[color]
ui = auto
diff = auto
status = always
branch = always
interactive = always
[color "branch"]
current = 220
local = 222
remote = 106