This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import subprocess | |
def right_network (fqdn): | |
""" | |
# Example of using 'dig' to find the IP address of a network IP address | |
$ dig -4 +short www.example.com | |
24.209.187.117 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def map_stop_times_to_dict(gtfs_file, list_of_stops): | |
""" | |
The stop_times.txt table can be *huge*, and can eat all your RAM | |
as 100MB of string data gets split into 1GB of dict data. | |
Instead, load the table in chunks, and filter it for the content | |
we want before loading the next chunk. | |
Reducing the huge stop_times file by ~95% also has the side effect | |
of cutting the script runtime in half. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def map_gtfs_table_to_dict(gtfs_file, table_name): | |
""" | |
Read data from a GTFS table, map the data into a list or dict for | |
easier iteration or searching or other use. Each line of the table | |
is mapped into a separate subdict, with a unique key. | |
Many GTFS tables include a unique value (Example: trips_id in the | |
trips.txt table) that this function automatically uses as the | |
dict key. If a tables has no unique key (Example: calendar_dates.txt), | |
the system generates a unique key using an incrementing row counter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
tkentrycomplete.py | |
A tkinter widget that features autocompletion. | |
Created by Mitja Martini on 2008-11-29. | |
Converted to Python3 by Ian weisser on 2014-04-06. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import curses | |
import time | |
import threading | |
class Clock(threading.Thread): | |
""" Clock curses string class. Updates every second. Easy to install """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Check a GTFS file's calendar and calendar_dates tables. | |
Return True if the dates are current or future. | |
Return False if all dates are in the past and the GTFS file | |
can be safely deleted. | |
This is a working example. Try it. Edit the path to match your GTFS file. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Locate stop_id candidates from a GTFS stops file. | |
This is a helper application. You use it to discover a list | |
of possible stop_ids for your *real* application. It's handy | |
during debugging, or during setup of an application. | |
Example: You know an intersection name or a lat/lon pair or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import tkinter | |
import time | |
""" | |
Example tkinter Clock widget, counting seconds and minutes in realtime. | |
Functions just like a Label widget. |