This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (CGRect) */ function CGRectInsetFromEdges (aRect, offsetTop, offsetRight, offsetBottom, offsetLeft) { | |
return CGRectMake( | |
aRect.origin.x - offsetLeft, | |
aRect.origin.y - offsetBottom, | |
aRect.size.width + offsetLeft + offsetRight, | |
aRect.size.height + offsetBotttom + offsetTop, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- In Mail, create a new rule, then add “Run AppleScript” to the list of actions to perform. Notice that the buddy name and the service index are both hard-coded. | |
using terms from application "Mail" | |
on perform mail action with messages newMessages for rule theRule | |
repeat with newMessage in newMessages | |
set senderName to (extract name from sender of newMessage) | |
set subjectText to (subject of newMessage) | |
set contentText to (content of newMessage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Number.prototype.toRad === undefined) | |
Number.prototype.toRad = /* (Number) */ function () { return this * Math.PI / 180; } | |
function MKGeographicalDistanceBetweenCoordinates (fromCoords, toCoords) { | |
if (CLLocationCoordinate2DEqualToCLLocationCoordinate2D(fromCoords, toCoords)) | |
return 0; | |
// Vincenty Inverse Solution. | |
// Google Maps API v3 does not provide distance calculation, so we have to roll our own. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @oldsite='http://monoceroi.com', @newsite='http://iridia.tw'; | |
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite); | |
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) handleKeyboardNotification:(NSNotification *)inNotification { | |
if (!self.contentView) | |
return; | |
CGRect (^rectFromScreenRect) (CGRect inRect) = ^ (CGRect inRect) { return [self.view convertRect:[self.view.window convertRect:inRect fromWindow:nil] fromView:nil]; }; | |
id (^notificationObject) (id inKey) = ^ (id inKey) { return [inNotification.userInfo objectForKey:inKey]; }; | |
CGRect (^rectFromValue) (id inValueObject) = ^ (id inValueObject) { return [((NSValue *)inValueObject) CGRectValue]; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
basePathString := '/Volumes/Data/Library/Application Support/iPhone Simulator/4.2/Applications/D1AB6AEB-6123-447B-A55F-A14603BA22FF/' | |
modelName := 'MLTwitterModel.momd' | |
storeName := 'twitter.evadne.sqlite' | |
modelURL := (NSURL fileURLWithPath:((basePathString stringByAppendingString:'Milk.app/') stringByAppendingString:modelName)) | |
storeURL := (NSURL fileURLWithPath:((basePathString stringByAppendingString:'Documents/') stringByAppendingString:storeName)) | |
coordinator := NSPersistentStoreCoordinator alloc initWithManagedObjectModel:((NSManagedObjectModel alloc initWithContentsOfURL:modelURL) autorelease) | |
coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CoreGraphics/CGBase.h> | |
#define irDump(aCGStruct) NSLog(@"%@", irDumpImpl(@encode(__typeof__(aCGStruct)), &aCGStruct)) | |
#define irDumpLog(aCGStruct,...) NSLog(@"%@: %@", irDumpImpl(@encode(__typeof__(aCGStruct)), &aCGStruct), [NSString stringWithFormat:__VA_ARGS__]) | |
CG_INLINE NSString* irDumpImpl (const char *encodedString, void * aPointer) { | |
if (strcmp(encodedString, @encode(CGRect)) == 0) | |
return NSStringFromCGRect(*(CGRect*)aPointer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// IRManagedObject.h | |
// Milk | |
// | |
// Created by Evadne Wu on 1/11/11. | |
// Copyright 2011 Iridia Productions. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import "IRFoundationAdditions.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation IRWebViewController (irFullscreenMediaPlaybackAutorotationLayoutFix) | |
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { | |
// There is a bug, where launching a media player from the web view, fullscreening it, then rotating the device, and tapping on the media to see the timelime, causes the layout to go all berserk. This is a hack to combat that. | |
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; | |
if ((!self.view.superview) || (self.parentViewController.modalViewController != self) || (self.modalPresentationStyle != UIModalPresentationFullScreen)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation IRSampleTableViewController : MPCompanionedViewController | |
// Assume that you work within -loadView, and assume arrayController is an CPArrayController somewhere | |
- (int) numberOfRowsInTableView:(CPTableView)inTableView { | |
return [[arrayController contentArray] count] || 0; | |
} |