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
#!/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
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
''' | |
create three background images in scene.setup() then in | |
scene.draw() use the x coordinate of the user's drag | |
location to determine which background image to display | |
''' | |
import scene | |
from PIL import Image, ImageDraw, ImageFont | |
theMessage = 'Drag the grey circle left and right to switch between the background images.' |
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
# beazleyCodeDownload.py | |
# | |
# copy source code from http://www.dabeaz.com | |
# into local directory David_Beazley | |
import bs4, os, requests | |
codeBases = ('coroutines', 'generators', 'pydata', | |
'python3io', 'usenix2009/concurrent') | |
baseURLFmt = 'http://www.dabeaz.com/{}/' |
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
# helloBarcode - ZBar delivers barcode data to Pythonista | |
programName = sys.argv[0].rpartition('/')[2] | |
theBarcode = sys.argv[1] if len(sys.argv) > 1 else None | |
fmt = '{} was launched with barcode: {}' | |
print(fmt.format(programName, theBarcode)) | |
# Save this file in Pythonista as 'helloBarcode'. | |
# Download free app ZBar from the iTunes App Store. | |
# Launch ZBar on your device. | |
# Scan the barcode on a book, coke can, whatever. |
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
# Current version at https://gist.github.com/cclauss/6656495 | |
import console | |
addPrompt = """Item to be added to the list? | |
or [M] to return to the main menu:""" | |
removePrompt = """Item to be removed from the list? | |
or [M] to return to the main menu:""" | |
def writeListToFile(inFileName, inList): |
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 | |
# create a BeautifulSoup by reading in a webpage | |
# Current varsion at https://gist.github.com/cclauss/6648735 | |
# usage: | |
# from soupFromURL import soupFromURL | |
# theSoup = soupFromURL('http://www.python.org') | |
import bs4 | |
useRequests = False # "Python HTTP: When in doubt, or when | |
try: # not in doubt, use Requests. Beautiful, |
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
# Display the current clipboard text in full screen mode | |
import clipboard, console, scene | |
clipText = clipboard.get() | |
if not clipText: | |
clipText = """Hang up your cellphone and drive your car!!!""" | |
zclipText = """Please take me home...""" | |
class MyScene(scene.Scene): | |
def setup(self): | |
(imageName, imageSize) = self.getImageNameAndSize() |