Skip to content

Instantly share code, notes, and snippets.

View kevinkub's full-sized avatar

Kevin Kub kevinkub

View GitHub Profile
@kevinkub
kevinkub / scriptable-line-chart.js
Last active February 1, 2024 15:18
Simple line chart class for https://scriptable.app 📈
class LineChart {
// LineChart by https://kevinkub.de/
constructor(width, height, values) {
this.ctx = new DrawContext();
this.ctx.size = new Size(width, height);
this.values = values;
}
_calculatePath() {
@kevinkub
kevinkub / scriptable-tests.js
Created October 20, 2020 07:49
Scriptable bugs?
const widget = await createWidget()
if (!config.runsInWidget) {
await widget.presentSmall()
}
Script.setWidget(widget)
Script.complete()
async function createWidget(items) {
Location.setAccuracyToThreeKilometers()
const location = await Location.current()
@kevinkub
kevinkub / incidence.js
Last active June 27, 2023 12:53
COVID-19 Inzidenz-Widget für iOS innerhalb Deutschlands 🇩🇪
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
class IncidenceWidget {
constructor() {
this.previousDaysToShow = 31;
this.apiUrlDistricts = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=RS,GEN,cases7_bl_per_100k,cases7_per_100k,BL&geometry=${location.longitude.toFixed(3)}%2C${location.latitude.toFixed(3)}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
this.apiUrlDistrictsHistory = (districtId) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/ArcGIS/rest/services/Covid19_hubv/FeatureServer/0/query?where=IdLandkreis%20%3D%20%27${districtId}%27%20AND%20Meldedatum%20%3E%3D%20TIMESTAMP%20%27${this.getDateString(-this.previousDaysToShow)}%2000%3A00%3A00%27%20AND%20Meldedatum%20%3C%3D%20TIMESTAMP%20%27${this.getDateString(1)}%2000%3A00%3A00%27&outFields=Landkreis,Meldedatum,AnzahlFall&outSR=4326&f=json`
this.stateToAbbr = {
@kevinkub
kevinkub / debian-setup.sh
Last active June 16, 2023 08:58 — forked from chris-redbeed/debian-setup.sh
Sets up and hardens an Debian Linux server.
# Arch Linux Setup: https://gist.github.com/kevinkub/46ce7229ee4f17be710ddd7c5a80a3c3
# Change root password
echo "# Change password of root user"
passwd
# Change hostname
echo "# Change hostname"
hostname
sudo hostnamectl set-hostname $hostname
@kevinkub
kevinkub / auto-adopt-shelly.sh
Last active September 15, 2020 14:37
Sets macOS to continuously scan for new wifi networks. When a shell* wifi network appears, it tries to connect automatically. Afterwards the script checks for versioning information and performs multiple http requests to configure the shellys accordingly.
#!/bin/bash
#
# Automatically connects to Shelly-Wifis and performs the initial setup (on macOS).
while true; do
# Connect to Shelly wifi
echo "Started scanning for shelly Wifi networks"
shellySsid=""
while [ -z "$shellySsid" ]; do
shellySsid=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s | grep shelly | awk '{$1=$1};1' | grep -io '[a-zA-Z0-9\-]\{10,\}' | head -n 1)
@kevinkub
kevinkub / Arch Linux Setup.sh
Last active September 16, 2020 09:25
Sets up and hardens an Arch Linux server.
# See https://gist.github.com/chris-redbeed/b3cee239532cee25b2357b4225e7f791 for a Debian version of this script.
# Change root password
echo "# Change password of root user"
passwd
# Change hostname
echo "# Change hostname"
read hostname
hostname $hostname
@kevinkub
kevinkub / object-path.js
Created September 11, 2019 19:20
Sets the values of a javascript object or array using a chain of colon separated keys.
function set(obj, keyChain, value) {
var keys = keyChain.split('.');
var key = keys.shift();
while(keys.length) {
obj[key] = obj[key] || (isFinite(keys[0]) ? [] : {});
obj = obj[key];
key = keys.shift();
}
obj[key] = value;
}
from axolotl.tests.inmemoryaxolotlstore import InMemoryAxolotlStore, InMemoryIdentityKeyStore, InMemoryPreKeyStore, InMemorySessionStore, InMemorySignedPreKeyStore
from axolotl.sessioncipher import SessionCipher
from axolotl.util.keyhelper import KeyHelper
class Entity:
def __init__(self):
self.__sessionStore = InMemorySessionStore()
self.__preKeyStore = InMemoryPreKeyStore()
self.__signedPreKeyStore = InMemorySignedPreKeyStore()