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
{"type":"Topology","objects":{"ca-counties":{"type":"GeometryCollection","properties":{"kind":"state","state":"ca"},"geometries":[{"type":"Polygon","bbox":[-122.3296,37.4548,-121.4697,37.904],"properties":{"name":"Alameda"},"arcs":[[0,1,2,3,4,5]]},{"type":"Polygon","bbox":[-120.0731,38.3257,-119.5418,38.9336],"properties":{"name":"Alpine"},"arcs":[[6,7,8,9,10,11]]},{"type":"Polygon","bbox":[-121.026,38.2216,-120.0731,38.7036],"properties":{"name":"Amador"},"arcs":[[12,13,14,15,-10]]},{"type":"Polygon","bbox":[-122.0667,39.2951,-121.0753,40.1495],"properties":{"name":"Butte"},"arcs":[[16,17,18,19,20,21]]},{"type":"Polygon","bbox":[-120.9932,37.8328,-120.0183,38.5119],"properties":{"name":"Calaveras"},"arcs":[[22,23,24,-13,-9]]},{"type":"Polygon","bbox":[-122.7841,38.9227,-121.7983,39.4156],"properties":{"name":"Colusa"},"arcs":[[-20,25,26,27,28]]},{"type":"Polygon","bbox":[-122.4281,37.7177,-121.5354,38.1011],"properties":{"name":"Contra Costa"},"arcs":[[29,-6,30,31,32]]},{"type":"Polygon","bbox":[-124.2574,41 |
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
from bs4 import BeautifulSoup, NavigableString, Tag | |
from urllib2 import urlopen | |
import json | |
def check_dbpedia(term): | |
api = 'http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?MaxHits=10&QueryString=' | |
#api = 'http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?MaxHits=10&QueryString=' | |
response = urlopen(api+term) | |
soup = BeautifulSoup(response.read()) | |
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
## call as: | |
## Proxy(YourObject()) | |
class Proxy: | |
def __init__(self, target_object): | |
print("initializing proxy for "+target_object.__class__.__name__) | |
self._log = [] | |
self._obj = target_object | |
def __getattr__(self,attr): |
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
## I'm working on a project using Flask to access a database and then | |
## pass on query data to a client where the data will be graphed | |
## in the browser. | |
## I wanted to enable users to retrieve the graph data | |
## in a csv file after clicking a button on the client. | |
## This is a generalized version of how I did it: | |
# imports other than Flask | |
import csv | |
from sqlalchemy import create_engine |