Skip to content

Instantly share code, notes, and snippets.

View kthy's full-sized avatar
💭
Was wird aus dem Loch wenn der Käs gefressen ist?

Kristian Thy kthy

💭
Was wird aus dem Loch wenn der Käs gefressen ist?
View GitHub Profile
@kthy
kthy / .bashrc
Created February 28, 2024 10:29
Bash setup @ SPARK
# add Windows host DNS entry
if ! $(cat /etc/hosts | grep -q 'winhost'); then
echo 'Adding DNS entry for Windows host in /etc/hosts'
echo '# Windows host - added via ~/.bashrc' | sudo tee -a /etc/hosts
echo -e "$(grep nameserver /etc/resolv.conf | awk '{print $2, " winhost"}')" | sudo tee -a /etc/hosts
fi
# configure Cargo
. "$HOME/.cargo/env"
@kthy
kthy / .bashrc
Created June 16, 2023 21:36
Add Windows host DNS entry in Ubuntu/WSL
if ! $(cat /etc/hosts | grep -q 'winhost'); then
echo 'Adding DNS entry for Windows host in /etc/hosts'
echo '# Windows host - added via ~/.bashrc' | sudo tee -a /etc/hosts
echo -e "$(grep nameserver /etc/resolv.conf | awk '{print $2, " winhost"}')" | sudo tee -a /etc/hosts
fi
@kthy
kthy / spooled_wrapper_fail.py
Created February 7, 2023 09:04
Spooled Wrapper Fail
from csv import DictReader, DictWriter
from io import TextIOWrapper
from tempfile import SpooledTemporaryFile
csv_lines = ["A;2;3", "B;4;6", "C;8;12"]
fieldnames = ["Foo", "Bar", "Baz"]
csv_reader = DictReader(csv_lines, fieldnames=fieldnames, delimiter=";")
with SpooledTemporaryFile(mode="w+b") as tmp:
with TextIOWrapper(tmp, encoding='utf-8') as wrapper:
writer = DictWriter(wrapper, fieldnames=fieldnames)
@kthy
kthy / .bashrc
Created November 17, 2022 08:59
Config for WSL@SPARK
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@kthy
kthy / live_streams.sii
Created October 26, 2022 21:56
ETS2 Radio Stations
SiiNunit
{
live_stream_def : _nameless.13d.c83f.e360 {
stream_data: 9
stream_data[0]: "https://live-bauerdk.sharp-stream.com/myrock_dk_mp3|myROCK|Rock|DA|112|0"
stream_data[1]: "http://live-icy.dr.dk/A/A29H.mp3|P6 Beat|Rock|DA|256|0"
stream_data[2]: "http://streams.radiobob.de/bob-metal/mp3-192/mediaplayer|Radio BOB Metal|Metal|DE|192|0"
stream_data[3]: "https://icecast.skyrock.net/s/natio_mp3_128k|Skyrock|Rock|FR|128|0"
stream_data[4]: "https://live-bauerno.sharp-stream.com/radiorock_no_mp3|Radio Rock|Rock|NO|0|0"
stream_data[5]: "https://stream.oneplay.no/rox128|Radio Rox|Rock|NO|128|0"
@kthy
kthy / app.js
Created June 9, 2022 09:35
Sequelize demo with custom schema
const dotenv = require('dotenv');
const express = require('express');
const { Sequelize, DataTypes } = require('sequelize');
dotenv.config();
const app = express();
const port = parseInt(process.env.APP_PORT) || 3000;
const pg_connection_details = {
database: process.env.PG_DATABASE,
set nocompatible
set expandtab
set tabstop=2
set shiftwidth=2
set number
set nobackup
set cursorline
set visualbell
autocmd BufEnter *.* setlocal indentexpr=
@kthy
kthy / brooks-the_craft.md
Last active January 7, 2022 22:47
The Joys of the Craft

Excerpt from chapter 1 of "The Mythical Man-Month"

The Joys of the Craft

Why is programming fun? What delights may its practitioner expect as his reward?

First is the sheer joy of making things. As the child delights in his mud pie, so the adult enjoys building things, especially things of his own design. I think this delight must be an image of God's delight in making things, a delight shown in the distinctness and newness of each leaf and each snowflake.

@kthy
kthy / lru_demo.py
Last active October 25, 2021 12:31
Python: Least-Recently-Used Cache Demonstration
"""Least-Recently-Used Cache Demonstration."""
from functools import lru_cache
@lru_cache(maxsize=5)
def powpow(input: int) -> int:
output = input**2
print(f"Computed: {output:3}", end=", ")
return output
@kthy
kthy / triangle.py
Last active July 15, 2021 09:41
TKT-DAP p01e20_usemodule
"""Triangle geometry functions."""
from math import sqrt
__version__ = '1.0.0'
__author__ = 'Kristian Thy <k@pyxy.dk>'
def hypothenuse(a: float, b: float) -> float:
"""Return the length of the hypothenuse when given the lengths of