Skip to content

Instantly share code, notes, and snippets.

View pzelasko's full-sized avatar
🌴
Building stuff!

Piotr Żelasko pzelasko

🌴
Building stuff!
View GitHub Profile
@pzelasko
pzelasko / defer_with_example.cpp
Last active September 7, 2016 19:03
Go-like defer in C++
#include <iostream>
#include <string>
namespace impl {
template <typename Fun> struct DeferredWrapper
{
Fun f_;
DeferredWrapper(Fun &&f) : f_{std::forward<Fun>(f)} {}
~DeferredWrapper() {
f_();
@pzelasko
pzelasko / i3-shell.sh
Created January 16, 2018 14:03 — forked from viking/i3-shell.sh
Bash script for i3 to run a terminal in the same working directory as the current focused application
#!/bin/bash
# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152
CMD=gnome-terminal
CWD=''
# Get window ID
ID=$(xdpyinfo | grep focus | cut -f4 -d " ")
# Get PID of process whose window this is
@pzelasko
pzelasko / dirsync
Last active October 3, 2018 12:06
Shell utility for continuously synchronizing two directories (possibly local and remote)
#!/bin/sh
if [ $# -ne 2 ]; then
echo "Usage:"
echo "dirsync <source> <target>"
fi
while inotifywait -r -e modify,create,delete "$1"; do
rsync -avz "$1" "$2"
done
@pzelasko
pzelasko / setup_zsh.sh
Last active April 22, 2021 14:48
Set up a server with ZSH
#!/bin/bash
# default zsh
#sudo chsh -s /bin/zsh pzelasko
# oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# syntax checker
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${HOME}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
@pzelasko
pzelasko / lab_sanity.py
Last active October 11, 2023 14:56
Jupyter sanity
%load_ext autoreload
%autoreload 2
# conda install pandas numpy matplotlib jupyterlab
# pip install lhotse torch
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
@pzelasko
pzelasko / build_tf_serving_centos7.sh
Last active May 8, 2021 09:26
Build TensorFlow Serving 1.14 on CentOS 7
#!/bin/bash
# Requires Python 3.6 virtualenv
source ~/venv36/bin/activate
# Java
sudo yum -y install java-1.8.0-openjdk-devel
# Build Esentials (minimal)
sudo yum -y install gcc gcc-c++ kernel-devel make automake autoconf swig git unzip libtool binutils
@pzelasko
pzelasko / parsync
Last active May 19, 2023 02:55
Parallel rsync for downloading a directory from remote server
#!/bin/bash
host="$1"
source_dir="$2"
target_dir="$3"
ssh "$host" ls "$source_dir" | parallel -j8 -v --sshdelay 0.2 rsync -raz --progress "$host":"$source_dir"/{} "$target_dir"/{}
@pzelasko
pzelasko / fancy_logging.py
Last active March 30, 2020 21:38
Enable fancy logging
import logging
from sys import stdout
def fancy_logging(level=logging.DEBUG, stream=stdout):
logging.basicConfig(
level=level,
format="[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s",
datefmt="%H:%M:%S",
stream=stream
)
@pzelasko
pzelasko / gist:41d46cef4fd43caaa8eb8efbef7d4137
Created May 17, 2020 21:27
Very poor man's English text normalization
sed "/[[:punct:]]*/{ s/[^[:alnum:][:space:]'-]//g}" | tr '[:upper:]' '[:lower:]' | grep -v '[0-9]'
@pzelasko
pzelasko / interactive_audio_plots.py
Created June 9, 2020 20:16 — forked from scottire/interactive_audio_plots.py
Interactive and clickable plots using Panel, Holoviz and Bokeh in Jupyter Notebooks
import numpy as np
import panel as pn
pn.extension()
import holoviews as hv
hv.notebook_extension("bokeh")
# hv.extension('matplotlib')
from holoviews.streams import Stream, Params
from scipy.io import wavfile
from scipy.signal import spectrogram