Regex to remember.
find:
^( *)// *([a-z])
| 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 |
| 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) |
| 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 |
| 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): |
| ~^*-*^~ | |
| |† , †| | |
| | / \ | | |
| \/ † \/ | |
| '\_/' |
| # 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', |
| 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 |
| 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, |