Skip to content

Instantly share code, notes, and snippets.

@PM2Ring
PM2Ring / merger_splitter1.svg
Created Feb 4, 2021
Merger-splitter diagram
View merger_splitter1.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / MathJaxTable.py
Created Jan 31, 2021
Simple MathJax table maker, using SageMathCell
View MathJaxTable.py
class Table:
def __init__(self, align, data):
self.buff = []
self.make(align, data)
def get(self):
s = "\n".join(self.buff)
return s + "\n\\end{array}"
def put(self, s):
View SquareTriTessBW.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / SquareTriTessBW.svg
Created Jan 24, 2021
Tessellate a square with 45-60-75 degree triangles, monochrome
View SquareTriTessBW.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View T-tet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / KeplerEllipse2.svg
Created Nov 12, 2020
Kepler's Laws Ellipse
View KeplerEllipse2.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View substring_palindromes.py
#!/usr/bin/env python3
''' Substring palindromes
Find the number of ways a string can be split in a non-overlapping way
such that p+q is a palindrome string. Two pairs (p,q) and (p',q') are
treated as different iff p is chosen from different position from p' or
q is chosen from diff position of q' .
For example, take the string abba. The possible substrings which are
@PM2Ring
PM2Ring / tk_bezier_track.py
Last active Oct 10, 2018
Cubic Bezier tracks with constant speed animation, using Tkinter
View tk_bezier_track.py
#!/usr/bin/env python3
''' Create a closed track from cubic Bezier curves, and animate a circle
following the track at constant speed.
https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B%C3%A9zier_curves
https://gist.github.com/PM2Ring/d6a19f5062b39467ac669a4fb4715779
Press the Add button to add black control dots to the Canvas. The first
@PM2Ring
PM2Ring / tk_multi_counters.py
Created Oct 7, 2018
Use Tkinter's .after method to run several named counters in parallel.
View tk_multi_counters.py
#!/usr/bin/env python3
""" Use .after to run several named counters in parallel.
Each counter prints its name and value to the terminal,
once per second.
When the 'New counter' button is clicked, a new
counter is created, using the name in `name_entry`, and
a 'Stop' button with the same name is added to the GUI.
@PM2Ring
PM2Ring / cat2.svg
Created Aug 17, 2018
Discrete catenary with vectors
View cat2.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.