Skip to content

Instantly share code, notes, and snippets.

View joefutrelle's full-sized avatar

Joe Futrelle joefutrelle

  • Falmouth, MA
View GitHub Profile
@joefutrelle
joefutrelle / parse_btl_file.ipynb
Last active February 5, 2024 11:55
Parse Seabird CTD .btl file
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / gray world.ipynb
Created April 4, 2016 15:58
Gray world algorithm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / tpj.pl
Last active September 18, 2023 16:34
Obfuscated Perl contest winner from 1997 (note: no longer works)
package S2z8N3;{
$zyp=S2z8N3;use Socket;
(S2z8N3+w1HC$zyp)&
open SZzBN3,"<$0"
;while(<SZzBN3>){/\s\((.*p\))&/
&&(@S2zBN3=unpack$age,$1)}foreach
$zyp(@S2zBN3){
while($S2z8M3++!=$zyp-
30){$_=<SZz8N3>}/^(.)/|print $1
;$S2z8M3=0}s/.*//|print}sub w1HC{$age=c17
@joefutrelle
joefutrelle / Hausdorff KDTree.ipynb
Last active June 15, 2023 23:54
Hausdorff and Modified Hausdorff distance implemented using KDTree
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / bwmorph_thin.py
Last active April 3, 2023 02:47
bwmorph('thin') in Python
import numpy as np
from scipy import ndimage as ndi
# lookup tables for bwmorph_thin
G123_LUT = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
@joefutrelle
joefutrelle / attiny85_synth.c
Last active July 26, 2022 16:10
Direct digital synthesis (Karplus-Strong plucked string algorithm) on the Atmel ATtiny85 AVR microcontroller using the MCP4725 12-bit DAC over I2C using USI-based TWI as described in Application Note AVR310
/**
* Author: Joe Futrelle
* License: CC0 - Free as in freedom
*/
/**
* ATtiny85 direct digital synthesis
* using MCP4725 12-bit I2C DAC
* TWI is handled using Atmel's USI TWI implementation
* which is provided as part of Application Note AVR310
* http://www.atmel.com/Images/Atmel-2561-Using-the-USI-Module-as-a-I2C-Master_AP-Note_AVR310.pdf
@joefutrelle
joefutrelle / MATLAB_datetimes.py
Created April 26, 2022 16:15
Convert MATLAB datenums to/from Python datetimes
from datetime import datetime, timedelta
# util for converting MATLAB datenum to Python datetime
# as described in http://stackoverflow.com/questions/13965740/converting-matlabs-datenum-format-to-python
def datenum2datetime(matlab_datenum):
dt = datetime.fromordinal(int(matlab_datenum)) + timedelta(days=matlab_datenum%1) - timedelta(days = 366)
return dt
# util for converting datetime to MATLAB datenum
# as described in http://stackoverflow.com/questions/8776414/python-datetime-to-matlab-datenum
@joefutrelle
joefutrelle / binpack2.py
Last active September 15, 2021 02:25
Numba implementation of Guillotine bin packing
import numba as nb
from numba.typed import List
NO_ID = -1
DOESNT_FIT = 99999999
NO_SECTION = (0, 0, 0, 0, DOESNT_FIT)
@nb.jitclass([
('x', nb.int32),
('y', nb.int32),
@joefutrelle
joefutrelle / attiny_alpha4.c
Last active June 11, 2021 16:24
attiny85 driving an Adafruit HT16K33 4-digit alphanumeric LED display
/* Name: main.c
* Author: Joe Futrelle
* License: CC0 - Free as in freedom
*/
/* Adafruit 4-digit alphanumeric backpack, I2C
* Via USI_TWI_master from application note AVR310
* http://www.atmel.com/Images/Atmel-2561-Using-the-USI-Module-as-a-I2C-Master_AP-Note_AVR310.pdf
*/
/* Datasheet for HT16K33
* http://www.adafruit.com/datasheets/ht16K33v110.pdf
@joefutrelle
joefutrelle / python_sqlite.ipynb
Created June 1, 2021 16:28
Working with SQLite in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.