Instantly share code, notes, and snippets.

View plot_directive.py
"""
A directive for including a matplotlib plot in a Sphinx document.
By default, in HTML output, `plot` will include a .png file with a
link to a high-res .png and .pdf. In LaTeX output, it will include a
.pdf.
The source code for the plot may be included in one of three ways:
1. **A path to a source file** as the argument to the directive::
View mask_creator.py
"""
Interactive tool to draw mask on an image or image-like array.
Adapted from matplotlib/examples/event_handling/poly_editor.py
"""
import numpy as np
# import matplotlib as mpl
# mpl.use('tkagg')
import matplotlib.pyplot as plt
View sample_optim.mop
package bob
import Modelica.Constants;
function mu
input Real t;
output Real y;
algorithm
y := 2.4*abs(cos(Constants.pi/12*t));
end mu;
View unambig_url_shortener.rb
#!/usr/bin/ruby
require 'digest'
#This function takes an input string, a desired hash length, and an attempt
#number. It returns a hash of the specified length encoded in an alphabet which
#is unambiguous in both upper and lower case. The attempt number should
#initially be 0. If the hash is found to conflict with a previous result, then
#the attempt number should be incremented and the function called again with the
#same input string and hashlen. If you have incremened attempt number an