This file contains hidden or 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
import json, requests | |
minMagnitude = str(5) | |
theURL = 'https://soda.demo.socrata.com/resource/earthquakes.json?%24where=magnitude%20%3E%20' + minMagnitude | |
fmt = '{datetime} {earthquake_id} {version} {magnitude} {depth:>6} {location[latitude]:>8} {location[longitude]:>8} {region}' | |
for theQuake in json.loads(requests.get(theURL).text): | |
print(fmt.format(**theQuake)) | |
print('=' * 75) |
This file contains hidden or 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/env python | |
import json, requests, pprint | |
minMagnitude = 5.5 | |
rootURL = 'https://soda.demo.socrata.com/resource/' | |
theURL = rootURL + 'earthquakes.json?$where=magnitude>' + str(minMagnitude) | |
fmt = '{datetime} {earthquake_id} {version} {magnitude} {depth:>6} {location[latitude]:>8} {location[longitude]:>8} {region}' | |
def soda2FieldDictFromHeaders(inRequestsHeader): |
This file contains hidden or 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/env python | |
""" | |
Socrata Open Data datasets are cached locally and printed out. | |
Datasets published by City of Austin @ http://data.AustinTexas.gov | |
""" | |
import collections, contextlib, datetime, json, os.path, time | |
import urllib2 |
This file contains hidden or 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/env python | |
""" | |
Socrata Open Data datasets are cached locally and printed out. | |
Datasets published by City of Austin @ http://data.AustinTexas.gov | |
""" | |
import collections, contextlib, datetime, json, os.path, time | |
import urllib2 |
This file contains hidden or 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
import bs4, collections, console, requests, scene | |
tkColorDict = collections.OrderedDict() # key = tkinter color name | |
def loadTkColorDict(): # will automaticly be called by getColor() if needed | |
tkColorURL = 'http://www.tcl.tk/man/tcl8.6/TkCmd/colors.htm' | |
print('Loading tkinter colors from: ' + tkColorURL) | |
tkColorSoup = bs4.BeautifulSoup(requests.get(tkColorURL).text).tbody | |
print('Soup is ready. Creating color table...') | |
for tableRow in tkColorSoup.find_all('tr'): |
This file contains hidden or 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
# an improved version at https://github.com/cclauss/Ten-lines-or-less/blob/master/elapsed_time.py | |
import math, time | |
def elapsedTime(start_time): | |
dt = time.time() - start_time | |
minutes = dt / 60 | |
seconds = dt % 60 | |
centiseconds = math.modf(dt)[0] * 100 | |
return '%02d:%02d.%02d' % (minutes, seconds, centiseconds) |
This file contains hidden or 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
import json, requests, sys #, pprint | |
''' | |
https://github.com/taherh/twitter_application_auth/blob/master/get_bearer_token.py | |
Use get_bearer_token.py (works on Pythonista) to get your Twitter access_token. | |
> You will need to create a new application on https://dev.twitter.com | |
> Enter below the Twitter access_token you get from running get_bearer_token.py | |
''' |
This file contains hidden or 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
import location, webbrowser #, time | |
def getLocation(): | |
location.start_updates() | |
# time.sleep(1) | |
currLoc = location.get_location() | |
location.stop_updates() # stop GPS hardware ASAP to save battery | |
return currLoc | |
def getStreetAddress(loc = getLocation()): |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import scene | |
keyboard_layouts = ( | |
''' | |
q w e r t y u i o p del | |
a s d f g h j k l return | |
z x c v b n m , . shift | |
.?123 space .?123 |
This file contains hidden or 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
Moved to GitHub repo: https://github.com/cclauss/Open_Data |