Skip to content

Instantly share code, notes, and snippets.

View jbaiter's full-sized avatar

Johannes Baiter jbaiter

View GitHub Profile
@jbaiter
jbaiter / 99-powerbank.rules
Last active January 11, 2021 21:38
Small script to inhibit charging when powering a USB-PD Thinkpad with a USB-C powerbank.
ACTION=="change", SUBSYSTEM=="power_supply", RUN+="/usr/local/sbin/powerbank"
#!/usr/bin/env python3
from __future__ import annotations
import html
import sys
from concurrent.futures import ProcessPoolExecutor, as_completed
from dataclasses import dataclass
from enum import Enum
from itertools import chain
from multiprocessing import cpu_count
String anonymizeIp(def ip) {
if (ip.contains(':')) {
try {
StringTokenizer tok = new StringTokenizer(ip, ':');
String firstGroup = tok.nextToken();
String secondGroup = tok.nextToken();
String thirdGroup = tok.nextToken();
return firstGroup + ":" + secondGroup + ":" + thirdGroup + ":0:0:0:0:0";
} catch (Exception e) {
return "0:0:0:0:0:0:0:0";
@jbaiter
jbaiter / azul.lua
Created April 12, 2020 09:16
TableTop Simulator: Scripted Azul
--[[ Lua code. See documentation: https://api.tabletopsimulator.com/ --]]
#include <vscode/console>
tileDiffuseUrls = {}
tileDiffuseUrls["http://cloud-3.steamusercontent.com/ugc/967597347416754435/BA4334969D1AD4E8B146AE7E7A1A430F14C7A5DA/"] = "yellow"
tileDiffuseUrls["http://cloud-3.steamusercontent.com/ugc/967597347419272946/C8F005A109AAD820E38A8E377F1026074B830401/"] = "turquois"
tileDiffuseUrls["http://cloud-3.steamusercontent.com/ugc/967597347419272641/EE644ECD0ADC6C78AC61E0C538BAF98FD8703908/"] = "red"
tileDiffuseUrls["http://cloud-3.steamusercontent.com/ugc/967597347419272833/D4C93372171EBA7604524C0E6B6DA29347B5209A/"] = "blue"
tileDiffuseUrls["http://cloud-3.steamusercontent.com/ugc/967597347419273056/A03D249CF12867EB4134A9A7E9A9D2A1632EE704/"] = "black"
(function ($){
$.ElucidateEndpoint = function (options) {
jQuery.extend(this, {
token: null,
container: options.container,
url: options.url,
dfd: null,
// OA list for Mirador use
annotationsList: [],

class: center, middle

Modernes JavaScript

Teil I: Basics


Agenda

  1. Deklaration von Variablen
  2. Funktionen
@jbaiter
jbaiter / solrstats
Last active July 12, 2018 05:30
Print size distribution of your Solr index
#!/usr/bin/env python3
# coding=utf8
"""
CFE file layout:
Header:
CodecHeader:
Magic [4byte uint32]
Codecname [?byte String]
Version [4byte uint32]
@jbaiter
jbaiter / sigil.sh
Last active May 16, 2018 20:54
Wrapper script around Sigil to support version control workflows. Change $SIGIL to match your system's settings.
#!/bin/bash
# USAGE
# =====
# $ sigil.sh <directory>
# Change this to match your system
SIGIL="/usr/local/bin/sigil"
# --------------------------------
.window-manifest-navigation > .mirador-btn.mirador-icon-download {
color: #929191;
margin-right: 5px;
width: 30px;
}
.window-manifest-navigation > .mirador-btn.mirador-icon-download:hover {
color: black;
}
import json
import logging
import sys
import time
from pathlib import Path
from gensim.models.fasttext import FastText
from gensim.models.word2vec import Text8Corpus