Skip to content

Instantly share code, notes, and snippets.

@yosemitebandit
yosemitebandit / crop_to_path.py
Created November 18, 2015 04:51
cut an image out based on a path in python with Pillow, Numpy and Shapely
"""Crop a polygonal selection from an image."""
import numpy as np
from PIL import Image
from shapely.geometry import Point
from shapely.geometry import Polygon
im = Image.open('bird.jpg').convert('RGBA')
pixels = np.array(im)
im_copy = np.array(im)
@yosemitebandit
yosemitebandit / yupyupnope.conf
Created September 29, 2011 23:37
nginx config file for flask app (behind gunicorn) with ssl
server {
listen 80;
server_name www.yupyupnope.com;
rewrite ^/(.*) https://yupyupnope.com/$1 permanent;
}
server {
listen 80;
server_name yupyupnope.com;
rewrite ^/(.*) https://yupyupnope.com/$1 permanent;
@yosemitebandit
yosemitebandit / classify.py
Created April 2, 2013 18:52
OCR with OpenCV - KNN methods from Abid Rahman
''' classify
after training, classify a sample image with K-Nearest Neighbor
annotated from Abid Rahman's post: http://stackoverflow.com/a/9620295/232638
'''
import cv2
import numpy as np
# load the data we generated previously
samples = np.loadtxt('general-samples.data', np.float32)
@yosemitebandit
yosemitebandit / udev.txt
Last active August 27, 2018 21:36
helpful udev / USB debugging commands
watch -n 1 "ls /dev"
watch -n 1 "ls /dev | grep unitek"
udevadm monitor
sudo service udev restart
udevadm info -a -p $(udevadm info -q path -n /dev/ttyACM0)
udevadm info --name=/dev/ttyACM0 --attribute-walk
udevadm info --name=/dev/ttyACM0 --attribute-walk | grep KERNELS
@yosemitebandit
yosemitebandit / 3_regularization.ipynb
Last active June 8, 2017 01:49
udacity neural network course -- assignment 3.4, 3-layer NN with regularization and dropout
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yosemitebandit
yosemitebandit / sample.ino
Created April 12, 2017 18:43
sample sketch for review
/* Sample sketch for review.
*/
#define USB Serial
const int usbBaud = 57600;
const int ledPin = 13;
const int commandBufferLength = 80;
static char commandBuffer[commandBufferLength];
char *commandMode;
@yosemitebandit
yosemitebandit / 1_notmnist.ipynb
Last active March 7, 2017 03:20
assignment two from the Udacity Deep Learning course
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yosemitebandit
yosemitebandit / notes.md
Last active November 27, 2016 09:41
live streaming notes

youtube

  • create an event and setup custom ingestion so you get an rtmp url, then use something like to stream from a mac's webcam:
ffmpeg -f avfoundation -i "default" -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -acodec aac -ab 128k -g 50 -strict experimental -f flv -s 426x240 "<rtmp_path>/<stream_id>"

zencoder

@yosemitebandit
yosemitebandit / gene_expression_plotter.py
Last active April 22, 2016 20:57
plotting gene expression data
"""Plotting gene expression data from a csv"""
import os
import matplotlib
import matplotlib.pyplot as plt
import pylab
# Load data.
path = 'murine-placenta-gene-1-2.csv'
@yosemitebandit
yosemitebandit / two-player-go.html
Created March 12, 2016 20:18
go in the browser -- basically just a virtual board, no scoring or rule enforcement or..much of anything, really!
<!doctype html>
<html>
<head>
<style>
body, html, table {
margin: 0;
padding: 0;
}
body {