Skip to content

Instantly share code, notes, and snippets.

Loading
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 January 24, 2021 21:15
Tessellate a square with 45-60-75 degree triangles, monochrome
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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 November 12, 2020 10:56
Kepler's Laws Ellipse
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / substring_palindromes.py
Created April 10, 2019 21:10
Substring palindromes
#!/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 April 10, 2023 23:08
Cubic Bezier tracks with constant speed animation, using Tkinter
#!/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 October 7, 2018 09:31
Use Tkinter's .after method to run several named counters in parallel.
#!/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 August 17, 2018 10:20
Discrete catenary with vectors
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / cat0.svg
Created August 13, 2018 14:48
Some discrete catenaries
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / cheney.py
Last active August 28, 2022 13:18
Generalization of the 'Fitch' Cheney card trick
#! /usr/bin/env python3
''' Generalization of the 'Fitch' Cheney card trick
Written by PM 2Ring 2003.02.13
Converted to Python 2018.06.27
'''
import sys
import readline