Skip to content

Instantly share code, notes, and snippets.

View davewalk's full-sized avatar
💭
test

Dave Walk davewalk

💭
test
  • Philadelphia, PA
View GitHub Profile
@davewalk
davewalk / gist:5893611
Last active June 15, 2018 18:58
Using Stamen map tiles in Leaflet without loading the tile.stamen.js file
var tonerUrl = "http://{S}tile.stamen.com/toner/{Z}/{X}/{Y}.png";
var url = tonerUrl.replace(/({[A-Z]})/g, function(s) {
return s.toLowerCase();
});
var basemap = L.tileLayer(url, {
subdomains: ['','a.','b.','c.','d.'],
minZoom: 0,
maxZoom: 20,

Keybase proof

I hereby claim:

  • I am davewalk on github.
  • I am dw (https://keybase.io/dw) on keybase.
  • I have a public key whose fingerprint is 685C 6EA6 9873 053B C256 451A DEB5 3CEF 3344 FDF6

To claim this, I am signing this object:

@davewalk
davewalk / convert.py
Last active January 5, 2017 22:24
Convert state plane PA South coordinates to lat/longs
import pyproj
def convert(x, y):
state_plane = pyproj.Proj(init='epsg:2272', preserve_units=True)
wgs = pyproj.Proj(proj='latlong', datum='WGS84', ellps='WGS84')
lng, lat = pyproj.transform(self.state_plane, self.wgs, x, y)
return lat, lng
@davewalk
davewalk / gist:05b9a6614e2b5fe9b640
Created May 6, 2014 18:09
Python standard logging module
import logging
from logging import handlers
logger = logging.getLogger()
# Change logging level here (CRITICAL, ERROR, WARNING, INFO or DEBUG)
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
# Logging variables
@davewalk
davewalk / account.cfg
Last active August 29, 2015 14:01
Python standard config module
[login]
password = abc123
@davewalk
davewalk / gist:59a438325fca5214f3de
Last active August 29, 2015 14:05
Dumb JS object debugging in NodeJS
var util = require('util'),
fs =require('fs');
// Print a nested object to the console for full inspection
console.log(util.inspect(data, showHidden=false, depth=16, colorize=true));
// Print a thing to a file
fs.writeFile('debug.txt', aThing, function(err) {
if (err) console.log('Write error for some reason!');
});
@davewalk
davewalk / gist:5211e7db094cee5082ca
Created September 18, 2014 15:40
mySQL metadata queries
# Get the charset of a table
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
AND T.table_schema = "schemaname"
AND T.table_name = "tablename";
# Get a bunch of details about a table including its collation
SHOW TABLE STATUS IN dbname like 'tablename'
@davewalk
davewalk / gist:64a6621db86adc8ebb75
Created October 15, 2014 17:50
Allow access to your stuff from a U.S. IP or a local IP (you know, for a load balancer or something) in Nginx
geoip_country /usr/share/GeoIP/GeoIP.dat;
map $geoip_country_code $allowed_country {
default no;
US yes;
}
geo $inNet {
default no;
10.0.0.0/8 yes;
@davewalk
davewalk / docker bulk container delete
Created March 14, 2015 23:42
Remove old Docker containers in bulk that from "weeks ago". Can obviously be edited to delete on a different string. Originally from https://twitter.com/jpetazzo/status/347431091415703552 via http://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers
docker ps -a | grep "weeks ago" | awk '{print $1}' | xargs docker rm
@davewalk
davewalk / gist:69e0bd8fd1b4e0c2db81
Created April 28, 2015 20:55
Save all of the AWS EC2 IP ranges for a given region using jq (more info: http://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html)
cat ip-ranges.json | jq '.prefixes' | jq '.[]' | jq '.service = "EC2"' | jq '.region = "us-east-1"' | jq '.ip_prefix' > ec2-us-east-1-ranges.txt