Skip to content

Instantly share code, notes, and snippets.

View DrDougPhD's full-sized avatar

Doug McGeehan DrDougPhD

View GitHub Profile
@DrDougPhD
DrDougPhD / download_progress.py
Created July 12, 2016 00:32
Example code for a textual download progress bar.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
DESCRIPTION
Sample script to show progress of a large file download.
EXAMPLE
$ python download_progress.py
@DrDougPhD
DrDougPhD / try-catch-finally.tex
Created September 13, 2016 22:54
LaTeX Exception Handling Pseudocode (i.e. Try-Catch-Finally blocks) for the algorithmicx package
%% try-catch-finally.tex
%% Copyright 2016 Doug McGeehan <djmvfb@mst.edu>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
@DrDougPhD
DrDougPhD / .vimrc
Last active October 3, 2016 16:29
Here's my vimrc file. Dark background and appropriate highlighting, tabs appear the equivalent width of 2 spaces, syntax highlighting, and I don't know what that last line does exactly but it's dope.
set background=dark "color scheme for reading source code
set tabstop=2 "width of tabs should be equal to width of two spaces
set shiftwidth=2 "number of tabs entered for auto-indenting
set colorcolumn=80 "display right-hand-side verticle column as reminder of
" the maximum suggested width of source code
"set expandtab "replace new tabs with spaces
"retab "replace old tabs with spaces
syntax on
filetype indent plugin on
set hlsearch "when I'm searching, this will highlight what I'm searching for
@DrDougPhD
DrDougPhD / bookmarklet
Created September 27, 2016 21:56
Bookmarklet to populate your clipboard with preset text by clicking the bookmarklet.
javascript:(function()%7Bcctb_t%3Ddocument.createTextNode(%22Replace%20this%20text%20with%20the%20text%20you%20want%20copied!%22)%3Bdocument.body.appendChild(cctb_t)%3Bcctb_r%3Ddocument.createRange()%3Bcctb_r.selectNode(cctb_t)%3Bwindow.getSelection().addRange(cctb_r)%3Btry%7Bdocument.execCommand('copy')%7Dcatch(err)%7Bconsole.log('Clipboard%20Copy%20Text%20Bookmarklet%3A%20Error%20in%20copying.')%7Ddocument.body.removeChild(cctb_t)%3Bdelete%20cctb_r%3Bdelete%20cctb_t%7D)()
@DrDougPhD
DrDougPhD / template.py
Last active February 1, 2023 17:11
Skeleton for Python command line script, including argparse and logging
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
SYNOPSIS
python SCRIPT.py [-h,--help] [-v,--verbose]
DESCRIPTION
@DrDougPhD
DrDougPhD / try_catch_conversion.py
Created November 4, 2016 03:29
Convert a raw string into an appropriate datatype by using trial and error!
#!/usr/bin/env python3
from dateutil.parser import parse
def convert(value):
"""
Be aware that this script is likely very incomplete. For instance, I don't even consider float!
"""
if value.lower() == "true":
return True
@DrDougPhD
DrDougPhD / rename_google_wallet_statements.py
Created January 11, 2017 17:00
Rename Google Wallet statements to reflect their covered months.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
SYNOPSIS
python rename_google_wallet_statements.py
DESCRIPTION
@DrDougPhD
DrDougPhD / recover_disk_img.sh
Last active January 19, 2017 18:44
Quick 'n' dirty script to recover a disk image and write to a drive.
#!/usr/bin/env bash
#
# Automatically recover a backup to a destination drive.
# NOTE: Must be run as root.
#
# DEPENDENCIES
#
# Lziprecover - for decompressing possibly corrupted lzip archives.
# pv - for status of writing image to drive
# smartmontools - for printing out drive info, used as safety measure to
@DrDougPhD
DrDougPhD / lineheaderpadded.py
Last active February 13, 2017 17:43
Pretty line headers in Python - e.g. "-------------------------: Hello, World! :-------------------------"
#!/usr/bin/env python3
#
# Create pretty line headers, padded with dashes, equals, octothorpes, tildes,
# and whatever else you want.
#
# Examples:
#
# ==========================: Hello, World! :==========================
#
# ~~~~~~~~~~~~~~~: Error Messages:~~~~~~~~~~~~~~~
@DrDougPhD
DrDougPhD / show list
Created March 7, 2017 06:39
KMNR Shows that weren't being recorded previously
Hyvää Huomenta
DJ SunMetal
Stored in /var/www/HyvaaHuomenta
................................................................................
It's Quiet Hours
DJ Undecided
Stored in /var/www/ItsQuietHours
................................................................................
The Bat Signal
DJ Batman