Skip to content

Instantly share code, notes, and snippets.

View spoletto's full-sized avatar

Stephen Poletto spoletto

  • San Francisco, CA
View GitHub Profile
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) bills.php?id=$1 [L]
ErrorDocument 404 /404.html
<?php
include('bitly.php');
$bitly = new bitly('username', 'apikey');
$expanded = $bitly->expand('http://bit.ly/'.htmlspecialchars($_GET['id']));
if (substr($expanded, 0, 30) == 'http://billr.s3.amazonaws.com/') {
echo '<img src="'.$expanded.'" id="sharedbill" width="640px" />';
} else {
echo '<img src="/images/missing.png" id="sharedbill" width="640px" />';
}
?>
@spoletto
spoletto / gist:3725118
Created September 14, 2012 21:47
iOS 6 Autorotation Swizzling
@implementation AppDelegate
void SwapMethodImplementations(Class cls, SEL left_sel, SEL right_sel) {
Method leftMethod = class_getInstanceMethod(cls, left_sel);
Method rightMethod = class_getInstanceMethod(cls, right_sel);
method_exchangeImplementations(leftMethod, rightMethod);
}
+ (void)initialize {
if (self == [AppDelegate class]) {
#ifdef __IPHONE_6_0
@spoletto
spoletto / gist:9383098
Created March 6, 2014 05:23
The undocumented behavior of ALAssetPropertyDate
/*
* In practice, what I've found is that ALAssetPropertyDate, which is documented as the "asset creation time"
* will return (always in UTC):
*
* (1) If taken from the native camera, a ms-precision time of when the photo was taken.
* (2) If EXIF exists, EXIF time converted to UTC based on the timezone the device was in when
* the photo was saved to the camera roll. This is sec-precision.
* (3) If EXIF does not exist, the time the photo was written into the camera roll. This is sec-precision.
*/
NSDate *timeTaken = [asset valueForProperty:ALAssetPropertyDate];
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN