Skip to content

Instantly share code, notes, and snippets.

View patrickfuller's full-sized avatar

Patrick Fuller patrickfuller

View GitHub Profile
@patrickfuller
patrickfuller / advent_of_code_2022.py
Last active December 27, 2022 04:04
Advent of Code 2022
# pylint: disable=unspecified-encoding
"""Solutions for 2022 Advent of Code puzzles.
https://adventofcode.com/2022
"""
import argparse
import functools
import itertools
import json
from queue import LifoQueue
@patrickfuller
patrickfuller / mcmaster_in_to_mm.js
Last active April 6, 2020 17:28
Converts inches to mm on McMaster's website.
$('.dx').each((i, el) => {
let val = $(el).html();
if (val.slice(-1) === '"') {
$(el).html((parseFloat(val.slice(0, -1)) * 25.4).toFixed(1) + ' mm');
}
});
@patrickfuller
patrickfuller / grid_maker.py
Last active October 10, 2018 13:40
Grid Maker
"""
Create a custom grid-paper design as a minified vector image.
This uses a unique adaptation of "stroke-dasharray" to create the grid
pattern in a very small svg.
Usage:
python grid_maker.py > grid.svg
python grid_mater.py --help
@patrickfuller
patrickfuller / alias_dns.py
Last active August 4, 2024 05:00
Enables local DNS resolution of Unifi aliases
"""
When run in cron, automatically adds compliant alias names to local DNS.
Use at your own risk.
Patrick Fuller, 25 June 17
"""
import re
import paramiko
import pymongo
@patrickfuller
patrickfuller / github_issues_to_csv.py
Last active October 7, 2024 16:28 — forked from unbracketed/export_repo_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
"""
Exports issues from a list of repositories to individual csv files.
Uses basic authentication (Github username + password) to retrieve issues
from a repository that username has access to. Supports Github API v3.
Forked from: unbracketed/export_repo_issues_to_csv.py
"""
import argparse
import csv
from getpass import getpass
import requests
@patrickfuller
patrickfuller / zn_bdc_dabco.cif
Created July 23, 2015 23:04
Zn-BDC-DABCO Conformers
#######################################################################
#
# This file contains crystal structure data downloaded from the
# Cambridge Structural Database (CSD) hosted by the Cambridge
# Crystallographic Data Centre (CCDC).
#
# Full information about CCDC data access policies and citation
# guidelines are available at http://www.ccdc.cam.ac.uk/access/V1
#
# Audit and citation data items may have been added by the CCDC.
@patrickfuller
patrickfuller / regex.md
Created June 27, 2015 16:56
Python single quote replacement

The goal is to replace individual double quotes " with single quotes ' without affecting docstring triple double quotes """.

%s/([^"])"([^"])/$1'$2/g
@patrickfuller
patrickfuller / pre-commit
Last active September 18, 2019 16:29
SCSS compilation pre-commit hook
#!/bin/bash
# When SCSS is changed in a commit, this compiles and commits the affected css.
# This script assumes a project directory of the form:
# main.scss
# main.css
# scss
# | file_1.scss
# | ...
# | file_n.scss
@patrickfuller
patrickfuller / sample_output.txt
Created January 7, 2015 21:06
Modbus Holding Register Scanner
40001: 0000110000000001
40002: 0000100000000001
40003: 0000000000000000
40004: 0000000000000000
40005: 0000000000000000
40006: 0000000000000000
40007: 0000000100000010
40008: 0000000000011100
40009: 0100001010001011
40010: 0101100111101011
@patrickfuller
patrickfuller / comparison.py
Last active May 21, 2017 17:39
Compares tornado.auth.GoogleMixin with tornado.auth.GoogleOAuth2Mixin. The latter is required after google's OAuth updates.
"""
A webserver to test Google OAuth in a couple of scenarios.
"""
import argparse
import time
import tornado.ioloop
import tornado.web
import tornado.auth
import tornado.gen