Skip to content

Instantly share code, notes, and snippets.

View drscotthawley's full-sized avatar
Solving environment /

Scott H. Hawley drscotthawley

Solving environment /
View GitHub Profile
@drscotthawley
drscotthawley / tictactoe_policy.py
Last active August 17, 2017 14:28
My implementation of a temporal difference policy method for playing Tic Tac Toe, after seeing Shlomo Bauer speak at the Brentwood A.I. meetup.
#! /usr/bin/env python3
# Uses temporal difference policy method
# See, e.g., http://www.cs.dartmouth.edu/~lorenzo/teaching/cs134/Archive/Spring2009/final/PengTao/final_report.pdf
# In this code, X plays randomly whereas O 'learns'. (Feel free to change that)
# Thus we expect O to outperform X eventually
# Author: Scott Hawley http://drscotthawley.github.io
# Unlimited License: Feel free to use any or all of this code however you like.
@drscotthawley
drscotthawley / TestRenderMan_DexedVST.ipynb
Created April 28, 2018 02:17
Slight modification of RenderMan demo, made for Python 3 and MacOS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drscotthawley
drscotthawley / scope_with_trigger.py
Last active May 3, 2018 03:42
Realtime waveform display with tunable trigger level
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Scott H. Hawley'
__copyright__ = 'Scott H. Hawley'
__license__ = "MIT Licence (do what you want, don't blame me)"
import numpy as np
import cv2
import soundcard as sc # https://github.com/bastibe/SoundCard
from scipy.ndimage.interpolation import shift
@drscotthawley
drscotthawley / osc2wek.py
Last active April 23, 2019 03:17
Sends incoming OSC messages (subject to some filter) to Wekinator
#! /usr/bin/env python3
'''
osc2wek.py
Author: Scott Hawley
This listens for incoming OSC messages and sends them on to Wekinator
Steps to get running (in Terminal):
0. First you need Mercurial "hg". It might be installed by default.
1. Use hg to clone the grail osc code:
@drscotthawley
drscotthawley / proc_fma.py
Last active August 22, 2019 06:23
FMA dataset conversion script, genre classification, to individual subdirs
#! /usr/env/python3
#
# FMA conversion script, genre classification
# Author: Scott Hawley
# License: Do as you like
#
# For FMA dataset https://github.com/mdeff/fma
# to be used with panotti https://github.com/drscotthawley/panotti
#
# This will create a directory called Samples/
@drscotthawley
drscotthawley / inst_freq.py
Last active November 4, 2019 18:21
Alternative method for calculating "instantaneous frequency" for use with spectrograms.
#! /usr/bin/env python3
# Test script for Phase 'Unrolling' / Instantaneous frequency
#
# See Jesse Engel's "rainbowgrams" script, https://gist.github.com/jesseengel/e223622e255bd5b8c9130407397a0494
#
# Modifications by Scott H. Hawley, @drscotthawley and Billy Mitchell
# These modified versions seem to be both more accurate (~2000x less reconstruction error)
# and faster (>20%)
#
# note, to really see/hear the difference, change dtypes to np.float16!
@drscotthawley
drscotthawley / newpost.py
Last active July 28, 2020 03:12
Little script I use to easily start a new Fastpages/Jekyll/Markdown blog entry
#! /usr/bin/env python
# Little script I use to start a new Markdown blog entry.
# Run from the parent directory above the blog directory,
# or supply a full path to run from anywhere.
#
# Usage: newpost.py <title>
# It automatically figures out what the current date is to
# create a new entry, and supplies a default header with a title
# and a bibliography placement
@drscotthawley
drscotthawley / FastAICustomModelExample.ipynb
Created November 20, 2018 06:57
FastAICustomModelExample
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env python
'''
Simulation of a 'magnetic' pendulum. Actually we'll just use
electrostatic charges instead of magnets, but..good enough, right?
Plots an image showing which source the object is closest to after a certain time
(Note: Depending on params like maxiter, the object may still be moving at the
end of the simulation, so the 'ending position' may not be where it comes to rest.)
This code integrates all the (non-interacting) test objects at once, on the GPU.
@drscotthawley
drscotthawley / text_shortener.py
Last active August 27, 2020 20:31
Shorten text by applying various shortening rules
#!/usr/bin/env python
# Replaces lengthy words/phrases with shorter variants
# Author: Scott Hawley
import pandas as pd
import re
import os