Skip to content

Instantly share code, notes, and snippets.

View andrewljohnson's full-sized avatar

Andrew L. Johnson andrewljohnson

View GitHub Profile
def get_point_photos(request, lat, lon, name):
'''takes a lat lon pair via an ajax request, and returns a list of photos'''
#create a Flickr API object
f = flickrapi.FlickrAPI(api_key)
#resolve a (lat,long) to a "Flickr Place" which can be used to search for photos.
place = f.places_findByLatLon(api_key = api_key, lat=lat, lon = lon)
#get the id of the Flickr Place returned
place_id = place.find('places').findall('place')[0].attrib['place_id']
#returns an XML response that contains data to construct photo URLs
flickr_search = f.photos_search(api_key = api_key, place_id = place_id, content_type = '1', tags = 'nature, landscape, hiking, outdoors,
@andrewljohnson
andrewljohnson / ZoomScale
Created May 14, 2014 17:09
calculate scale from TMS/Google/OSM zoom level
double latitude = self.mapView.mapCenter.latitude;
metersPerPixel *= cos(latitude * (M_PI / 180));
double metersPerUnit = 1609.344;
int numberOfUnits = 1;
NSString *unitName = MILES_UNIT_STRING;
if (metersPerPixel < (1000/maxScaleSize)) {
unitName = METERS_UNIT_STRING;
metersPerUnit = 1;
} else {
unitName = KILOMETERS_UNIT_STRING;
on run {input, parameters}
tell application "Terminal"
set currentTab to do script ("ps ax | grep jekyll | grep -v grep | awk '{ print $1 }' | xargs kill") in front window
set currentTab to do script ("jekyll serve --detach;") in front window
end tell
tell application "Google Chrome"
activate
set theUrl to "http://0.0.0.0:4000/"
@andrewljohnson
andrewljohnson / make_gaia_map_source.py
Created September 2, 2015 03:41
Make a URL that imports a TMS map source into Gaia GPS
#!/usr/local/bin/python
import sys
import urllib
'''
make a URL that imports a TMS map source into Gaia GPS
example
@andrewljohnson
andrewljohnson / globalmaptiles.py
Last active March 21, 2016 05:01 — forked from tucotuco/globalmaptiles.py
Classes to calculate Tile coordinates
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
@andrewljohnson
andrewljohnson / download_naips.py
Created March 24, 2016 04:45
download a naip from an s3 RquesterPayer bucket, using boto3
import boto3
def download_naips(self):
s3_client = boto3.client('s3')
filename = 'm_3807708_ne_18_1_20130924.tif'
s3_client.download_file('aws-naip', 'md/2013/1m/rgbir/38077/{}'.format(filename), filename, {'RequestPayer':'requester'})
root@8e3b54c9c353:/code# python manage.py shell < real_estate/scripts/generate_neural_net.py
fetching AnalysisRecords took 0.0015499591827392578
Fetched 15577 records for properties.
annotating years and months took 1.1473767757415771
making value map took 11.682528972625732
Using 15573 properties for analysis.
making model took 0.3301811218261719
Model: "model"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
root@8e3b54c9c353:/code# python manage.py shell < real_estate/scripts/generate_neural_net.py
fetching AnalysisRecords took 0.0015206336975097656
Fetched 47555 records for properties.
2183530944 - Hashing AnalysisRecords took 3.006469964981079
annotating years and months took 3.25303053855896
making value map took 36.68412470817566
Using 47550 properties for analysis.
4202095867 - data_hash
4036931971 - value_map_hash
making model took 0.8455119132995605
import datetime
import math
import numpy as np
import pandas as pd
import pickle
import time
from django.db.models.functions import Cast
from django.db.models import IntegerField
from real_estate.models import AnalysisRecord
#include <iostream>
using namespace std;
// Current Cards
// Mountain
// Future Cards
// Forest
// Lightning Bolt, Giant Growth, Earthquake