Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
require 'rubygems'
require 'socket'
socket = UDPSocket.new
# Encode Latitude (((latitude + 90) / 180) * 4294967296)
# Encode Longitude (((longitude + 180) / 360) * 4294967296)
# Decode Latitude (((latitude / 4294967296) * 180) - 90)
# Decode Longitude (((longitude / 4294967296) * 360) - 180)
@aaronpk
aaronpk / gist:1544351
Created December 31, 2011 15:34
Lowercase MediaWiki Hack

From http://jeffmcneill.com/2007/09/30/lowercase-usernames-namespaces-mediawiki-installation/

http://web.archive.org/web/20071210165719/http://jeffmcneill.com/2007/09/30/lowercase-usernames-namespaces-mediawiki-installation/

Ah, between this article on custom namespaces and a wonderful set of hacks over here and going into the languages.php file, here is what needs to be changed (beyond renaming special files and templates) in order to get an all-lower-case mediawiki installation:

LocalSettings.php

DO NOT CAPITALIZE

@aaronpk
aaronpk / gist:1761119
Created February 7, 2012 18:28
Tries to find a good one-sentence summary from a wikipedia article.
<?php
class WikiLayer {
/*
* wikilayer::getSignificantSentence()
* -----------------------------------
* Grabs the first significant sentence from a wikipedia article
*/
public function getSignificantSentence($id) {
$url = 'http://en.wikipedia.org/w/index.php?curid=' . $id;
$html = $this->get_data($url);
@aaronpk
aaronpk / UIDeviceHardware.h
Created February 26, 2012 18:59 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@aaronpk
aaronpk / gist:2149881
Created March 21, 2012 17:30
download all geoloqi history
<?php
$oauth_token = 'YOUR ACCESS TOKEN';
$points = new StdClass;
$points->points = array(1);
$last = new StdClass;
// Set this to the date you want to start exporting data from
$last->date = '2011-01-01 00:00:00';
@aaronpk
aaronpk / github-post-receive.rb
Created April 8, 2012 19:53
Automatically configure post-receive hooks on all your Github repositories
require 'json'
require 'uri'
require 'httpclient'
require 'redis'
require 'mw-irc'
# First, get an access token for your account on the command line
# curl -d '{"scopes":["repo"],"note":"Post-Receive Hooks"}' -u 'username:******' https://api.github.com/authorizations
# Paste your access token here
@aaronpk
aaronpk / gist:2468855
Created April 23, 2012 04:22
handling geoloqi trigger post hook
<?php
$post = json_decode(file_get_contents("php://input"));
// user id
$post->user->user_id;
// layer id
$post->layer->layer_id;
{
currentTemp: 75,
currentSummary: "rain",
hourSummary: "rain for 20 min",
isPrecipitating: true,
minutesUntilChange: 20,
checkTimeout: 360
}
@aaronpk
aaronpk / gist:2947274
Created June 18, 2012 07:22
Example of using sign up / log in methods of the Titanium SDK
geoloqi.init({
clientId: "xxxxxxx",
clientSecret: "xxxxxxx",
trackingProfile: "OFF", // Don't automatically start tracking
allowAnonymousUsers:false, // Don't automatically create a user when starting up the first time
pushAccount: "example@gmail.com", // Sets the push account to use for Android notifications
pushIcon: "push_icon" // Also required for Android push notifications
}, {
onSuccess:function(e) {
if (geoloqi.session==null) {
@aaronpk
aaronpk / lat,lng,timezone
Created July 21, 2012 20:20
timezone detection database, from geoname 15000.txt
42.50729 1.53414 Europe/Andorra
42.50779 1.52109 Europe/Andorra
25.56473 55.55517 Asia/Dubai
25.78953 55.9432 Asia/Dubai
25.33132 56.34199 Asia/Dubai
25.25817 55.30472 Asia/Dubai
25.61955 56.27291 Asia/Dubai
25.35731 55.4033 Asia/Dubai
24.11028 52.73056 Asia/Dubai
25.11641 56.34141 Asia/Dubai