Skip to content

Instantly share code, notes, and snippets.

Bohumír Zámečník bzamecnik

Block or report user

Report or block bzamecnik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bzamecnik
bzamecnik / cdwifi.sh
Created Sep 17, 2019
Accept ČD Wifi on the command line (if you hate clicking). http://cdwifi.cz
View cdwifi.sh
#!/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
curl -s \
-o /dev/null \
-w "%{http_code}\n" \
-b 'user.email=eula@accepted' \
http://cdwifi.cz/portal/api/vehicle/gateway/user/authenticate?url=http://cdwifi.cz/ \
| grep -q 307 \
@bzamecnik
bzamecnik / floyd_steinberg_dithering.py
Created Aug 6, 2019
Floyd-Steinberg dithering in Python (quite fast via Numba JIT)
View floyd_steinberg_dithering.py
# 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 Apr 4, 2019
Allows to compare data in two DataFlows, eg. for regression tests.
View tensorpack_compare_data.py
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 Mar 9, 2019
Power saving mode for NVIDIA GTX 980 Ti.
View power_saving_mode_for_nvidia_gtx_980_ti.md

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 Mar 1, 2019
Example of basic MNIST Keras model with tf.Dataset
View mnist_dataset_api.py
# 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:
@bzamecnik
bzamecnik / python_profiling.py
Last active Jan 14, 2019
Python profiling to chrome://tracing
View python_profiling.py
#
# Example of how to profile a Python app with multiple processes
# by logging events and opening the resulting trace file in chrome://tracing.
#
# pip install multiprocessing_logging
from functools import wraps
import json
import logging
@bzamecnik
bzamecnik / .profile
Created Dec 19, 2018
SSH refresh in tmux & git force pull
View .profile
# refresh SSH socket after reconnect to tmux (useful with ssh agent forwarding)
alias ssh_refresh='export $(tmux show-environment | grep "^SSH_AUTH_SOCK")'
# list current git branch
alias git_current_branch='git branch | grep \* | cut -d " " -f2'
# force pull (after rebase in remote)
alias git_pull_force='ssh_refresh && git fetch && git reset --hard origin/$(git_current_branch)'
View perfect_tuner_privacy.md

Perfect Tuner - Privacy terms

This app uses microphone to analyze tones from your musical intstrument and help you with tuning it.

It does not store or transmit your audio anywhere.

Period.

View docker_compose_in_gitlab.md

How not to run docker-compose in .gitlab-ci.yml?

Official docker-compose docs recommend this installer:

curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Curl is not available in docker:lastest image, so let's use wget.

@bzamecnik
bzamecnik / docker-compose.yml
Created Aug 6, 2018
NVIDIA in docker-compose
View docker-compose.yml
# based on https://github.com/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#do-you-support-docker-compose
# it indeed works :)
# minimum syntax version to support the "runtime" keyword
version: "2.3"
services:
# show the system information about GPUs
smi:
image: "nvidia/cuda:9.1-base"
You can’t perform that action at this time.