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 / bcd_segmentation.ipynb
Last active August 29, 2015 14:12
BCD segmentation
Loading
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 / webapp.py
Created April 2, 2015 17:56
Flask webapp template
from flask import Flask, Response
app = Flask(__name__)
@app.route('/')
def index():
return Response('<h1>Hello, world.</h1>',mimetype='text/html')
if __name__=='__main__':
app.run(host='0.0.0.0',port=8080,debug=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 (
@joefutrelle
joefutrelle / safe_copy_fileset.py
Created May 12, 2015 17:44
Safe copies a fileset with retry (uses oii utils)
import random
import shutil
import tempfile
import os
from oii.utils import retry, safe_tempdir, gen_id, compare_files
def unreliable_copy(src,dest):
if random.random() > 0.2:
shutil.copy(src,dest)
@joefutrelle
joefutrelle / ldr_ex1.py
Last active August 29, 2015 14:24
Ladder API examples
from oii.ldr import Resolver
RESOLVER="""
<rule name="main">
<path var="conf_file" match="/etc/*/*.conf"/>
</rule>
"""
# load the resolver from the text block.
# you can also pass a filename to Resolver
@joefutrelle
joefutrelle / Vagrantfile
Created October 23, 2015 17:36
Vanilla Vagrantfile, Ubuntu 14.04 LTS, 2GB RAM
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.memory="2048"
end
end