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 / read_eeprom.ino
Created November 7, 2014 15:42
read tinycube eeprom
#include <Wire.h>
#define EEP_ADDR 0x50
void dump();
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
@joefutrelle
joefutrelle / remus_interp_alt.py
Created December 21, 2014 19:21
Interpolate altitudes in REMUS exported bathy data
#!/env/python
import sys
import os
import numpy as np
import pandas as pd
from pandas.io.parsers import read_csv
BASE_PATH='/media/F_DRIVE/FSM 2014'
@joefutrelle
joefutrelle / extract_desc.py
Created December 22, 2014 18:11
Extract description from #TIFF files using python-tifffile
#!/env/python
import os
from glob import glob
from tifffile import TiffFile
BASE_DIR='{whatever}'
for tfpath in sorted(glob(os.path.join(BASE_DIR,'*.tif'))):
tf = TiffFile(tfpath)
tfn = os.path.basename(tfpath)
@joefutrelle
joefutrelle / count_bright.py
Created December 26, 2014 14:41
Quick 'n dirty method for counting bright objects on a dark background (or vice versa by inverting the image)
from skimage.feature import peak_local_max
from skimage.filter import threshold_otsu
import scipy.ndimage as ndi
def count_bright(Y):
t = threshold_otsu(Y)
D = ndi.distance_transform_edt(Y > t)
Pl = peak_local_max(D,indices=False)
_, count = ndi.label(Pl)
return count
@joefutrelle
joefutrelle / bcd_segmentation.ipynb
Last active August 29, 2015 14:12
BCD segmentation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / par.cpp
Last active August 29, 2015 14:18
Simple Boost ASIO based parallelization template
#include <iostream>
#include <string>
#include <boost/thread.hpp>
#include <boost/asio.hpp>
#define N_THREADS 4
#define N_JOBS 10
/* compile on Ubuntu using
g++ par.cpp -lboost_thread -lboost_system
@joefutrelle
joefutrelle / orm.py
Last active August 29, 2015 14:18
SQLAlchemy ORM template
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, Integer, Numeric
from sqlalchemy.orm import backref, relationship
Base = declarative_base()
class Thing(Base):
__tablename__ = 'things'
id = Column(Integer, primary_key=True)
@joefutrelle
joefutrelle / pandas_merge.py
Created April 9, 2015 23:50
pandas merge example
from pandas import DataFrame, merge
import numpy as np
# generate array of random small integers
df1 = DataFrame(np.random.random_integers(5,size=(5,2)),columns=['a','b'])
# find unique values
uq = df1.a.unique()
# now generate two associated columns per unique value
@joefutrelle
joefutrelle / Makefile
Last active August 29, 2015 14:20
ATTiny85
# Name: Makefile
# Author: <insert your name here>
# Copyright: <insert your copyright message here>
# License: <insert your license reference here>
# This is a prototype Makefile. Modify it according to your needs.
# You should at least check the settings for
# DEVICE ....... The AVR device you compile for
# CLOCK ........ Target AVR clock rate in Hertz
# OBJECTS ...... The object files created from your source files. This list is
ECHO OFF
cd /d %~dp0
for /f "tokens=2* delims= " %%F IN ('vagrant status ^| find /I "default"') DO (SET "STATE=%%F%%G")
ECHO Close this window if it remains open, and http://localhost:8081 is responsive
IF "%STATE%" NEQ "saved" (
ECHO Starting Vagrant VM from powered down state...
vagrant up
) ELSE (