Skip to content

Instantly share code, notes, and snippets.


Richard Barnes r-barnes

View GitHub Profile
r-barnes /
Last active Jan 3, 2018
Modified plot_directive for matplotlib which preserves images between compilation
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
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::
r-barnes /
Last active Jul 20, 2020 — forked from tonysyu/
Tool to create polygon mask in Matplotlib
Interactive tool to draw mask on an image or image-like array.
Adapted from matplotlib/examples/event_handling/
import numpy as np
# import matplotlib as mpl
# mpl.use('tkagg')
import matplotlib.pyplot as plt
r-barnes / sample_optim.mop
Last active Sep 10, 2015
Sample Model for Syntax Highlighting
View sample_optim.mop
package bob
import Modelica.Constants;
function mu
input Real t;
output Real y;
y := 2.4*abs(cos(Constants.pi/12*t));
end mu;
r-barnes / unambig_url_shortener.rb
Last active Aug 29, 2015
Richard's Unambiguous URL Shortener
View unambig_url_shortener.rb
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
You can’t perform that action at this time.