Skip to content

Instantly share code, notes, and snippets.

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 / 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
@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."""

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:

@stringfellow
stringfellow / problem.md
Last active August 8, 2018 10:45
Celery hang problem

Celery 4.1.0, Redis client 2.10.6, Redis server 4.0

I have a problem that seems to be related to synchronous subtasks, except that none of the workarounds (or indeed the errors/warnings that I should expect from the docs) are having any effect.

I have 3 worker servers, A B and C

  • A and B run the same codebase.
  • A calls apply_async of a Task1. Get/Forget not called (it doesn't care about the result itself, but we want the result stored in the backend)
  • Task1 gets run by server B.
  • Within Task1 (now executed on server B) - Task2 from another codebase is called - using send_task (since the codebase is not shared here).
@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