This file contains hidden or 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/env python | |
# Copyright (c) 2012 Stuart Carnie | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# "Software"), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, | |
# distribute, sublicense, and/or sell copies of the Software, and to | |
# permit persons to whom the Software is furnished to do so, subject to |
This file contains hidden or 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
#!/usr/bin/env python | |
import imaplib | |
import getpass | |
import os | |
import argparse | |
import sys | |
__productname__ = 'grabmsg' | |
__version__ = "0.1" |
This file contains hidden or 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 <UIKit/UIKit.h> | |
@interface UIAlertView (BlocksExtension)<UIAlertViewDelegate> | |
+ (id)alertViewWithTitle:(NSString *)title message:(NSString *)message completionBlock:(void (^)(NSUInteger buttonIndex))block cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; | |
@end |
This file contains hidden or 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
using System; | |
namespace FinalizerTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
for (var i = 0; i < 10000; i++) | |
{ |
This file contains hidden or 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 <objc/runtime.h> | |
// this is called when a keyboard is attached / detached, and | |
// isHardwareAttached will return YES / NO appropriately | |
void hardwareChangeIMP(id aSelf, SEL sel, BOOL isHardwareAttached) { | |
SEL newSel = NSSelectorFromString(@"_modeChange:"); | |
[aSelf performSelector:newSel withObject:[NSNumber numberWithBool:isHardwareAttached]]; | |
} | |
// call this to start capturing hardware changes |
This file contains hidden or 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 RetrieveFriends(GameCenter& gameCenter, GKLocalPlayer* localPlayer) | |
{ | |
[localPlayer loadFriendsWithCompletionHandler:^(NSArray* friends, NSError* error) | |
{ | |
// 1. this block is copied and retained by loadFriendsWithCompletionHandler | |
// 2. When called, loadPlayersForIdentifiers:withCompletionHandler will copy and retain the block below, | |
// which doesn't exist until the outer block is called | |
[GKPlayer loadPlayersForIdentifiers:friends withCompletionHandler:^(NSArray* players, NSError* error2) | |
{ | |
// Finally, dispatch_async will copy and retain the block which is passed to it below |
This file contains hidden or 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 RetrieveFriends(GameCenter& gameCenter, GKLocalPlayer* localPlayer) | |
{ | |
[localPlayer loadFriendsWithCompletionHandler:^(NSArray* friends, NSError* error) | |
{ | |
[GKPlayer loadPlayersForIdentifiers:friends withCompletionHandler:^(NSArray* players, NSError* error2) | |
{ | |
dispatch_async(dispatch_get_main_queue(), ^(void) | |
{ | |
TestLala(gameCenter); //, friends, players, error2); | |
}); |
This file contains hidden or 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/sh | |
read -p "Apple Id: " appleid; echo | |
stty -echo | |
read -p "Password: " passw; echo | |
stty echo | |
while [ /bin/true ]; do | |
curl -u$APPLEID:$PASSW developer.apple.com/devcenter/ios/index.action | grep "soon" | |
if [ $? -eq 1 ]; then | |
growlnotify -m "Done" |
This file contains hidden or 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 <CoreText/CoreText.h> | |
... | |
// preload | |
dispatch_queue_t queue = dispatch_queue_create("com.company.worker", NULL); | |
dispatch_async(queue, ^(void) { | |
NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; | |
[attributes setObject:@"Helvetica" forKey:(id)kCTFontFamilyNameAttribute]; | |
[attributes setObject:[NSNumber numberWithFloat:36.0f] forKey:(id)kCTFontSizeAttribute]; |
This file contains hidden or 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
// credits to Matthias Plappert | |
#import <Foundation/Foundation.h> | |
@interface NSObject (PWBlocks) | |
- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay; | |
@end |