Skip to content

Instantly share code, notes, and snippets.

View avlakin's full-sized avatar

Anton Lakin avlakin

View GitHub Profile
@avlakin
avlakin / nvidia-smi-gb.sh
Last active March 19, 2023 03:05
nvidia-smi-gb
nvidia-smi | awk '
BEGIN { FS=OFS="|" }
$0 ~ /MiB/ && $0 !~ /GPU Memory/ {
split($3, arr, /MiB *\//);
gsub(/[0-9.]+MiB *\//, sprintf("%2.2fGiB /", arr[1] / 1024), $3);
gsub(/[0-9.]+MiB/, sprintf("%2.2fGiB", arr[2] / 1024), $3);
print $1, $2, $3, $4;
next;
}
{ print }'
@avlakin
avlakin / plots.py
Last active December 29, 2019 08:54
Easy plot multiple images
def plt_gen(cols, nrows=1, figsize=[20,5]):
plt.clf()
fig, ax = plt.subplots(nrows=nrows, ncols=cols, figsize=figsize)
for i, axi in enumerate(ax.flat):
axi.set_title(i)
yield i, axi, lambda img: axi.imshow(img, cmap='gray', vmin=0, vmax=1)
plt.show()
@avlakin
avlakin / PyMarkov
Last active January 30, 2016 01:57 — forked from Slater-Victoroff/PyMarkov
Arbitrary ply markov constructor in python
# source for names https://www.sec.gov/rules/other/4-460list.htm
from collections import Counter
import cPickle as pickle
import random
import itertools
import string
def words(entry):
return [word.lower().decode('ascii', 'ignore') for word in entry.split()]
//-----------------------------------------------
// SPARK CORE CUSTOM PWM FREQUENCY EXAMPLE
//===============================================
// Define your own frequency below!
// PWM Glitch issue fixed, only sets up PWM once,
// ... thereafter sets duty cycle.
// This allows true 0 - 100% PWM.
// Copy this into a new application at:
// https://www.spark.io/build and go nuts!
//-----------------------------------------------