Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Kub kevinkub

View GitHub Profile
View scriptable-line-chart.js
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() {
View scriptable-tests.js
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 Nov 27, 2020
COVID-19 Inzidenz-Widget für iOS innerhalb Deutschlands 🇩🇪
View incidence.js
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
// Thanks to @rphl (https://github.com/rphl) and @tzschies (https://github.com/tzschies) for their inspiring work on this widget. See https://gist.github.com/rphl/0491c5f9cb345bf831248732374c4ef5 and https://gist.github.com/tzschies/563fab70b37609bc8f2f630d566bcbc9.
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/RKI_COVID19/FeatureServer/0/query?where=IdLandkreis%20%3D%20%27${districtId}%27%20AND%20Meldedatum%20
@kevinkub
kevinkub / debian-setup.sh
Last active Nov 1, 2020 — forked from chris-redbeed/debian-setup.sh
Sets up and hardens an Debian Linux server.
View debian-setup.sh
# 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 Sep 15, 2020
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.
View auto-adopt-shelly.sh
#!/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 Sep 16, 2020
Sets up and hardens an Arch Linux server.
View Arch Linux Setup.sh
# 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 Sep 11, 2019
Sets the values of a javascript object or array using a chain of colon separated keys.
View object-path.js
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;
}
View libaxolotl_simple_demo.py
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()
You can’t perform that action at this time.