Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
$home_base_array = array();
$home_base_array[''] = '--select--';
$home_base_array[$this->config->item('site_name')] = $this->config->item('site_name'));
foreach($this->config->item('social_connections') as $connection)
$home_base_array[$connection] = $connection;
@aaronpk
aaronpk / json format for geo data
Created April 30, 2010 16:47
A JSON protocol for sharing and storing real-time data streams. Common use would be for sharing location data.
Common minimal format for sending just lat/long data
[
{
uuid: "550e8400-e29b-41d4-a716-446655440000",
date: "2010-04-30T16:50:00Z",
location: {
position: {
latitude: 45.5118,
longitude: -122.6433
}
{
uuid: "550e8400-e29b-41d4-a716-446655440000",
date: "2010-04-30T16:50:00Z",
location: {
position: {
geojson: {
type: "Point",
coordinates: [-122.643, 45.512]
}
}
SELECT `id`, `description`, `radius`,
( 3959 * ACOS( COS( RADIANS(?) ) * COS( RADIANS( `lat` ) ) * COS( RADIANS( `lng` ) - RADIANS(?) ) + SIN( RADIANS(?) ) * SIN( RADIANS( `lat` ) ) ) ) AS `distance`
FROM `gps_places`
WHERE `startDate` <= NOW() AND `endDate` >= NOW()
HAVING `distance` <= `radius`
ORDER BY `distance`
LIMIT 1
@aaronpk
aaronpk / gist:459618
Created July 1, 2010 05:34
Unexpected access to a protected object property in PHP
<?php
highlight_file(__FILE__);
echo '<hr />';
class A
{
protected $_x = 100;
public static function getX()
<?php
$client = array('client_id' => 'geoloqi_web', 'client_secret' => '1234');
$post = array(
'grant_type' => 'password',
'username' => 'aaronpk',
'password' => '1234'
);
<?php
ob_start();
echo "\n\n\n============\n" . date('Y-m-d H:i:s') . ' ' . $_SERVER['REMOTE_ADDR'] . "\n";
print_r($_GET);
print_r($_POST);
print_r($_SESSION);
print_r(apache_request_headers());
$input = json_decode(file_get_contents("php://input"));
print_r($input);
echo "\n";
@aaronpk
aaronpk / cyborgcamp-tropo.php
Created October 16, 2010 16:07
CyborgCamp volunteer SMS notifications
<?php
include('include.php');
session_start();
$voice = 'allison';
$jsonInput = file_get_contents("php://input");
$input = json_decode($jsonInput);
@aaronpk
aaronpk / gist:825467
Created February 14, 2011 04:05
Google Latitude Example
<?php
include('autoloader.php');
include('OAuth.php');
$googleOAuthConsumerKey = 'aaron.pk';
$googleOAuthConsumerSecret = 'XXXXXXXXXXXXXXXXXXXX';
$oAuthAccessTokenSecret = 'XXXXXXXXXXXXXXXXXXXXXXX';
$oAuthAccessToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
@aaronpk
aaronpk / parser.py
Created February 23, 2011 00:03 — forked from naoyamakino/parser.py
from icalendar import Calendar, Event
import simplejson as json
import re
import web
from mimerender import mimerender
import sys
event = {}
urls = (
'https://api.geoloqi.com/1/place/create', 'place'