This gist has moved to https://github.com/0xced/ABGetMe
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
#import <Carbon/Carbon.h> | |
#import <dlfcn.h> | |
/* | |
* Returns an array of CFDictionaryRef types, each of which contains information about one of the processes. | |
* The processes are ordered in front to back, i.e. in the same order they appear when typing command + tab, from left to right. | |
* See the ProcessInformationCopyDictionary function documentation for the keys used in the dictionaries. | |
* If something goes wrong, then this function returns NULL. | |
*/ | |
CFArrayRef CopyLaunchedApplicationsInFrontToBackOrder(void) |
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
#import <IOKit/graphics/IOGraphicsLib.h> | |
#import <IOKit/graphics/IOGraphicsTypes.h> | |
NSString* screenNameForDisplay(CGDirectDisplayID displayID) | |
{ | |
NSString *screenName = nil; | |
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); | |
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; |
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
#import <Foundation/Foundation.h> | |
#import <dlfcn.h> | |
#import <mach/vm_map.h> | |
#import <mach-o/dyld.h> | |
#import <mach-o/nlist.h> | |
#if defined(__i386__) || defined(__x86_64__) |
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
/* | |
* CLAlert is a drop-in replacement for NSAlert | |
* | |
* A CLAlert is exactly the same as a NSAlert, except for the alert style behavior | |
* | |
* - An alert with the informational style (NSInformationalAlertStyle) will always display a "Note icon" (kAlertNoteIcon) | |
* - An alert with the warning style (NSWarningAlertStyle) will always display a "Caution icon" (kAlertCautionIcon) | |
* - An alert with the critical style (NSCriticalAlertStyle) will always display a "Stop icon" (kAlertStopIcon) | |
* | |
* Tested on Mac OS X 10.5.8, 10.6.1 and 10.11.5 |
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
#!/bin/bash | |
cd ~/Library/Application\ Support/MobileSync/Backup | |
backup=`ls -t1 | sed -n '1p'` # most recent backup | |
for f in "$backup"/*.mdinfo; do | |
grep -q "Library/AddressBook/AddressBook.sqlitedb" $f | |
if [ $? -eq 0 ]; then | |
addressbook=`basename $f .mdinfo` | |
cp -v "`pwd`/$backup/$addressbook.mddata" ~/Library/Application\ Support/iPhone\ Simulator/User/Library/AddressBook/AddressBook.sqlitedb | |
exit $? |
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
#!/bin/bash | |
while true; do | |
curl --silent http://store.apple.com | grep --silent "backsoon" | |
if [ $? -ne 0 ]; then | |
growlnotify --sticky --name 'Apple Store' --image ~/Pictures/Apple.tiff --message 'Apple Store is now open!' | |
exit 0 | |
fi | |
sleep 60 | |
done |
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
@try | |
{ | |
id textView = [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.textView"]; | |
if ([textView respondsToSelector:@selector(becomeFirstResponder)]) | |
[textView becomeFirstResponder]; | |
} | |
@catch (NSException *e) {} |
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
/* | |
* NSMutableURLRequest+CaseSensitive is a category on NSMutableURLRequest | |
* that let you control the exact value of the HTTP header fields. | |
* | |
* NSMutableURLRequest documentation says: | |
* "The name of the header field to set. In keeping with the HTTP RFC, | |
* HTTP header field names are case-insensitive." | |
* | |
* Unfortunately, not all HTTP implementations are RFC compliant and some | |
* require case-sensitive header fields. To set such headers, use the |
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
/* | |
* Adds the serialNumber property to the UIDevice class | |
* | |
* The implementation uses undocumented (for iOS) IOKit functions, | |
* so handle with caution and be prepared for nil. | |
*/ | |
#import <UIKit/UIDevice.h> | |
@interface UIDevice (serialNumber) |
OlderNewer