Skip to content

Instantly share code, notes, and snippets.

View Kautenja's full-sized avatar
:octocat:
$(git status)

Christian Kauten Kautenja

:octocat:
$(git status)
View GitHub Profile
@Kautenja
Kautenja / fuse_normalize_into_conv2d.py
Created May 16, 2023 15:57
A PyTorch method for fusing normalization statistics directly into a convolutional layer
import torch
from torch.nn import Conv2d
@torch.no_grad()
def fuse_normalize_into_conv_2d(conv: Conv2d, mean: torch.Tensor, std: torch.Tensor) -> Conv2d:
"""
Fuse normalization statistics into a convolutional layer.
Args:
@Kautenja
Kautenja / cv2plot.py
Created August 19, 2022 22:05
A structure for rendering plots in the style of matplotlib using opencv.
"""Structures for real-time plot rendering using OpenCV."""
import cv2
import numpy as np
from matplotlib import pyplot as plt
class Plot:
"""A base structure for real-time plot rendering using OpenCV."""
def __init__(self, title: str,
@Kautenja
Kautenja / static_type.py
Created February 21, 2022 17:56
A wrapper for enforcing static typed inputs to python methods.
"""A python method wrapper to enforce static typing."""
import typing
from functools import wraps
import inspect
def static_type(function):
"""
Wrap a method with a guard condition to statically type input variables.
@Kautenja
Kautenja / .Xmodmap
Last active June 27, 2020 05:37
swap crtl and alt on ubuntu. place in home directory and execute: xmodmap ~/.Xmodmap
clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 64 = Control_L
keycode 105 = Alt_R
keycode 108 = Control_R
add control = Control_L Control_R
add mod1 = Alt_L Meta_L
@Kautenja
Kautenja / sftp_pandas.py
Last active January 6, 2023 04:39
Functions for working with remote files using pandas and paramiko (SFTP/SSH).
"""Functions for working with remote files using pandas and paramiko (SFTP/SSH)."""
import pandas as pd
import paramiko
def read_csv_sftp(hostname: str, username: str, remotepath: str, *args, **kwargs) -> pd.DataFrame:
"""
Read a file from a remote host using SFTP over SSH.
Args:
@Kautenja
Kautenja / sftp.py
Last active March 4, 2020 21:21
Simple SFTP functions using paramiko
"""Methods for working with files and remote hosts using SFTP."""
import paramiko
def sftp_get(hostname: str, username: str, remotepath: str, localpath: str):
"""
Read a file from a remote host using SFTP over SSH.
Args:
hostname: the remote host to read the file from
@Kautenja
Kautenja / hue_color.py
Created February 15, 2020 04:31
methods for changing between RGB and xyZ color space for Hue devices
"""Methods for converting color spaces for hue devices.
Reference: https://developers.meethue.com/develop/application-design-guidance/color-conversion-formulas-rgb-to-xy-and-back/
"""
from numba import jit
@jit(nopython=True)
def correct_xyz2rgb_gamma(channel):
@Kautenja
Kautenja / refresh-music-selection.scpt
Last active June 21, 2024 13:52
An applescript to refresh the metadata of a selection in the Apple Music application (with progress bar)
tell application "Music"
-- get the selection
set theSongs to selection
end tell
-- setup the progress bar
set theSongCount to length of theSongs
set progress total steps to theSongCount
set progress completed steps to 0
set progress description to "Refreshing Songs..."
@Kautenja
Kautenja / yamaha.css
Last active January 20, 2020 23:11
A stylesheet for Yamaha receiver web portals (Dark Mode)
/* Yamaha AV Receiver – Dark Mode */
.gr__receiver_local,
.gr__receiver_local body,
.gr__receiver_local div,
.gr__receiver_local span,
.gr__receiver_local font,
.gr__receiver_local h1,
.gr__receiver_local h2,
.gr__receiver_local h3,
@Kautenja
Kautenja / spotipi.css
Last active January 27, 2020 06:34
Styles to make emby look like Spotify
/*
EMBY THEME : spotipi
# Table of Contents
1. ACCENT COLORS
1.1 Buttons
1.1.1 Checkboxes
1.1.2 Rectangles
1.1.3 Links & Text buttons