Skip to content

Instantly share code, notes, and snippets.

View Flushot's full-sized avatar
👀

Chris Lyon Flushot

👀
View GitHub Profile
@Flushot
Flushot / log_progress.py
Created July 30, 2025 23:53
Python logger: In-place updating progress bar
import time
import logging
from tqdm import tqdm
LOG = logging.getLogger(__name__)
log_interval = 5
cursor_up = r'\033[A' # CSI -> A (Cursor up) https://en.wikipedia.org/wiki/ANSI_escape_code
if __name__ == '__main__':
@Flushot
Flushot / cpu_count
Last active June 6, 2025 21:12
Get logical CPU count in a platform-independent way
#!/bin/bash
os="$(uname -s)"
case $os in
Darwin*|BSD*) sysctl -n hw.ncpu;; # macOS, BSD
Linux*) nproc --all;; # Linux
Solaris*) psrinfo -p;; # Solaris
Win*|CYGWIN*|MINGW*|MSYS_NT*) echo "$NUMBER_OF_PROCESSORS";; # Windows
*) >&2 echo "unsupported os: $os"; exit 1;; # Unsupported
esac
@Flushot
Flushot / vimeo_download.py
Last active August 31, 2022 06:24
Vimeo video downloader
#!/usr/bin/env python
# Run: pip install argparse requests tqdm
# Requires 'ffmpeg' is also installed on your system
import os
import sys
import base64
import tempfile
import subprocess
import io
import shutil
LOG_FORMAT = '%(asctime)s %(levelname)-5.5s [%(name)s.%(funcName)s][%(threadName)s] %(message)s'
@Flushot
Flushot / create_user.sql
Created May 6, 2021 06:29
Postgresql: Create user and database
create user USERNAME with encrypted password 'PASSWORD';
create database DB with owner = USERNAME;
grant all privileges on database DB to USERNAME;
@Flushot
Flushot / postgresql.py
Last active May 6, 2021 05:46
Wrapper for psycopg2 that handles connection pooling, transactions, cursors, and makes the API easier to deal with
"""
PostgreSQL database utilities.
Wrapper for psycopg2 that handles connection pooling, transactions, cursors, and makes the API
easier to deal with.
"""
from collections import defaultdict
import contextlib
import logging
import re
@Flushot
Flushot / Trie.h
Last active November 5, 2019 23:47
Simple Trie
#ifndef HD_TRIE_H
#define HD_TRIE_H
#include <map>
#include <string>
#include <vector>
/**
* Trie data structure.
*
@Flushot
Flushot / finalcut_lowres_video_transcode.sh
Created June 1, 2019 07:38
Transforms Final Cut Pro master file into lower res MP4
#!/bin/sh
ffmpeg -i $1.mov -vf "scale=iw/2:ih/2" -vcodec libx264 -crf 20 $1.mp4

Keybase proof

I hereby claim:

  • I am flushot on github.
  • I am flushot (https://keybase.io/flushot) on keybase.
  • I have a public key ASDsNJlQBU8PQkSdKncgPmt6de9uafuQgjd7lzNGmyBHDwo

To claim this, I am signing this object:

@Flushot
Flushot / ascii_graph.sh
Created September 11, 2018 17:44
Convert *.graphml to an ASCII graph
#!/bin/sh
# brew install graphviz cpanminus
# cpanm Graph::Easy
graphml2gv ${1:-/dev/stdin} | graph-easy -