Skip to content

Instantly share code, notes, and snippets.

View wlach's full-sized avatar
👋

Will Lachance wlach

👋
View GitHub Profile
def latlng_dist(src_lat, src_lng, dest_lat, dest_lng):
if src_lat == dest_lat and src_lng == dest_lng:
return 0.0
theta = float(src_lng) - float(dest_lng);
src_lat_radians = math.radians(float(src_lat));
dest_lat_radians = math.radians(float(dest_lat));
dist = math.sin(src_lat_radians) * math.sin(dest_lat_radians) + \
math.cos(src_lat_radians) * math.cos(dest_lat_radians) * \
math.cos(math.radians(theta));
dist = math.acos(dist);
#!/usr/bin/python
import zipfile
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser()
(options, args) = parser.parse_args()
zip = zipfile.ZipFile(args[0], mode='r')
include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp = fopen(argv[1], "w");
int b;
fwrite(&b, sizeof(int), 1, fp);
fclose(fp);
}
#0 0x00002b574cba9d59 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib64/libpthread.so.0
#1 0x00002b574a91cc53 in g_once_init_enter_impl ()
from /usr/lib64/libglib-2.0.so.0
#2 0x000000000042538a in mutter_window_get_type ()
at /usr/include/glib-2.0/glib/gthread.h:342
#3 0x00002b574df26b05 in shell_wm_class_intern_init (klass=0x6fa970)
at shell-wm.c:65
#4 0x00002b574a08db9d in g_type_class_ref ()
from /usr/lib64/libgobject-2.0.so.0
#0 0x00007ffff2edbad0 in g_once_init_leave () from /usr/lib64/libglib-2.0.so.0
#1 0x00000000004253d5 in mutter_window_get_type ()
at compositor/compositor.c:233
#2 0x00007fffefa333cf in shell_alt_tab_handler_class_intern_init (
klass=0x6d7a30) at shell-alttab.c:202
#3 0x00007ffff377bb9d in IA__g_type_class_ref (type=<value optimized out>)
at gtype.c:1989
#4 0x00007ffff3e1fe38 in dump_properties (type=7167296, out=0x6d4000)
at gdump.c:94
#5 0x00007ffff3e20264 in g_irepository_dump (arg=<value optimized out>,
#!/usr/bin/python
import math
import transitfeed
from optparse import OptionParser
def latlng_dist(src_lat, src_lng, dest_lat, dest_lng):
if abs(src_lat-dest_lat) < 0.00001 and abs(src_lng-dest_lng) < 0.00001:
return 0.0
theta = src_lng - dest_lng
@wlach
wlach / get-gtfs-date-range.py
Created May 9, 2011 05:49
Simple and stupid python script to get the range of dates covered by its service periods (useful for telling if a feed is way out of date, or will be soon)
#!/usr/bin/python
import os
import sys
from codecs import iterdecode
from zipfile import ZipFile
import csv
import datetime
if len(sys.argv) < 2:
@wlach
wlach / gist:1014595
Created June 8, 2011 15:04
Quick example of a cherrypy server that uses etags
import cherrypy
class HelloWorld(object):
@cherrypy.tools.etags(autotags=True)
def index(self):
cherrypy.response.headers['Content-Type']= 'application/json'
return "{ \"a\": 1 }"
index.exposed = True
@wlach
wlach / gist:1270763
Created October 7, 2011 16:48
jsbridge test script
from __future__ import print_function
import jsbridge
import time
page_loaded_count = 0
animation_finished_count = 0
def page_loaded(obj):
global page_loaded_count
print("Page loaded (count %s)" % page_loaded_count)
class BrowserHandler:
def process_before_start(self):
pass
def process_output_line(self, line):
pass
def process_timeout(self):