Skip to content

Instantly share code, notes, and snippets.

@yosemitebandit
yosemitebandit / api_test.py
Created November 8, 2011 18:54
api testing
#! /usr/bin/env python
'''
api_test.py
'''
import requests
engine = 'pv66-lab'
auth = ('admin', 'redwood')
'''
@yosemitebandit
yosemitebandit / thumb.py
Created December 9, 2011 05:48
makes thumbnails
#!/usr/bin/env python
'''
thumb.py
making little images; PIL's thumbnail method be damned!
usage:
$ thumb target.png
$ thumb target.png -W 300
$ thumb target.jpg -W 300 -H 200
$ thumb target.jpg -W 300 -H 200 -o /thumbs/target_thumb.png
'''
@yosemitebandit
yosemitebandit / meduele_login_with_requests.py
Created February 12, 2012 02:46
using the request lib's sessions to login; bonus: beautiful soup finds the csrf token
#!/usr/bin/env python
'''
testing a login to meduele using sessions
meduele checks csrf tokens with every request, even during login
'''
import requests
from BeautifulSoup import BeautifulSoup
# need to capture a valid csrf token
# first visit the login page to generate one
@yosemitebandit
yosemitebandit / ncdc_processor.py
Created February 21, 2012 21:20
Format historical weather data exported from the NCDC
#!/usr/bin/env python
'''
ncdc_processor.py
imports a csv of historical weather data from the NCDC
exports a somewhat more sanely formatted csv suitable for graphing
data from http://www7.ncdc.noaa.gov/CDO/cdo
usage:
$ python ncdc_processor.py /path/to/ncdc_data.txt /path/to/export.csv
@yosemitebandit
yosemitebandit / csv_to_flot_data.py
Created February 22, 2012 00:28
pull timeseries data from a csv and export a js file with formatting suitable to flot
#!/usr/bin/env python
'''
csv_to_flot_data.py
extract data from a csv; save a js file with flot-compatible data
usage:
$ python csv_to_flot_data.py /path/to/input.csv /path/to/output.js
'''
import csv
import sys
import time
@yosemitebandit
yosemitebandit / carto-example.mss
Created March 1, 2012 02:47
sample carto file for TileMill with labels and conditional styling based on string-matching
Map { background-color: #b8dee6; }
#countries { ::polygon { polygon-fill: #fff; } }
#boladm {
::polygon {
polygon-fill: #76b8d5;
}
::line {
line-color: #3f3f3f;
@yosemitebandit
yosemitebandit / key-fingerprint
Created March 7, 2012 18:27
view your ssh public key's fingerprint; compare this to what Github has listed in the ssh key audit
$ ssh-keygen -l -f /path/to/keys/id_rsa.pub
2048 aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99 id_rsa.pub (RSA)
@yosemitebandit
yosemitebandit / twiml_response.xml
Created March 22, 2012 15:36
twiml response that is failing with "Error 11100 - Invalid play URL"
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Hello. This form is called nother-form. First question.</Say>
<Play>https://ivrhub_prompts_akiajf7vh6epo5gc7eia.s3.amazonaws.com/kvv27g7m4eknsqv2nnudqpge.mp3</Play>
<Gather />
</Response>
@yosemitebandit
yosemitebandit / edit-snippet.js
Created April 30, 2012 17:46
a (failed) shot at jqeditable; didn't have all the callbacks I wanted
$(function() {
// drop the ajax-ed-ness..it's just not working out
// save the below in a gist
$('.edit').editable(function(value, settings) {
// gather up the user data
var form_data = {
_csrf_token: '{{ csrf_token() }}'
};
@yosemitebandit
yosemitebandit / organization-labels.css
Created May 2, 2012 00:28
labeling organizations in carto via a CSV
Map {
background-color: #b8dee6;
}
#10madmin0countries {
line-color:#594;
line-width:0.5;
polygon-opacity:1;
polygon-fill:#ae8;
}