Instantly share code, notes, and snippets.

# Grant TrebbinGrantTrebbin

• Sort options
Created May 10, 2015
Create a series of images to demonstrate weather related events using python and matplotlib
View si470x_log_processor.py
 #!/usr/bin/python import csv import sys from datetime import datetime import matplotlib.pyplot as plt import matplotlib.dates as mdates import matplotlib.image as image import matplotlib.lines as mlines import os.path
Created May 21, 2015
Compressing Similar PNG Images
View imCompress.py
 #!/usr/bin/python from PIL import Image import numpy import argparse import os import sys #Configure argument parser to take input arguments
Created Nov 3, 2015
A quick demonstration of the magnetic field of a circular current loop
View MagField.py
 import numpy as np import matplotlib.pyplot as plt import scipy.special as sp a = 1.55 current = 1 mu = 4 * np.pi / 10000000 # equal to sqrt(4ra(z^2 + (a+r)^2)^(-1)) def k_val (R, Z):
Created Nov 28, 2015
In plane magnetic field of a current loop of radius a, distance r from the loop axis. Field will be perpendicular to the plane.
View MagField2.py
 import numpy as np import matplotlib.pyplot as plt import scipy.special as sp a = 1.55 current = 1 mu = 4 * np.pi / 10000000 # equal to sqrt(4ra(z^2 + (a+r)^2)^(-1)) def k_val (R, Z):
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
Created May 18, 2016
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
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
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.
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
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 = []
You can’t perform that action at this time.