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 / python_profiling.py
Last active February 5, 2024 02:13
Python profiling to chrome://tracing
#
# 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 December 19, 2018 13:16
SSH refresh in tmux & git force pull
# 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)'

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.

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 August 6, 2018 15:01
NVIDIA in docker-compose
# 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"
@bzamecnik
bzamecnik / extract_and_print_summary.py
Last active July 26, 2018 19:53
Example extractions from a invoice with tax details.
import rossum
exctracted = rossum.extract('invoice.pdf')
rossum.extraction.print_summary(exctracted)
{
"full_text": {
"name": "full_text",
"content": [
"SomaFM. com, LLC",
"Invoice",
"2180 Bryant Street",
"Suite 208",
"San Francisco, CA 94110",
"United States",
# https://rossum.ai/developers#sign-in
export ROSSUM_API_KEY="xxxxxxxxxxxxxxxxxxxxxx_YOUR_ELIS_API_KEY_xxxxxxxxxxxxxxxxxxxxxxx"
pip install rossum
# Submit invoice for processing and save extracted values to invoice.pdf.json.
rossum extract invoice.pdf
import pandas as pd
import rossum
extracted = rossum.extract('invoice.pdf')
# max score only:
df = pd.DataFrame.from_dict(extracted['fields'])
idx = df.groupby('name')['score'].idxmax()
print(df.iloc[idx][['name', 'value']].to_string(index=False))
# pip install rossum
import rossum
rossum.extract('invoice.pdf', 'invoice.json')