Skip to content

Instantly share code, notes, and snippets.

@alexchantavy
alexchantavy / get_neighborhood_name_from_addr.py
Created December 7, 2015 22:52
uses google's map geocoding api to find neighborhood names of a list of addresses
# uses google's map geocoding api to find neighborhood names of a list of addresses
import json, requests, urllib
addrs = [] # put your own addresses here
result = {}
for addr in addrs:
params = {'address': addr, 'key': api_key}
encoded_req = 'https://maps.googleapis.com/maps/api/geocode/json?%s' % urllib.urlencode(params)
@alexchantavy
alexchantavy / gelocate_nginx_visitors.sh
Created September 1, 2014 15:45
Geolocate nginx visitors
#!/bin/sh
# Geolocate nginx site visitors with geoiplookup.
# Output format = <IP> <Date> <Request> <City of IP>
NGINX_LOG_FILE=/my/log/file/here
cat $NGINX_LOG_FILE | awk '{print $1, $4, $5, $6, $7}' |
while read p ; do
set -- $p
echo "$p ["`geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat "$1" | awk '{print $6, $7, $8, $9, $10, $11}'`"]";
@alexchantavy
alexchantavy / hnfeb.js
Last active August 29, 2015 13:56
Searches HN February "Who's Hiring" listings for jobs located in San Francisco and Mountain View using phantom.js.
var page = require('webpage').create();
// Listener to display console msgs from within page.evaluate()
page.onConsoleMessage = function(msg) {
console.log(msg);
};
// Open HN
page.open('https://news.ycombinator.com/item?id=7162197', function(status) {
if (status === 'success') {
/*
* http://www.reddit.com/r/dailyprogrammer/comments/1heozl/070113_challenge_131_easy_who_tests_the_test
*/
import java.util.*; // '*' cus i was lazy and doing this in a rush
import java.io.*; //ditto
public class Challenge131 {
public static void main (String args[]) {
//args[0] = input file name
try {