Skip to content

Instantly share code, notes, and snippets.

View bzamecnik's full-sized avatar

Bohumír Zámečník bzamecnik

View GitHub Profile
@bzamecnik
bzamecnik / keras_mnist_sequence.py
Last active June 30, 2021 13:30
Keras MNIST with Sequence - tracing with multiple processes
"""
Title: Simple MNIST convnet
Author: [fchollet](https://twitter.com/fchollet)
Date created: 2015/06/19
Last modified: 2020/04/21
Description: A simple convnet that achieves ~99% test accuracy on MNIST.
Modified:
- data wrapped as a Sequence
@bzamecnik
bzamecnik / github_code_review_full_repo.sh
Created June 10, 2021 12:06
GitHub - code review full repo
# In order to make a full repo code review, fork a repo and clone the fork.
# Then use this script to make a new empty base branch merge the current
# main branch into it for the sake of code review. Then open
# a pull request in GitHub: "review" <- "homework".
git checkout --orphan review
git rm -rf .
git commit --allow-empty -m "Create empty branch"
git push --set-upstream origin review
@bzamecnik
bzamecnik / evernote_10_redeemer.md
Last active November 16, 2020 11:18
How to extract missing note changes in Evernote 10

Two weeks after upgrade to Evernote 10 Mac I found that all my changes are lost!

This script helps to extract the missing notes.

Forums:

Evernote was showing that changes are saved but nothing was synchronized to other devices and most importantly upon app restart (or crash) everything returned to the state

@bzamecnik
bzamecnik / rename_git_remote_new_domain.sh
Created April 18, 2020 10:39
Rename Git remotes to new domain
for remote in $(git remote); do
old_url=$(git remote get-url "$remote")
new_url=${old_url//git.old.example.com/git.new.example.com}
if [ "$old_url" != "$new_url" ]; then
echo "$remote: $old_url -> $new_url"
git remote set-url "$remote" "$new_url"
else
echo "$remote: $old_url (already OK)"
fi
done
@bzamecnik
bzamecnik / zmikund.md
Created February 24, 2020 12:55
"Se stim smiř!" -- Zmikund. ASCII art

Se stim smiř! -- Zmikund

           +
         |\|/|
    O    |. ,|
    \    |vvv|
     \  /\/\/|   /_\
 \_/ + \ | /
@bzamecnik
bzamecnik / cdwifi.sh
Last active July 9, 2023 17:30
Accept ČD Wifi on the command line (if you hate clicking). http://cdwifi.cz
#!/bin/bash
# Accept CD Wifi (Czech railways) on the command line (if you hate clicking).
# http://cdwifi.cz
#
# Put the script to ~/bin/cdwifi and make sure that export it's on the path: PATH=$PATH:~/bin
# Note that if you have a custom DNS set (eg. 8.8.8.8 or 1.1.1.1) they don't resolve
# cdwifi.cz. If you don't want to use their DNS set via DHCP for all your traffic
# the workaround here is to query their DNS server at the gateway just
# for this request.
#
@bzamecnik
bzamecnik / floyd_steinberg_dithering.py
Created August 6, 2019 16:05
Floyd-Steinberg dithering in Python (quite fast via Numba JIT)
# https://en.wikipedia.org/wiki/Floyd–Steinberg_dithering
from numba import jit
import numpy as np
@jit(nopython=True)
def floyd_steinberg(image):
# image: np.array of shape (height, width), dtype=float, 0.0-1.0
# works in-place!
h, w = image.shape
for y in range(h):
@bzamecnik
bzamecnik / tensorpack_compare_data.py
Created April 4, 2019 10:35
Allows to compare data in two DataFlows, eg. for regression tests.
import numpy as np
from tensorpack import DataFlow
class CompareData(DataFlow):
"""
Compares that two DataFlows generate equal data, raises ValueError if not.
"""
def __init__(self, a, b):
self.a = a
@bzamecnik
bzamecnik / power_saving_mode_for_nvidia_gtx_980_ti.md
Created March 9, 2019 21:56
Power saving mode for NVIDIA GTX 980 Ti.

My NVIDIA GTX 980 Ti being idle eats 53 W (out of 250 W max). Here's how to put to to a power saving mode at 30 W consumption and keep it prepared to run at higher performance automatically when there's a computation running.

TL;DR

sudo nvidia-smi -pm ENABLED -i 0
sudo nvidia-smi -ac 405,135 -i 0
@bzamecnik
bzamecnik / mnist_dataset_api.py
Created March 1, 2019 20:42
Example of basic MNIST Keras model with tf.Dataset
# Example of basic MNIST Keras model with tf.Dataset
# More up-to-date version of: https://github.com/keras-team/keras/blob/master/examples/mnist_dataset_api.py
"""
MNIST classification with TensorFlow's Dataset API.
Introduced in TensorFlow 1.3, the Dataset API is now the
standard method for loading data into TensorFlow models.
A Dataset is a sequence of elements, which are themselves
composed of tf.Tensor components. For more details, see: