Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kurtraschke
kurtraschke / subviewer.pde
Created September 6, 2011 16:56
Render archived MTA NYCT A Division ATS data
import processing.video.*;
MovieMaker mm;
OSMMercator om;
PFont theFont;
void setup() {
size(1280, 720);
smooth();
@kurtraschke
kurtraschke / subviewer1.py
Created September 6, 2011 17:52
Two approaches to visualizing MTA NYCT A Divsion ATS data in Google Earth
from csv import DictReader
from collections import defaultdict
import xml.etree.ElementTree as etree
from datetime import datetime
import pytz
from gtfs import Schedule
from gtfs.entity import Stop
@kurtraschke
kurtraschke / test.html
Created September 15, 2011 21:58
Demonstration of polling disconnect in socket.io
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script>
var connectTime;
var socket = io.connect('/', {transports: ['websocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']});
socket.on('connect', function(){
console.log('connected');
connectTime = new Date().getTime();
@kurtraschke
kurtraschke / gist:1390328
Created November 24, 2011 00:18
WMATA bus API says there are no buses...
Kurt-Raschke:~ kurt$ curl http://api.wmata.com/Bus.svc/json/JBusPositions?api_key=redacted
{"BusPositions":[]}
{
"Routes": [
{
"Name": "10:00:00 AM - 10A HUNT TOWERS-PENT ",
"RouteID": "10A"
},
{
"Name": "10:00:00 AM - 10A HUNT TOWERS-PENT ",
"RouteID": "10Av1"
},
@kurtraschke
kurtraschke / area.py
Created December 17, 2012 23:18
Find bounding box and convex hull of agency coverage (as WKT) for a OneBusAway TDS.
from mustaine.client import HessianProxy
from shapely.geometry import box
from shapely.ops import cascaded_union
service = HessianProxy("http://172.16.2.32:8080/onebusaway-transit-data-federation-webapp/remoting/transit-data-service")
agencies = service.getAgenciesWithCoverage()
boxes = []

This Gist contains a script and supporting files for building a OneBusAway GTFS bundle with data for all agencies in the Baltimore/Washington area that have publicly released their data.

Configuration parameters come from two sheets in a Google Docs document:

https://docs.google.com/spreadsheet/ccc?key=0AvrkbWHnoksNdGdYam4wX214SXpoRmdia0FEalZvUHc&usp=sharing

The dependency on Google Docs could easily be removed by removing that part of download.sh and using a locally-maintained CSV file instead.

Recently (as in, over the past few months) the WMATA BusPosition feed has been behaving anomalously.
There are three observed problems:
1. The feed doesn't include the entire fleet - during the weekday rush hour we'd expect to see close to 900 buses, but this morning the feed returned fewer than 250 vehicles.
2. Bus positions return the wrong trip, or are lagging badly. Look at this example:
<BusPosition>
<DateTime>2013-08-16T07:32:01</DateTime>
@kurtraschke
kurtraschke / cap.xjb
Created November 11, 2013 01:47
JAXB bindings file for CAP schema to produce enums from anonymous types.
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="1.0">
<jaxb:bindings schemaLocation="CAP-v1.2.xsd" node="/xsd:schema">
<jaxb:bindings node="//xsd:element[@name='status']">
<jaxb:bindings node="./xsd:simpleType">
<jaxb:typesafeEnumClass name="StatusType" />
@kurtraschke
kurtraschke / sleep.ps1
Last active March 2, 2016 02:48
PowerShell script to summarize a Windows PC's sleep history
$filter = @{LogName='System';
ProviderName='Microsoft-Windows-Power-Troubleshooter';
ID=1}
$namespaces = @{"event"="http://schemas.microsoft.com/win/2004/08/events/event"}
Get-WinEvent -FilterHashtable $filter | % {
$obj = New-Object PSObject
[xml]$_.ToXml() | Select-Xml -Namespace $namespaces "/event:Event/event:EventData/event:Data" | % {