Skip to content

Instantly share code, notes, and snippets.

@schilli91
schilli91 / tf_get_parameter_count_of_graph.py
Last active September 4, 2018 15:25
Calculates the parameter count required in the current graph.
# https://stackoverflow.com/questions/38160940/how-to-count-total-number-of-trainable-parameters-in-a-tensorflow-model
total_parameters = 0
for variable in tf.trainable_variables():
# shape is an array of tf.Dimension
shape = variable.get_shape()
# print("{}: {}".format(variable.name, shape))
variable_parameters = 1
for dim in shape:
variable_parameters *= dim.value
# print(variable_parameters)
@schilli91
schilli91 / tensorboard_smoothing.py
Created November 27, 2018 14:09
Applies smoothing according to Tensorboard to exported .csv files.
import csv
def tf_smooth_csv(in_file, out_file, smoothingWeight=0.6):
count = 0
last = -1
with open(in_file) as csvfile:
with open(out_file, 'w') as out:
reader = csv.DictReader(csvfile, delimiter=',')
writer = csv.DictWriter(out, fieldnames=["Step", "Value"])
@schilli91
schilli91 / md_parser.py
Last active December 13, 2018 12:36
converts a markdown string to html and then to pdf
from markdown2 import Markdown
import pdfkit
GITHUB_CSS = "a.anchor,ol,ul{padding-left:30px}dl dt,table tr th{font-weight:700}body{font-family:Helvetica,arial,sans-serif;font-size:14px;line-height:1.6;background-color:#fff;padding:30px}body>:first-child{margin-top:0!important}h1 p,h2 p,h3 p,h4 p,h5 p,h6 p,ol :first-child,ul :first-child{margin-top:0}body>:last-child{margin-bottom:0!important}blockquote>:last-child,dl dd>:last-child,dl dt>:last-child,ol :last-child,table tr td :last-child,table tr th :last-child,ul :last-child{margin-bottom:0}a{color:#4183C4}a.absent{color:#c00}h1,h2{color:#000}blockquote,h6{color:#777}a.anchor{display:block;margin-left:-30px;cursor:pointer;position:absolute;top:0;left:0;bottom:0}dl,dl dt,dl dt:first-child,hr,table,table tr{padding:0}h1,h2,h3,h4,h5,h6{margin:20px 0 10px;padding:0;font-weight:700;-webkit-font-smoothing:antialiased;cursor:text;position:relative}h1:hover a.anchor,h2:hover a.anchor,h3:hover a.anchor,h4:hover a.anchor,h5:hover a.anchor,h6:hover a.anchor{background
% standalone um Bild zu rendern
% Fuer standalone luatex85
% \RequirePackage{luatex85}
% \documentclass{standalone}
\documentclass{article}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{tikz}
\usetikzlibrary{graphdrawing, graphs, backgrounds, fit, positioning, calc, arrows}
\usegdlibrary{layered}
https://github.com/pyenv/pyenv/issues/94
On MacOS you may need to set some env. vars. in order for the pyenv installation to pick up the homebrew tcl-tk. Check your brew info tcl-tk's caveats section for the exact values you should use.
pyenv uninstall 3.8.1
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"
export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"
pyenv install 3.8.1
@schilli91
schilli91 / scheduler.py
Created May 4, 2020 13:55
Schedules a notification every second and runs it in background thread.
import threading
from time import sleep
import schedule
class Notifier(threading.Thread):
def __init__(self):
super(Notifier, self).__init__()
#!/bin/bash
alias ducks='du -cks * | sort -rn | head'
#!/bin/bash
git config --global alias.ll 'log --oneline --graph --all '
git config --global alias.st 'status '
git config --global remote.origin.prune true
git config --global rerere.enabled=true
git config --global core.editor=vim
git config --global core.pager=less -F -X
git config --global diff.wsErrorHighlight all
# Credit:
# https://stackoverflow.com/a/34467298/6180150
# https://stackoverflow.com/a/9074343/6180150
[alias]
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
@schilli91
schilli91 / clear_jenkins_build_history.groovy
Last active November 17, 2020 12:41
Delete Jenkins build history
# https://superuser.com/questions/1418885/clear-jenkins-build-history-clear-build-yesterday/1418896
def jobName = "JOB_NAME"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()