Skip to content

Instantly share code, notes, and snippets.

Avatar

Philip Kahn tigerhawkvok

View GitHub Profile
@tigerhawkvok
tigerhawkvok / pyproject.toml
Last active Jul 5, 2021
Webify a directory of images
View pyproject.toml
[tool.poetry]
name = "webImages"
version = "0.1.0"
description = "Scales all images in a directory and preps for web use"
authors = ["Philip Kahn <tigerhawkvok@gmail.com>"]
license = "MIT"
[tool.poetry.dependencies]
python = "^3.7"
scikit-image = "~0.19.0"
View names_regex.md

Should work with most englishy names of folks - NOT suitable for international use - but just fine for "make sure people locally give me a full name"

The Pattern

^[a-zA-Z'\u00c0-\u01ff]+[ \t]+([a-zA-Z\u00c0-\u01ff]+\.?[ \t]+)?([a-zA-Z\u00c0-\u01ff]+([\-']|[a-zA-Z\u00c0-\u01ff](\. ?)?)?)+(?<!\.|-|')[ \t]*$"

Test Success

@tigerhawkvok
tigerhawkvok / .gitconfig
Last active May 27, 2021 — forked from joechrysler/who_is_my_mummy.sh
Find the nearest parent branch of the current git branch
View .gitconfig
[alias]
parentalt = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #"
parent = "!vbc=$(git rev-parse --abbrev-ref HEAD) && vbc_col=$(( $(git show-branch | grep '^[^\\[]*\\*' | head -1 | cut -d* -f1 | wc -c) - 1 )) && swimming_lane_start_row=$(( $(git show-branch | grep -n \"^[\\-]*$\" | cut -d: -f1) + 1 )) && git show-branch | tail -n +$swimming_lane_start_row | grep -v \"^[^\\[]*\\[$vbc\" | grep \"^.\\{$vbc_col\\}[^ ]\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//'"
@tigerhawkvok
tigerhawkvok / cleanupGitHere.py
Last active Jul 1, 2021
Clean up a directory of Git projects
View cleanupGitHere.py
#!python3
"""
Cleanup all top level git directories here.
Creates a powershell or bash script to then execute
https://gist.github.com/tigerhawkvok/2161ef3aead495420fc84588ec50b6a3
Python 3.7+
"""
#pylint: disable= line-too-long, invalid-name
@tigerhawkvok
tigerhawkvok / ImageDeTiler.py
Last active Apr 19, 2021 — forked from will-hart/README.md
Stitch together tilemaps into a single image
View ImageDeTiler.py
#!python3
"""
A simple script which converts all the images in
the folder it is run from into a single image.
Images should be in a directory <searchDir>, with
the tiles binned into folders based on their
Y-axis identity, named as their X-axis identity.
In other words, they should be folders of rows
containing column-items for that row of images.
@tigerhawkvok
tigerhawkvok / smoothSignal.py
Last active Mar 17, 2020
Smooth an input signal
View smoothSignal.py
#!python3
import numpy as np
from typing import Union
def smooth(inputSignal:Union[list, np.ndarray], windowLength:int= 11, window:str= 'flat') -> np.ndarray:
"""
Smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal.
The signal is prepared by introducing reflected copies of the signal
@tigerhawkvok
tigerhawkvok / poetry-convert.py
Last active Aug 13, 2019
Convert a requirements.txt file to a Poetry project
View poetry-convert.py
#!python3
"""
Convert a requirements.txt file to a Poetry project.
Just place in the root of your working directory and run!
"""
sourceFile = "./requirements.txt"
import re
import os
@tigerhawkvok
tigerhawkvok / listify.py
Last active Mar 21, 2019
Make things a list
View listify.py
#########
# Casting Helper
#########
def isSimpleIterable(thing) -> bool:
"""
Check if the thing is a basic iterable type
"""
return isinstance(thing, (list, set, tuple, frozenset))
@tigerhawkvok
tigerhawkvok / file_get_contents_curl.php
Last active Sep 21, 2018
cURL replacement for file_get_contents()
View file_get_contents_curl.php
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
# Actual fetch
$data = curl_exec($ch);
@tigerhawkvok
tigerhawkvok / geocodeHelper.py
Created Apr 4, 2018
Strip down a user-provided address to its essentials
View geocodeHelper.py
#!python3
"""
@author Philip Kahn
@license MIT
"""
def getBarebonesAddress(dirtyAddress):
"""
Will take most forms of addresses, and return an address of form