Skip to content

Instantly share code, notes, and snippets.

(barkingowl)administrator@anna:~/dev/sql2api/scripts$ fedmsg-config
Traceback (most recent call last):
File "/home/administrator/.virtualenvs/barkingowl/bin/fedmsg-config", line 4, in <module>
fedmsg.commands.config.config()
File "/home/administrator/.virtualenvs/barkingowl/local/lib/python2.7/site-packages/fedmsg/commands/config.py", line 26, in config
config = fedmsg.config.load_config([], __doc__)
File "/home/administrator/.virtualenvs/barkingowl/local/lib/python2.7/site-packages/fedmsg/config.py", line 152, in load_config
raise ValueError("No config value 'endpoints' found.")
ValueError: No config value 'endpoints' found.
(barkingowl)administrator@anna:~/dev/sql2api/scripts$
def geocodemq(address):
key = "Fmjtd%7Cluub2gurll%2C8w%3Do5-9uagq4"
vals = {'location': address}
qstr = urllib.urlencode(vals)
#print "QSTR = '{0}'".format(qstr)
reqstr = "http://www.mapquestapi.com/geocoding/v1/address?key={0}&outFormat=json&maxResults=1&{1}".format(key,qstr)
#print "Sending: {0}".format(reqstr)
_json = simplejson.loads(urllib.urlopen(reqstr).read())
return _json
#include <stdio.h>
#define LENGTH 99
#define MISSING_NUMBER 47
int main()
{
// vars
int numbers[LENGTH];
int missingnumber = -1;
@thequbit
thequbit / gist:7762342
Created December 3, 2013 01:27
Rochester City Neighborhood GeoJSON? Maybe?
GAddCopyright("m","16594126484873845410",43.0647,-78.0077,43.3035,-77.2187,11,"Google",11,false);
GAddCopyright("k","9223630303596154971",43.0647,-78.0077,43.3035,-77.2187,11,"TerraMetrics",11,false);
GAddCopyright("k","11955203846863391525",-90.0000,-180.0000,90.0000,180.0000,0,"",19,false);
GAddCopyright("k","4565752688697377595",-90.0000,-180.0000,90.0000,180.0000,0,"",9,false);
GAddCopyright("k","1430798344457654368",-90.0000,-180.0000,90.0000,180.0000,0,"",8,false);
GAddCopyright("k","17565615998743351574",-84.3750,-180.0000,84.3750,180.0000,0,"",14,false);
GAddCopyright("k","11350805467989226148",12.0000,-127.0000,47.0000,-57.0000,0,"",14,false);
GAddCopyright("k","3035392783884246871",41.3086,-85.6055,48.8672,-67.3242,0,"",16,false);
GAddCopyright("k","11657524632733150381",40.3935,-78.1985,45.0777,-71.5930,0,"",17,false);
GAddCopyright("k","5922223813155577633",40.3936,-78.1985,45.0776,-71.5931,0,"",17,false);
@thequbit
thequbit / gist:7831084
Created December 6, 2013 19:51
Use Map Quest to geocode an address. You will need to sign up for a key here: http://developer.mapquest.com/
def geocodemq(address):
key = ""
vals = {'location': address}
qstr = urllib.urlencode(vals)
#print "QSTR = '{0}'".format(qstr)
reqstr = "http://www.mapquestapi.com/geocoding/v1/address?key={0}&outFormat=json&maxResults=1&{1}".format(key,qstr)
#print "Sending: {0}".format(reqstr)
_json = simplejson.loads(urllib.urlopen(reqstr).read())
return _json
inputdata = ""
with open("dunkindonuts_raw.json","r") as f:
json = f.read()
json = json.encode("ascii","ignore")
inputdata = simplejson.loads(json)
(tapir)administrator@anna:~/dev/tapir/data$ python gendd.py
Traceback (most recent call last):
File "gendd.py", line 8, in <module>
json = json.encode("ascii","ignore")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa9 in position 4783337: ordinal not in range(128)
{"results":[{"locations":[{"latLng":{"lng":-77.715289,"lat":43.02724},"adminArea4":"Monroe County","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"West Henrietta","street":"79 Harrogate Xing","adminArea1":"US","adminArea3":"NY","type":"s","displayLatLng":{"lng":-77.715256,"lat":43.027111},"linkId":0,"postalCode":"14586-9473","sideOfStreet":"R","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"ADDRESS","geocodeQualityCode":"L1AAA","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luubn1u2ll,rg=o5-90bl9f&type=map&size=225,160&pois=purple-1,43.02724,-77.715289,0,0|&center=43.02724,-77.715289&zoom=15&rand=-277786938","adminArea3Type":"State"}],"providedLocation":{"location":"79 Harrogate Crossing,14586"}}],"options":{"ignoreLatLngInput":false,"maxResults":1,"thumbMaps":true},"info":{"copyright":{"text":"© 2013 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"© 2013 MapQuest, Inc."},"statuscode":0,"messages":[]}}
function plotCrime(coords,crimeID){
var marker = L.marker([coords[0], coords[1]]).addTo(map).on('click',function(){
generateCrimeData(marker.myId,coords);
marker.setIcon(highlightedIcon);
if(currentlyClicked == null){
currentlyClicked = marker;
console.log("The currently clicked marker: " + currentlyClicked);
}else{
currentlyClicked.setIcon(markerIcon);
console.log("Resetting to the default icon.");
def sendtoelasticsearch(self,targeturl,docurl,pdftext,pdfhash,scrapedatetime):
Where:
targeturl = "http://henrietta.org/" # the root url that was scraped
docurl = "http://henrietta.org/mydoc.pdf" # the url of the pdf document
pdftext = <the converted text of the pdf>
pdfhash = md5(pdftext)
scrapedatetime = the datetime of when the pdf was scraped/downloaded
I would like to send the text to elastic search for it to be indexed so I can perform queies on it from a website.