Skip to content

Instantly share code, notes, and snippets.

@shaperilio
shaperilio / gui_qt_playground.ipynb
Created December 9, 2022 17:39
Notebook to try out the functionality of `%gui qt`
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shaperilio
shaperilio / keyboard.py
Created February 11, 2021 17:09
Python 3 key input without enter key
#From https://stackoverflow.com/a/6599441/149506
import termios, fcntl, sys, os
def read_single_keypress():
"""Waits for a single keypress on stdin.
This is a silly function to call if you need to do it a lot because it has
to store stdin's current setup, setup stdin for reading single keystrokes
then read the single keystroke then revert stdin back after reading the
keystroke.
@shaperilio
shaperilio / .bashrc
Last active August 26, 2020 23:19
zsh and bash prompts to show git branch and date / time
# Set the prompt the way I want it.
# git branch name from https://medium.com/@thucnc/how-to-show-current-git-branch-with-colors-in-bash-prompt-380d05a24745
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
PS1='\u@\h:\w\[[\e[33m\D{%y-%m-%d %H:%M:%S}\e[0m\]]\e[42m\e[30m$(parse_git_branch)\e[0m % '
@shaperilio
shaperilio / profile.ps1
Last active April 27, 2021 20:06
Powershell prompt with date and git branch
# $profile.CurrentUserAllHosts
function prompt {
$host.ui.rawui.WindowTitle = ($pwd -split '\\')[-1] # Set the window title to the current directory.
# Now prepend the prompt with:
# 1. The date, with seconds,
Write-Host '' $(Get-Date -f "yyyy-MM-dd HH:mm:ss") '' -NoNewline -BackgroundColor Black -ForegroundColor Green
# 2. if in a git repo, the branch name,
@shaperilio
shaperilio / log_setup.py
Last active May 28, 2020 21:31 — forked from mbrengel/logging_example.py
Python Logging Setup
# Slightliy modified from this Gist:
# https://gist.github.com/mbrengel/c823baa45ed21dce86e8b8321c804bcf
# Modifications:
# 1. Pump everything to standard out
# 2. Make file logging optional.
# 3. Show module name instead of level.
# From the entry point of your program, simply do
# import log_setup
# log_setup.configure_logging()