This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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")}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# probably about right | |
def variance(samples): | |
mean = sum(samples) / len(samples) | |
return sum((x - mean)**2 for x in samples) / len(samples) | |
# probably too short | |
def var(s): | |
m = sum(s) / len(s) | |
return sum((x - m)**2 for x in s) / len(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implementation of RoI Pooling | |
Credit: This is from tutorial available at | |
https://medium.com/xplore-ai/992508b6592b | |
""" | |
import tensorflow as tf | |
from tensorflow.keras.layers import Layer |
NewerOlder