Skip to content

Instantly share code, notes, and snippets.

View tmthydvnprt's full-sized avatar

Timothy Davenport tmthydvnprt

View GitHub Profile
@tmthydvnprt
tmthydvnprt / python_spirals.py
Created August 16, 2023 01:37
Python Spirals
from __future__ import division
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from scipy.special import fresnel
theta = np.linspace(0, 10 * np.pi, 1000)
# Archimedean Spiral
@tmthydvnprt
tmthydvnprt / notebook_code_toggle.py
Created January 1, 2017 13:33
Toggle code cells in jupyter notebooks
import IPython.core.display as di
# This line will hide code by default when the notebook is exported as HTML
di.display_html('<script>jQuery(function(){if(jQuery("body.notebook_app").length==0){jQuery(".input_area").toggle();jQuery(".prompt").toggle();}});</script>', raw=True)
# This line will add a button to toggle visibility of code blocks, for use with the HTML export version
di.display_html('<button onclick="jQuery(\'.input_area\').toggle();jQuery(\'.prompt\').toggle();">Toggle code</button>', raw=True)
@tmthydvnprt
tmthydvnprt / crosspickler.py
Created December 11, 2016 18:51
Convert a directory of pickle objects to be cross platform
import sys
import glob
import cPickle as pickle
class ProgressBar(object):
"""Implements a comand-line progress bar"""
def __init__(self, iterations):
"""Create a progress bar"""
self.iterations = iterations
@tmthydvnprt
tmthydvnprt / asciibinaryhex.py
Last active December 10, 2016 11:59
ASCII <-> Binary <-> Hex
def string2bitstring(s=''):
return ''.join([bin(ord(x))[2:].zfill(8) for x in s])
def bitstring2string(b=None):
return ''.join([chr(int(x, 2)) for x in [b[i:i+8] for i in xrange(0, len(b), 8)]])
def string2bitlist(s=''):
return [bin(ord(x))[2:].zfill(8) for x in s]
def bitlist2string(b=None):
@tmthydvnprt
tmthydvnprt / davenport_coat_of_arms.txt
Created July 20, 2016 13:13
ASCII Davenport Coat of Arms
~^*-*^~
|† , †|
| / \ |
\/ † \/
'\_/'
@tmthydvnprt
tmthydvnprt / Gistionary.py
Last active August 22, 2021 21:35
Rad Python dictionaries to keep around
# Unicode Character to Letter Name
greek_alphabet = greek_alphabet_unicode_to_letter_name = {
u'\u0391' : 'Alpha',
u'\u0392' : 'Beta',
u'\u0393' : 'Gamma',
u'\u0394' : 'Delta',
u'\u0395' : 'Epsilon',
u'\u0396' : 'Zeta',
u'\u0397' : 'Eta',
u'\u0398' : 'Theta',
@tmthydvnprt
tmthydvnprt / base64image.py
Created March 24, 2016 11:41
create base64 image
import base64
with open("/path/to/your/image.png", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
print 'data:image/png;base64,'+encoded_string
@tmthydvnprt
tmthydvnprt / rememberegex.md
Last active February 14, 2016 19:35
Remeberegex - Regex to remember.

Remeberegex

Regex to remember.

Capitalize js comments and ensure one space

find:

^( *)// *([a-z])

@tmthydvnprt
tmthydvnprt / reset_rasberrypi_password.md
Last active January 10, 2016 15:09
Reset a forgotten raspberry pi password

Reset a forgotten raspberry pi password

  1. Using another computer, edit the cmdline.txt file in the boot partition to include this at the end of the line:
init=/bin/sh
  1. Boot again
  2. Become root
@tmthydvnprt
tmthydvnprt / textplot.py
Last active December 4, 2015 02:57
Text Plotting
def textplot(data,
kind='line',
width=100, height=None,
ymax=None, ymin=None, xmax=None, xmin=None,
margin=None,
yticks=5, xticks=10,
bar_padding=2,
bar_style='#',
line_styles=['*','+','-','x','o','·','•','^','˚','°','∞','∆'], gridstyle='˙', ystyle='|', xstyle='-',
title=1,