Skip to content

Instantly share code, notes, and snippets.

@gotomypc
gotomypc / get_lat_lon_exif_pil.py
Created August 15, 2012 05:40 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
@gotomypc
gotomypc / gist:3356643
Created August 15, 2012 05:54 — forked from sillygwailo/gist:2249822
Convert iPhone and BlackBerry latitude and longitudes in Twitter profiles to city name
<?php
/*
* requires the GeoCoder PHP library https://github.com/sillygwailo/GeoCoder
*/
include_once("./GeoCoder/GeoCoder.php");
$f = fopen("File to read here", 'r+');
$o = fopen("File to write here", 'w+');
$g = new GeoCoder('geocoder.ca API key here');
while ($c = fgetcsv($f)) {
if ($c[0] != 'screen_name') {
@gotomypc
gotomypc / Android.mk
Created August 20, 2012 10:11 — forked from kanru/Android.mk
Android GPS using libhardware
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
gps.cpp
LOCAL_SHARED_LIBRARIES := \
libcutils libhardware
LOCAL_MODULE:= test-gps
@gotomypc
gotomypc / gist:3402841
Created August 20, 2012 10:11 — forked from granoeste/gist:1024384
[android][GPS]LocationManager
// copy from http://goo.gl/NxT8B
private LocationManager mLocationManager;
private String mBestProvider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 位置情報サービスマネージャを取得
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# Install gcc44 package and update-alternatives (in chkconfig)
yum -y install gcc44 chkconfig
# Check if gcc is already a link
if [ ! -L /usr/bin/gcc ]; then mv /usr/bin/gcc /usr/bin/gcc41; fi
if [ ! -L /usr/bin/g++ ]; then mv /usr/bin/g++ /usr/bin/g++41; fi
# Install update-alteratives links for gcc41 and gcc44
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc41 60 --slave /usr/bin/g++ g++ /usr/bin/g++41
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc44 40 --slave /usr/bin/g++ g++ /usr/bin/g++44
# Select gcc44 to compile gecode-3.5.0 in chef::bootstrap_server
update-alternatives --config gcc
@gotomypc
gotomypc / index.js
Created October 27, 2012 03:48 — forked from eugenehp/index.js
Chrome scrapper
var express = require('express');
var cp = require('child_process');
var Chrome = require('./lib/chrome');
var Remote = require('./lib/remote');
var app = express.createServer();
app.use(express.bodyParser());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
@gotomypc
gotomypc / reverse-ip-lookup.js
Created October 27, 2012 08:54 — forked from eugenehp/reverse-ip-lookup.js
node.js IP reverse lookup
var dns = require('dns');
function reverseLookup(ip) {
dns.reverse(ip,function(err,domains){
if(err!=null) callback(err);
domains.forEach(function(domain){
dns.lookup(domain,function(err, address, family){
console.log(domain,'[',address,']');
console.log('reverse:',ip==address);
@gotomypc
gotomypc / output
Created October 27, 2012 08:55 — forked from eugenehp/output
parse images
var http = require('http');
var jsdom = require('jsdom');
var url = "http://deathtoglamour.com/articles/695-top-ten-sexiest-exploits-of-uk-olympic-gold-medal-winners-hopefully";
var options = {
host: 'deathtoglamour.com',
port: 80,
path: '/articles/695-top-ten-sexiest-exploits-of-uk-olympic-gold-medal-winners-hopefully',
method: 'GET'
};
@gotomypc
gotomypc / NodeJS web scraper for Anagrams
Created October 28, 2012 03:07 — forked from daithiw44/NodeJS web scraper for Anagrams
NodeJS Web Scraper Anagram Example, written as a test some time ago with early Node Version, seems to still work.
//Web Scraper that scrapes a web page (without permission I may add).
//Simple test using node is all this is, no error handling etc.
//Returns JSON OR XML
//Format : localhost:'PORT'/scrape/'WORD'/'FORMAT'
//Example CURL
//JSON - curl -X GET http://localhost:3000/scrape/fundamental/json
//XML - curl -X GET http://localhost:3000/scrape/fundamental/xml
var express = require('express'),
request = require('request'),