Skip to content

Instantly share code, notes, and snippets.

View khdlr's full-sized avatar
Watching the Arctic from above

Konrad Heidler khdlr

Watching the Arctic from above
View GitHub Profile
khdlr /
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 /
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 /
Created November 30, 2016 11:35 — forked from alexmacedo/
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