Skip to content

Instantly share code, notes, and snippets.

View finloop's full-sized avatar

Piotr Krawiec finloop

View GitHub Profile
@finloop
finloop / docker_output.py
Created June 22, 2022 17:42 — forked from oseme-techguy/docker_output.py
Docker Python logger output to stdout
import logging
from sys import stdout
# Define logger
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG) # set logger level
logFormatter = logging.Formatter\
("%(name)-12s %(asctime)s %(levelname)-8s %(filename)s:%(funcName)s %(message)s")
consoleHandler = logging.StreamHandler(stdout) #set streamhandler to stdout
'downloader/response_count': 2,
'downloader/response_status_count/200': 2,
'elapsed_time_seconds': 0.805264,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2021, 12, 19, 9, 29, 10, 427176),
'httpcompression/response_bytes': 62728,
'httpcompression/response_count': 2,
'log_count/DEBUG': 3,
'log_count/INFO': 11,
'memusage/max': 82173952,
@finloop
finloop / shell.nix
Created November 28, 2021 09:06
Nix-shell: Pycharm + mach-nix config (nixos)
let
pkgs = import <nixpkgs> { };
mach-nix = import (builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
ref = "master";
}) { python = "python38"; };
customPython = mach-nix.mkPython rec {
providers._default = "wheel,conda,nixpkgs,sdist";
requirements = builtins.readFile ./requirements.txt;
};
# Generated by Powerlevel10k configuration wizard on 2021-09-24 at 17:27 CEST.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 54401.
# Wizard options: compatible, unicode, lean, 24h time, 2 lines, dotted, left frame,
# light-ornaments, sparse, fluent, transient_prompt, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
# Tip: Looking for a nice color? Here's a one-liner to print colormap.
@finloop
finloop / animate.py
Last active September 5, 2021 18:54
Create matplotlib animations and save to mp4
import matplotlib.pylab as plt
from matplotlib import animation
FPS = 12
FRAMES = range(30,90) # iterator for animate function
FILENAME = 'basic_animation.mp4'
# Create fig and axes
fig, ax = plt.subplots(figsize=(20,10))
@finloop
finloop / analyze_clusters_by_frequency.py
Created August 13, 2021 13:39
Plot pie charts for each cluster to show how popular are different categories in each cluster.
import matplotlib.pyplot as plt
from math import ceil
# Parameters for data. I assume data is in df.
cluster_col = "cluster" # Column with clusters
group_by = "customer_city" # Metric to group by "city" etc.
n_first = 4 # Number of most popular entries of `group_by` in cluster to include
@finloop
finloop / mkv_to_mp3.sh
Created May 4, 2021 11:36
Convert all .mkv files in directory (recursive) to .mp3
#!/bin/bash
# Convert all .mkv files in directory (recursive) to .mp3
find . -type f -name "*.mkv" -print0 | parallel -0 ffmpeg -i {} -vn -c:a libmp3lame -y {.}.mp3;