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) deleteAllContacts { | |
CNContactStore *contactStore = [[CNContactStore alloc] init]; | |
[contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) { | |
if (granted == YES) { | |
NSArray *keys = @[CNContactPhoneNumbersKey]; | |
NSString *containerId = contactStore.defaultContainerIdentifier; | |
NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId]; | |
NSError *error; | |
NSArray *cnContacts = [contactStore unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error]; |
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 | |
# Include commit rev script by @bsneed | |
buildPlist="${PRODUCT_NAME}-Info.plist" | |
buildCommit=$(/usr/local/git/bin/git --work-tree="${PROJECT_DIR}" show --abbrev-commit | grep "^commit") | |
/usr/libexec/PlistBuddy -c "Add :CFBundleCommit string $buildCommit" $buildPlist | |
if [ $? != 0 ] | |
then | |
/usr/libexec/PlistBuddy -c "Set :CFBundleCommit $buildCommit" $buildPlist | |
fi |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'tweetstream' | |
require 'boxcar_api' | |
SETTINGS = { | |
:key => 'xyz', # Provider Key | |
:secret => 'xyz', # Provider Secret | |
:tweeter => 'macrumorslive' # Whom we'll be following on Twitter | |
:tweeter_id => 1581511, # The tweeter's user id (check their RSS feed) |
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
// | |
// A category on UIViewController that lets you do this: | |
// | |
// [myViewController showInPopoverFromRect:someRect inView:someView]; | |
// | |
// A global instance of the popover controller will be managed by the view controller.. | |
// | |
#import <UIKit/UIKit.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
#!/usr/bin/ruby | |
require 'osx/cocoa' | |
require 'date' | |
OSX.require_framework "AddressBook" | |
filePath = "%%%{PBXFilePath}%%%" | |
fileName = File.basename(filePath) | |
projName = File.basename(File.dirname(filePath)) |
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
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby | |
# - a browser with WebSocket support | |
# | |
# Usage: | |
# ruby redis_pubsub_demo.rb | |
# |
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
class Hash | |
def recursively_symbolize_keys | |
tmp = {} | |
for k, v in self | |
tmp[k] = if v.respond_to? :recursively_symbolize_keys | |
v.recursively_symbolize_keys | |
else | |
v | |
end |
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
// | |
// SynthesizeSingleton.h | |
// CocoaWithLove | |
// | |
// Created by Matt Gallagher on 20/10/08. | |
// Copyright 2009 Matt Gallagher. All rights reserved. | |
// | |
// Permission is given to use this source code file without charge in any | |
// project, commercial or otherwise, entirely at your risk, with the condition | |
// that any redistribution (in part or whole) of source code must retain |
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
// by Wil Shipley | |
// from: http://www.wilshipley.com/blog/2005/10/pimp-my-code-interlude-free-code.html | |
static inline BOOL IsEmpty(id thing) { | |
return thing == nil | |
|| ([thing respondsToSelector:@selector(length)] | |
&& [(NSData *)thing length] == 0) | |
|| ([thing respondsToSelector:@selector(count)] | |
&& [(NSArray *)thing count] == 0); | |
} |
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
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request | |
navigationType:(UIWebViewNavigationType)navigationType { | |
NSLog(@"webView requested: %@ - %@", request, [[request URL] host]); | |
NSURL *requestUrl = [request URL]; | |
if ([[requestUrl host] isEqualToString:OAUTH_REDIRECT_TRIGGER]) { | |
[self completeAccessTokenRequest]; | |
} | |
return YES; | |
} |
NewerOlder