Skip to content

Instantly share code, notes, and snippets.

View mathandy's full-sized avatar

Andrew Port mathandy

View GitHub Profile
firstname = input("What is your first name? ")
lastname = input("What is your last name? ")
fullname = firstname + " " + lastname
age = int(input("What is your age? "))
address = input("What is your address? ")
print("Hi {}.".format(fullname))
print("Your address is {}.".format(address))
if age >= 18:
@mathandy
mathandy / dominion.py
Last active February 6, 2021 07:57
Parses Dominion (dominion.games) log to get decks.
"""Parses Dominion (dominion.games) log to get decks.
To use: create text file in your Downloads folder called "log.txt"
and copy/paste the log into that file. Then run this script with python.
"""
from collections import deque
import re
from pathlib import Path
@mathandy
mathandy / flash.sh
Last active August 11, 2021 04:15
script to make terminal flash until any key is pressed (works inside tmux also)
#!/bin/bash
# script to make terminal flash until any key is pressed
# credit:
# https://stackoverflow.com/questions/25532773/change-background-color-of-active-or-inactive-pane-in-tmux/33553372#33553372
# https://stackoverflow.com/questions/32009787/bash-how-can-the-terminal-be-set-to-flash
# https://stackoverflow.com/questions/5297638/bash-how-to-end-infinite-loop-with-any-key-pressed
# check if tmux version is < 2.1
tmux_is_old=$(awk -v n1="$(tmux -V| cut -d' ' -f2)" -v n2="2.1" 'BEGIN {printf (n1<n2?"1":"0")}')
#!/usr/bin/env python3
import tensorflow as tf
import pathlib
data_dir = pathlib.Path.home() / 'datasets' / 'dogs-v-cats' / 'train'
# data_dir = pathlib.Path.home() / 'datasets' / '10flowers' / 'images'
batch_size = 32
img_height = 224
img_width = 224
@mathandy
mathandy / determine-if-svg-path-is-contained-in-other-path-example.py
Created December 10, 2016 04:07
An example of how to determine if an SVG Path is contained in another SVG Path in Python.
"""
An example of how to determine if an svg path is contained in another
svg path in Python.
Note: for discontinuous paths you can use the svgpathtools
Path.continuous_subpaths() method to split a paths into a list of its
continuous subpaths.
"""
from svgpathtools import *
@mathandy
mathandy / mic_listener.py
Created August 5, 2018 07:59
A real-time analog to midi converter
"""A real-time analog to midi converter.
Listens to you system's microphone and does its best to convert the
sounds it hears to a sequence of musical notes. It works ok... play
with the sampling settings to get results that fit your needs.
Usage Example:
--------------
>>> from mic_listen import list_devices, MicListener
>>> list_devices() # to list system devices
@mathandy
mathandy / draw-grid-lines-on-image.py
Last active November 11, 2023 10:53
Use OpenCV to draw grid lines on an image.
"""Draw grid lines on an image.
Usage:
# To draw a 3x4 grid on an image
$ python draw_grid_lines.py <path/to/image> <num_rows> <num_cols> -o <output/dir-or-path>
$ python draw_grid_lines.py image.png 3 4 -o output.png
# for more options, see
$ python draw_grid_lines.py --help