Skip to content

Instantly share code, notes, and snippets.

View tafaust's full-sized avatar
💻
Coding

Thomas Faust tafaust

💻
Coding
View GitHub Profile
@tafaust
tafaust / masternode_kill_processes.sh
Created June 23, 2017 08:55
Shell script to terminate all services started by DC/OS that run on the master node. Source: https://dcos.io/docs/1.9/installing/ports/
#!/usr/bin/bash
killall nginx 2>/dev/null && echo "Killing nginx service on ports 80, 443"
for port in {53,1050,1801,2181,5050,7070,8080,8123,8181,9990,15055,15101,15201}; do
kill -9 $(netstat -tlnp | awk "/:$port */ {split(\$NF,a,\"/\"); print a[1]}") 2>/dev/null && echo "Killing service that runs on port $port"
done
@tafaust
tafaust / hidraw_read.py
Created March 11, 2018 17:42
Debug hidraw through hipdapi in linux python 3.6
#!/usr/bin/env python
"""Debug hidapi python library and hid devices.
You may use this utility script for debugging purposes to check if this library does work as
intended, thus detecting all plugged hid devices.
This files does also provide you with the vendor_id and product_id required by the udev rule.
"""
@tafaust
tafaust / type_enforcement.py
Created March 13, 2018 10:04
Python 3.6 type «enforcement» (/ check) through annotations or custom list of types
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging.config
import functools
from typing import Callable, Union
__author__ = 'Thomas Hesse'
@tafaust
tafaust / main.dart
Created February 6, 2021 07:06
How to check if Dart List contains certain object instance?
class Book {
String title;
Book(this.title);
}
void main() {
List<Book> bookList = [
Book('foo'),
];
@tafaust
tafaust / toggletouchpad
Created February 21, 2021 07:14
Bash script to toggle touchpad state on X server
#!/bin/bash
# set your device name here (can be found through `xinput`)
touchpadDevice='SynPS/2 Synaptics TouchPad'
if [ ! -z "$1" ]; then
# set the device state via argument (must be 0 or 1)
devEnabled=$1
else
# toggle the device state
@tafaust
tafaust / debian_install_docker.sh
Last active March 23, 2022 17:33
Docker install script for debian
#!/usr/bin/env sh
# https://docs.docker.com/engine/install/debian/
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
apt-get remove docker docker-engine docker.io containerd runc
@tafaust
tafaust / development_time_check.py
Created February 12, 2022 08:24
Python run time vs development time dict key check
from typing import TypedDict
class Movie(TypedDict):
name: str
year: int
def foo(movie_params: Movie):
pass # do your thing
@tafaust
tafaust / application.py
Created April 21, 2022 19:41
FastAPI singleton service dependency injection across multiple requests
import random
import click
import uvicorn
from fastapi import FastAPI, APIRouter, Depends, Request
# Service
class MySingletonService:
def __init__(self):
@tafaust
tafaust / filter_obj_by_obj.js
Last active May 12, 2022 09:11
Javascript filter object by object with mutation
const a = [
{id: 1},
{id: 4},
{id: 8},
{id: 6},
];
const b = [
{id: 1, op: 'foo'},
{id: 2, op: 'abc'},
{id: 3, op: 'def'},

Keybase proof

I hereby claim:

  • I am tahesse on github.
  • I am tahesse (https://keybase.io/tahesse) on keybase.
  • I have a public key ASC5oB1TWSKfC3-p_ZDDJ3m5XEf0kGzJlapCX-Gm-pOSuQo

To claim this, I am signing this object: