Skip to content

Instantly share code, notes, and snippets.

@GrantTrebbin
GrantTrebbin / rectangleBuilder.py
Created January 17, 2017 13:49
Create and Arrange Rectangles with relationships.
# rectangleBuilder
# Grant Trebbin - 2017_01_17
import svgwrite
class Rectangle:
def __init__(self, rectangle_width, rectangle_height):
# Calculate coordinates for corners and middle of sides for rectangle
# These are offset from the bottom left
@GrantTrebbin
GrantTrebbin / IndexingDemo_BinaryVersion.py
Created March 16, 2017 12:59
Rendering Animations for Hilbert Curves - Undocumented Scratch Code
import svgwrite
import math
# mogrify -format gif *.svg
# gifsicle --scale 0.2 --delay=5 --loop --optimize=2 --colors=256 --multifile *.gif > OutGIF/out.gif
order = 3
number_of_index_bits = order * 2
number_of_elements = pow(2, number_of_index_bits)
x_offset = 130
@GrantTrebbin
GrantTrebbin / LockBox.py
Created May 19, 2017 10:23
Generate sequences to brute force locks with mechaincal pin codes. Works for locks where order of numbers in PIN doesn't matter and numbers can't be repeated.
from itertools import combinations, chain
# https://stackoverflow.com/questions/5920643/add-an-item-between-each-item-already-in-the-list
def intersperse(lst, item):
result = [item] * (len(lst) * 2)
result[0::2] = lst
return result
pins = []
@GrantTrebbin
GrantTrebbin / stl-surface.py
Created October 2, 2019 09:15
Generate a 3D model based on a 2D equation
# stl-surface.py
# Generate a 3D model based on a 2D equation
# The model will be rectangular with a flat base. The top surface is based on
# a provided equation in "surface_function". The file name can be set with the
# output_filename variable. The x and y width of the model and the grid spacing
# is defined by the following parameters.
# x_spacing
@GrantTrebbin
GrantTrebbin / pdfbind.tex
Created February 28, 2024 21:32
Resise PDF and add page numbers with LaTeX
% pdfbind.tex
\documentclass[10pt,a4paper,twoside]{report}
\usepackage[final]{pdfpages}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\fancyhead{} % clear header