Skip to content

Instantly share code, notes, and snippets.

View AJRenold's full-sized avatar

AJ Renold AJRenold

  • San Francisco, CA
View GitHub Profile
{"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
@AJRenold
AJRenold / gist:5416406
Last active December 16, 2015 09:58
Find a wikipedia article. Example called at bottom.
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())
@AJRenold
AJRenold / gist:4391590
Last active December 10, 2015 05:58
Solution from about_proxy_object_project.py https://github.com/gregmalcolm/python_koans
## 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):
@AJRenold
AJRenold / gist:4171988
Created November 29, 2012 21:19
Returning MySQL query data in a csv file with Flask
## 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