Skip to content

Instantly share code, notes, and snippets.

@stringfellow
stringfellow / watch.rb
Created February 10, 2012 13:32
Watch for file changes and refresh your browser automatically
#!/usr/bin/env ruby
# watch.rb by Brett Terpstra, 2011 <http://brettterpstra.com>
# with credit to Carlo Zottmann <https://github.com/carlo/haml-sass-file-watcher>
# edited by Dave Arter to refresh Chrome using code suggested in Brett's original blog post: <http://brettterpstra.com/watch-for-file-changes-and-refresh-your-browser-automatically/>
# edited more by Steve Pike to not do any of that, and instead recompile coffee.
trap("SIGINT") { exit }
if ARGV.length < 1
puts "Usage: #{$0} watch_folder"
@stringfellow
stringfellow / tms2osm.py
Created May 11, 2012 11:02
TMS to OSM directory conversion script
import os
import shutil
import argparse
import commands
from datetime import datetime
try:
import progressbar as pb
except ImportError:
@stringfellow
stringfellow / spine_modelresource.py
Created May 18, 2012 13:19
Spinejs - django-tastypie integration base ModelResource class
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
from tastypie.resources import ModelResource
class SpineFrontedResource(ModelResource):
"""A base model resource for spine-fronted models.
* Bins the 'id' that spine sends.
* Removes 'meta' from the list, returns only objects.
@stringfellow
stringfellow / silence_if_ok.sh
Created July 12, 2012 10:09
Bash wrapper script to silence cron if there are no errors, and print out if there are
#!/bin/bash
logfile=$$.log
exec 6>&1
exec > $logfile 2>&1
$*
RETVAL=$?
exec 1>&6 6>&-
if [ $RETVAL -ne 0 ]; then
echo "FAILURES:"
cat $logfile
call "C:\OSGeo4w64\bin\o4w_env.bat"
IF NOT EXIST C:\mapproxy (
easy_install virtualenv
mkdir C:\mapproxy
cd C:\mapproxy
virtualenv --system-site-packages env
env\Scripts\activate
pip install pyreadline MapProxy ipython lxml
mapproxy-util create -t base-config mapactionproxy
cd mapactionproxy
@stringfellow
stringfellow / ebay_sold_averagerer.js
Created January 1, 2016 20:12
eBay sold item averagerer
x=y=0;$('.bidsold').each(function(){x++;y+=parseFloat($(this).html().trim().substr(1,5))});y/x;
@stringfellow
stringfellow / middleware.py
Created March 17, 2016 16:04
Simple Django profiling middleware
# -*- coding: utf-8 -*-
import cProfile
import pstats
from django.conf import settings
class ProfileStatsMiddleware(object): # pragma: no cover
"""Super light-weight cProfile/pstats profile middleware."""
@stringfellow
stringfellow / stacked_area_hover.py
Created October 10, 2016 14:11
Showing how to make a Bokeh stacked area with hover labels per-series
def stacked_area(df, colours, series_noun, **kwargs):
"""Return a stacked area plot."""
columns = df.columns
areas = stacked(df, columns)
x2 = np.hstack((df.index[::-1], df.index))
p = figure(
width=900, height=600, tools=[
SaveTool(),
HoverTool(tooltips=[(series_noun, "@name")])
@stringfellow
stringfellow / slinear vs linear
Last active September 7, 2018 11:52
linear & slinear interpolation of constant data
pandas slinear: [60.0, 60.0, 60.0, 60.0, 59.999999999999993, 60.0, 60.0, 60.0]
pandas linear: [60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0]
scipy slinear: [60.0, 60.0, 60.0, 60.0, 59.999999999999993, 60.0, 60.0, 60.0]
scipy linear: [60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0]
F
======================================================================
FAIL: Proof that linear and slinear are not equal.
----------------------------------------------------------------------
Traceback (most recent call last):
File "....", line 329, in test_slinear_versus_linear

Keybase proof

I hereby claim:

  • I am stringfellow on github.
  • I am stringfellow (https://keybase.io/stringfellow) on keybase.
  • I have a public key ASDXUKQ063VHceGQE6EEdI1OX86qMYngre_FK_7K5eqnnQo

To claim this, I am signing this object: