Skip to content

Instantly share code, notes, and snippets.

@gotomypc
gotomypc / get_lat_lon_exif_pil.py
Created Aug 15, 2012 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
View get_lat_lon_exif_pil.py
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 Aug 15, 2012 — forked from sillygwailo/gist:2249822
Convert iPhone and BlackBerry latitude and longitudes in Twitter profiles to city name
View gist:3356643
<?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 Aug 20, 2012 — forked from kanru/Android.mk
Android GPS using libhardware
View Android.mk
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 Aug 20, 2012 — forked from granoeste/gist:1024384
[android][GPS]LocationManager
View gist:3402841
// copy from http://goo.gl/NxT8B
private LocationManager mLocationManager;
private String mBestProvider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 位置情報サービスマネージャを取得
View redis_pubsub_demo.rb
# 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
View rhel-chef-gcc-workaround.sh
# 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 Oct 27, 2012 — forked from eugenehp/index.js
Chrome scrapper
View index.js
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 Oct 27, 2012 — forked from eugenehp/reverse-ip-lookup.js
node.js IP reverse lookup
View reverse-ip-lookup.js
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 Oct 27, 2012 — forked from eugenehp/output
parse images
View output
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 Oct 28, 2012 — 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.
View NodeJS web scraper for Anagrams
//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'),