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 "XMLUtils.h" | |
#import <libxml/xmlreader.h> | |
@implementation XMLUtils | |
//... | |
+ (NSString*)rootNodeNameFromURL:(NSURL*)url { | |
NSString* obj = nil; | |
xmlTextReaderPtr reader = xmlReaderForFile( url.absoluteString.UTF8String, |
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
NSString *CurrenySymbolForIso(NSString *isoCode) { | |
NSLocale *locale = [NSLocale currentLocale]; | |
return [locale displayNameForKey:NSLocaleCurrencySymbol value:isoCode]; | |
} | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
NSString *isoCode = @"GBP"; | |
NSString *currency = CurrenySymbolForIso(isoCode); | |
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
<?php | |
// | |
// executeRequest | |
// | |
// uses cURL to run a http(s) request. | |
// data, contentType, user, password are all optional | |
// | |
function executeRequest($target, $data, $contentType, $user, $password, &$http_status) { | |
//try to send request to remote |
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
// | |
// main.m | |
// plutilIdent | |
// | |
// Created by Dominik Pich on 08/04/14. | |
// Copyright (c) 2014 Dominik Pich. All rights reserved. | |
// | |
#import <Foundation/Foundation.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
import Foundation | |
extension Array { | |
func contains<U: Equatable>(object:U) -> Bool { | |
return (self.indexOf(object) != nil); | |
} | |
func indexOf<U: Equatable>(object: U) -> Int? { | |
for (idx, objectToCompare) in self.enumerate() { | |
if let to = objectToCompare as? U { |
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 | |
FILENAME="Localizable.strings" | |
DUPES=`cut -d' ' -f1 "$FILENAME" | sort | uniq -d` | |
while read -r line; do | |
echo "error: $line used multiple times -" | |
done <<< "$DUPES" |
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 | |
@objc | |
class ReflectionHelpers : NSObject { | |
class func getNSNumberForProperty(cls: AnyObject!, name: String!) -> NSNumber! { | |
let m = Mirror(reflecting: cls) | |
let child1 = m.descendant(name) | |
if(child1 != nil) { | |
//bool |
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 | |
# This has to be run from develop (NOTE: if master is your main dev branch, edit the file.) | |
git checkout develop | |
# Update our list of remotes | |
git fetch | |
git remote prune origin | |
# Remove local fully merged branches |
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
//MIT | |
import Foundation | |
import Contacts | |
if(NSProcessInfo.processInfo().arguments.count != 2) { | |
print("Usage: CNPurgeGroup %GROUPNAME%") | |
} | |
else { | |
let groupName = NSProcessInfo.processInfo().arguments[1] |
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
//setup a new task | |
let configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration() | |
let session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: NSOperationQueue.mainQueue()) | |
let task = session.dataTaskWithURL(url, completionHandler: handleUrlCompleted) | |
task.resume() | |
.... | |
//url session needs to accept invalid certificates | |
func URLSession(session: NSURLSession, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) { |