Skip to content

Instantly share code, notes, and snippets.

@yosemitebandit
yosemitebandit / membership.html
Created May 4, 2012 02:32
an incomplete member/cloud example with typeahead; punting on this cause nobody would see it anyway
{% extends "layout.html" %}
{% block head %}
<style>
.btn-info {
margin-top: 5px;
}
#members {
display: none;
@yosemitebandit
yosemitebandit / openpyxl-install-with-pip
Created June 4, 2012 17:42
reading xlsx files in python with openpyxl
$ pip install -E ~/conf/virtualenvs/xyuml https://bitbucket.org/ericgazoni/openpyxl/get/1.5.8.zip
@yosemitebandit
yosemitebandit / send_pdf_with_boto_ses.py
Created June 6, 2012 17:56
send PDF attachment with boto and SES
''' quick example showing how to attach a pdf to multipart messages
and then send them from SES via boto
'''
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
import boto
@yosemitebandit
yosemitebandit / BOL_adm3.js
Created August 22, 2012 22:23
Leaflet maps with shapefile-derived GeoJSON
var BOL_adm3 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"ID_0": 27,
"ISO": "BOL",
"NAME_0": "Bolivia",
"ID_1": 1,
"NAME_1": "Chuquisaca",
@yosemitebandit
yosemitebandit / sample_form.xml
Created October 19, 2012 01:12
attempting conditional select items using itemsets (http://goo.gl/Z6QQO)
<?xml version="1.0" encoding="UTF-8" ?>
<h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns:orx="http://openrosa.org/jr/xforms" xmlns="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
<h:head>
<h:title>location location location</h:title>
<model>
<instance>
<data xmlns:jrm="http://dev.commcarehq.org/jr/xforms" xmlns="http://openrosa.org/formdesigner/4DCD3A18-692B-4BA4-BC5A-A863D1C766FA" uiVersion="1" version="1" name="location location location">
<name />
<province />
<district />
@yosemitebandit
yosemitebandit / sp.py
Created December 10, 2012 20:18
mongodb data injection simulation
#!/usr/bin/env python
''' sp.py
throw data at a mongodb instance
simulate the SP data load
'''
import datetime
import os
from mongoengine import connect, Document, StringField, DateTimeField
connect('sp')
@yosemitebandit
yosemitebandit / cells.py
Created December 11, 2012 06:11 — forked from thenoviceoof/cells.py
Randomly generate automata
#!/usr/bin/env python
# commented version of a gist from @thenoviceoof
import os
import time
import random
# capture the screen size and find the middle-ish pixel
rows, columns = os.popen('stty size', 'r').read().split()
@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)
''' communicating to openbts through zeromq
'''
import json
import zmq
address = 'tcp://127.0.0.1:45060'
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect(address)
payload = {
# via
# https://mail.python.org/pipermail/python-list/2010-August/586080.html
import random
import timeit
with open('/usr/share/dict/words') as infile:
words = [line.strip() for line in infile]
sample = random.sample(words, 501)