Skip to content

Instantly share code, notes, and snippets.

Grant Trebbin GrantTrebbin

Block or report user

Report or block GrantTrebbin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@GrantTrebbin
GrantTrebbin / stl-surface.py
Created Oct 2, 2019
Generate a 3D model based on a 2D equation
View stl-surface.py
# 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 / QRBackup.sh
Last active Aug 7, 2019
How to encode and decode a file backed up as a series of printed QR codes
View QRBackup.sh
# How to encode and decode a file backed up as a series of printed QR codes
# Install the required tools
sudo apt-get update
sudo apt-get install zbar-tools imagemagick qrencode
################################################################################
# Convert the file to a base 64 encoded format. Probably not needed as QR codes
@GrantTrebbin
GrantTrebbin / IndexingDemo_BinaryVersion.py
Created Mar 16, 2017
Rendering Animations for Hilbert Curves - Undocumented Scratch Code
View IndexingDemo_BinaryVersion.py
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 / MailStat.py
Created Oct 19, 2015
Crudely analyse the emails in an mbox file to generate statistics
View MailStat.py
import mailbox
from email.header import decode_header
import re
import itertools
regex = re.compile('[^a-zA-Z0-9]')
words = []
for message in mailbox.mbox('Inbox.mbox'):
subject, encoding = decode_header(message['subject'])[0]
@GrantTrebbin
GrantTrebbin / LockBox.py
Created May 19, 2017
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.
View LockBox.py
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 / rectangleBuilder.py
Created Jan 17, 2017
Create and Arrange Rectangles with relationships.
View rectangleBuilder.py
# 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 / Backup.ps1
Last active Oct 30, 2016
Create encrypted and compressed backups only when warranted
View Backup.ps1
<#
.SYNOPSIS
Backs up and encrypts a directory or file
.DESCRIPTION
Backs up files or directories by adding it them a tar file and then
encrypting it with a public key. Becuase public key encryption is used
there are no passwords stored anywhere.
gpg must be installed and the public key you want to use must be imported.
@GrantTrebbin
GrantTrebbin / DirHash.ps1
Created Oct 15, 2016
Create fingerprints of directories and files that incorporate name and directory structure
View DirHash.ps1
function Hex_To_Bytes($hex){
# Takes a string with an even number of hexadecimal characters and
# converts it two characters at a time to an array of bytes half as long
# Initialize ouput byte array
$hexLength = $hex.Length
$byteLength = $hexLength / 2
$bytes = ,0 * ($byteLength)
# generate bytes by taking 2 hexadecimal characters at a time
View GenerateCards.py
import itertools as itt
from collections import deque
# Each element of a sequence can have these values
possible_elements = [0, 1, 2, 3, 4, 5, 6, 7]
element_count = len(possible_elements)
# A sequence contains this many elements
sequence_length = 4
@GrantTrebbin
GrantTrebbin / orderGraph.py
Created Feb 28, 2016
Visualizing Periodic Order Schedules
View orderGraph.py
import random
import math
import sqlite3
import numpy
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
def order_trajectory(base, colours, trajectory):
scale = 500
day_trajectory = trajectory / 24
You can’t perform that action at this time.