Skip to content

Instantly share code, notes, and snippets.

View khdlr's full-sized avatar
🌍

Konrad Heidler khdlr

🌍
View GitHub Profile
@khdlr
khdlr / sane_quiver.py
Created August 13, 2021 07:28
How to get sane arrow plotting in matplotlib
ax.quiver(x, y, dx, dy,
scale=1, scale_units='xy', angles='xy')
import torch
from torch.optim import *
def check_optimizer(optimizer_type, modify_grad=False):
testvar = torch.ones([])
testvar.requires_grad = True
if optimizer_type is SGD:
opt = optimizer_type([testvar], 1e-3)
@khdlr
khdlr / klib.py
Created April 12, 2017 12:45
File to automatically import in a Jupyter Notebook session to get to work quickly
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from IPython.display import display
from IPython import get_ipython
@khdlr
khdlr / pipeline.py
Created November 30, 2016 11:35 — forked from alexmacedo/pipeline.py
Unix pipeline pattern in python
#! /usr/bin/env python
class Pipeline(object):
def __init__(self):
self.source = None
def __iter__(self):
return self.generator()
def generator(self):
# Copy .iso to usb stick
dd bs=4M if=/*.iso of=/dev/sdx && sync
# Convert .pngs to .gif (imagemagick)
convert -delay 2 -layers OptimizePlus *.png anim.gif
# Rip CD into the current directory
abcde -xpPo vorbis -d /dev/disk/by-id/$drive # Specifying the device seems to result in faster rips