Skip to content

Instantly share code, notes, and snippets.

View sunsided's full-sized avatar
🇺🇦
#StandWithUkraine

Markus Mayer sunsided

🇺🇦
#StandWithUkraine
View GitHub Profile

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@sunsided
sunsided / resize_area.py
Created May 16, 2018 00:03
Resize an image such that the number of pixels is equal to a given value while keeping the aspect ratio.
def resize_area(size: Tuple[int, int], target_area: float) -> Tuple[int, int]:
"""
Calculates new dimensions with the same aspect ratio as the input
such that the total number of pixels is close to the specified target are.
:param size: The original size of the image.
:param target_area: The targeted number of pixels (e.g. 512*512).
:return: The new image size.
"""
w, h = size
@sunsided
sunsided / build-tf-all.md
Last active October 9, 2021 02:08
Build TensorFlow 1.8 with XLA, MKL, CUDA, cuDNN and TensorRT

Building TensorFlow from Source (non-interactive mode)

These scripts are meant to provide a starting point for easily (and automatically) building TensorFlow on different Ubuntu versions.

The scripts follow the schema:

  • build-tf-cudaX-cudnnY.sh
  • build-tf-nogpu-ARCHITECTURE.sh
@sunsided
sunsided / build.sh
Last active April 26, 2018 11:11
Building Boost for Anaconda Python 3.6
conda create -n boost python=3.6
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/anaconda3/envs/boost/include/python3.6m
./bootstrap.sh --prefix=boost_output --with-python=python3 --with-icu
./b2 -j9 toolset=gcc cxxflags="-std=c++14" link=static threading=multi --layout=tagged
@sunsided
sunsided / kubectl-resources.sh
Last active September 1, 2017 19:24
Get Kubernetes pod resource usage per node
#!/usr/bin/env bash
# https://github.com/kubernetes/kubernetes/issues/17512#issuecomment-304069458
set -euo pipefail
echo -e "Iterating...\n"
nodes=$(kubectl get node --no-headers -o custom-columns=NAME:.metadata.name)
for node in $nodes; do
echo "Node: $node"
kubectl describe node "$node" | sed '1,/Non-terminated Pods/d'
@sunsided
sunsided / gp.sh
Created August 24, 2017 14:00
kubectl color output: finally you can tell Pending from Running
# https://unix.stackexchange.com/a/10065
# if stdout is a terminal
if test -t 1; then
# see if it supports colors
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
@sunsided
sunsided / copy-k8s-secret-across-namespaces.sh
Last active August 10, 2017 14:41 — forked from simonswine/copy-k8s-resources-across-namespaces.sh
Copying kubernetes resources accross namespaces
kubectl get secrets secret-name -o json --namespace old | jq '.metadata.namespace = "new"' | kubectl create -f -
@sunsided
sunsided / floatpack.py
Created April 14, 2017 12:37
Packing an array of IEEE 754 single-precision floats into a string of bytes in Python
import argparse
import struct
import binascii
from base64 import b64encode
from typing import Union, Iterable
def main():
parser = argparse.ArgumentParser()
parser.add_argument('number', type=float, nargs='+', help='The number to convert.')
@sunsided
sunsided / find_avx.cmake
Last active April 12, 2017 16:05 — forked from UnaNancyOwen/find_avx.cmake
Check for the presence of AVX and figure out the flags to use for it.
# Check for the presence of AVX and figure out the flags to use for it.
macro(CHECK_FOR_AVX)
set(AVX_FLAGS)
include(CheckCXXSourceRuns)
set(CMAKE_REQUIRED_FLAGS)
# Check AVX
if(MSVC AND NOT MSVC_VERSION LESS 1600)
set(CMAKE_REQUIRED_FLAGS "/arch:AVX")
@sunsided
sunsided / dump_operations.py
Last active October 27, 2021 21:26
Listing operations in frozen .pb TensorFlow graphs in GraphDef format (see comments for SavedModel)
import argparse
import os
import sys
from typing import Iterable
import tensorflow as tf
parser = argparse.ArgumentParser()
parser.add_argument('file', type=str, help='The file name of the frozen graph.')
args = parser.parse_args()