Skip to content

Instantly share code, notes, and snippets.

View CatherineH's full-sized avatar

Catherine Holloway CatherineH

View GitHub Profile
import pickle
import re
import os
from time import sleep
import urllib.parse
from pandas import read_csv
from selenium.webdriver.common.by import By
from selenium import webdriver
# generates an svg topographical map from a GeoTIFF file.
import rasterio
from shapely.geometry import Point, LineString
from skimage.measure import find_contours
from numpy import rot90, fliplr, flipud
# this data was downloaded from https://maps.canada.ca/czs/index-en.html
fp = r'dataset/DEM.tif'
dataset = rasterio.open(fp)
_min = None
@CatherineH
CatherineH / trapezoid_tiling.py
Last active December 25, 2020 17:24
two ways of generating a trapezoid tiling
import svgwrite
from svgwrite.path import Path
from svgwrite.shapes import Polygon, Polyline
from svgwrite.container import Group
from svgwrite.mixins import Transform
from math import sin, cos, pi, sqrt
width = 50
angle = 60*pi/360.0
margin = 10
scale_ratio = (width-margin)/width
@CatherineH
CatherineH / inkstitch-playbook.yaml
Created April 16, 2019 20:54
playbook for setting up inkstitch in wsl
---
- hosts: localhost
vars:
po: en_US
username: CatherineH
branch: change-pip-url
tasks:
- name: install debian packages
become: true
apt:
@CatherineH
CatherineH / cut_lines.py
Last active March 24, 2020 16:52
Extract cut lines from sewing pattern pdfs
# the latest version of this code is available at https://github.com/CatherineH/python-sewing/blob/master/patchwork.py
@CatherineH
CatherineH / grover_qutip.py
Last active May 5, 2018 06:13
Grover's search in qutip
from random import randint
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
from qutip import tensor, basis, hadamard_transform, identity
# initialize the |0> and |1> qubit states
zero = basis(2, 0)
one = basis(2, 1)
# how many times have we applied the oracle and diffuser?
@CatherineH
CatherineH / text_to_svg_path.py
Last active December 5, 2023 13:41
Convert a text character to an SVG path.
from svgpathtools import wsvg, Line, QuadraticBezier, Path
from freetype import Face
def tuple_to_imag(t):
return t[0] + t[1] * 1j
face = Face('./Vera.ttf')
@CatherineH
CatherineH / layering svgs with javascript.html
Last active June 21, 2023 13:22
two ways to layer SVGs with javascript
<html>
<body>
<p>Quick SVG</p>
<svg id="quickSVG"></svg>
<p>DOM SVG</p>
<svg id="appendSVG"></svg>
<script>
var circle ="<svg>\n" +
" <ellipse\n" +
@CatherineH
CatherineH / read_aerotec_energy_meter_with_pyopenzwave.py
Created October 28, 2017 21:03
Continuously reads power values from an Aerotec Energy Meter with pyopenzwave
import time
from openzwave.option import ZWaveOption
from libopenzwave import PyManager
import csv
from matplotlib import pyplot
device="/dev/ttyUSB0"
options = ZWaveOption(device, config_path="/etc/openzwave/", user_path=".", cmd_line="")
options.set_console_output(False)
options.lock()
from os.path import join, dirname, abspath
from matplotlib import pyplot
from matplotlib.cbook import get_sample_data
from numpy import linspace
from numpy.core.umath import pi
from numpy.ma import sin
# poo-mark came from emojipedia:
# https://emojipedia-us.s3.amazonaws.com/thumbs/120/apple/96/pile-of-poo_1f4a9.png
poo_img = pyplot.imread(get_sample_data(join(dirname(abspath(__file__)), "poo-mark.png")))