Skip to content

Instantly share code, notes, and snippets.

@piwwww
piwwww / printProgressBar.py
Created October 16, 2019 17:09
create terminal progress bar in Python
# Print iterations progress
# Ref: https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console/34325723#34325723
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required : total iterations (Int)
prefix - Optional : prefix string (Str)
suffix - Optional : suffix string (Str)
@piwwww
piwwww / 02_strip_header.sh
Created September 23, 2019 16:19
[template on shell script with file-ext validation]
#!/bin/sh
input_ext=".csv"
# simple check on input file extension
if [ "${1%$input_ext}" != $1 ]
then
header_file="${1%$input_ext}.header"
stript_file="${1%$input_ext}.noheader"
@piwwww
piwwww / jllocal.sh
Created January 14, 2019 17:14
Running Jupyter Lab Remotely (Local Part)
# tips from Ben Lindsay: http://benjlindsay.com/blog/running-jupyter-lab-remotely/
# This function does a few things when you type jllocal:
# Runs ssh tunneling command if it's not already running
# Grabs the Jupyter token from the remote machine
# Opens a tab in your browser with the right url and token for you
# When you're done with Jupyter Lab, you just type jllocal kill and it will shut down the ssh connection.
function jllocal {
@piwwww
piwwww / jlremote.sh
Last active January 14, 2019 17:10
Running Jupyter Lab Remotely (Remote Part)
# tips from Ben Lindsay: http://benjlindsay.com/blog/running-jupyter-lab-remotely/
alias jlremote='jupyter lab --no-browser --port=8888'
for f in *.tif; do mv -v --backup=numbered "$f" "dest/$(date -r $f +%Y%m%d-%H%M%S).tif"; done
@piwwww
piwwww / Command_Line_Arguments.py
Last active December 30, 2015 10:19
Tip #1. Using command line arguments.
#!/usr/bin/python
"""
$ test.py -h
usage: test.py -i <inputfile> -o <outputfile>
$ test.py -i BMP -o
usage: test.py -i <inputfile> -o <outputfile>
$ test.py -i inputfile