Skip to content

Instantly share code, notes, and snippets.

View IdlePhysicist's full-sized avatar
🕳️
Code Pothole

᚛ᚓᚑᚌᚐᚅ᚜ IdlePhysicist

🕳️
Code Pothole
View GitHub Profile
@IdlePhysicist
IdlePhysicist / cave-log.tex
Last active September 10, 2020 12:30
LaTeX templates for Pandoc
%!TEX TS-program = xelatex
%
% Latex template for my cave logs
% Eoghan, 2019
%
\documentclass[11pt]{article}
%
% Setup for the Typewriter look
@IdlePhysicist
IdlePhysicist / keybase.md
Created March 11, 2020 20:23
Identity proof for Keybase.

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@IdlePhysicist
IdlePhysicist / wait-for-input.py
Created October 2, 2019 20:48
A simple python script for *NIX to wait for terminal input.
def getch():
import sys, tty, termios
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
@IdlePhysicist
IdlePhysicist / what-exceptions.py
Created August 6, 2019 23:44
Find out what exceptions are defined in a module.
# Where sqlite3 is the place holder for the module that you want to find the exceptions for.
import sqlite3, inspect
print( [name for name, value in vars(sqlite3).items() if inspect.isclass(value) and issubclass(value, Exception)] )
@IdlePhysicist
IdlePhysicist / yesorno.py
Created July 22, 2019 18:09
Simple user prompt function
CHOICE = {'yes': {'yes', 'y', ''}, 'no': {'no', 'n'}}
def YorN(text):
"""
This method prompts the user for an answer to a question.
`text` should be the prompt to that the user responds to.
"""
answer = input(f'{text} [Y/n] ').lower()
if answer in CHOICE['yes']:
return True
@IdlePhysicist
IdlePhysicist / md2pdf.sh
Created May 28, 2019 23:52
.md -> .pdf
#!/bin/bash
pdf () {
pandoc $1 -s --template cave-log.tex \
-o ${1%.*}.pdf --latex-engine=xelatex
}
xerox () {
convert -density 150 ${1%.*}.pdf \
-rotate 0.5 \