Skip to content

Instantly share code, notes, and snippets.

View jeffreyjackson's full-sized avatar
🎺

Jeffrey Jackson jeffreyjackson

🎺
View GitHub Profile
sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;
@jeffreyjackson
jeffreyjackson / gist:6243201485c8cbced707
Created April 9, 2015 14:49
resign .ipa with new CFBundleIdentifier and certificate
//How to resign an .ipa with a new CFBundleIdentifier and certificate
/*
Assumptions
1. .ipa filename is app.ipa
2. app is called MyApp
3. new provisioning profile resides at: ~/Downloads/AdHoc.mobileprovision
4. distribution certificate name is Company Certificate
5. may not need resource-rules parameter
6. provisioning profile is either for Adhoc, or Enterprise distribution
@jeffreyjackson
jeffreyjackson / gist:78785349ed6456a699ad
Created April 8, 2015 15:28
Prevent Screen Dimming
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
@jeffreyjackson
jeffreyjackson / gist:bfbc8f68e4cb1a201fd9
Created April 8, 2015 14:36
Merging 2 NSArrays & Duplicates
//You have two NSArrays and you want to merge them into 1 Array.
//Easy. You need to know about NSSet and maybe a little 'Set Theory'.
NSMutableSet *mergedSet = [NSMutableSet setWithArray:arrayFirst];
[mergedSet unionSet:[NSSet setWithArray:arraySecond]];
//In Set Theory, a union will automatically remove your duplicates. In the case you only wanted to know about duplicates, then take a look at intersectSet:
//Take your new set one step further by sorting them alphabetically with a block:
arraySorted = [[mergedSet allObjects] sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
NSString *first = [a objectForKey:@"identifier"];
- (BOOL)validateEmail:(NSString *)email {
//RFC 2822 Email Implementation
if ([email length] == 0) {
return NO;
}
//Practical Implementation w/ allowing uppercase characters
NSString *emailRegex = @"[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?";
//Alternative for TRUE RFC2822 compliance w/ uppercase characters
//@"(?:[A-Za-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[A-Za-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
@jeffreyjackson
jeffreyjackson / gist:915ecb98a9e9090ff71e
Created April 8, 2015 14:31
Autoincrement Xcode Build
#!/bin/bash
bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
bN=$((bN += 1))
bN=$(printf "%d" $bN)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE"
UIColor *glowColor = [UIColor greenColor];
textLabel.layer.shadowColor = [glowColor CGColor];
textLabel.layer.shadowRadius = 3.0f;
textLabel.layer.shadowOpacity = .8;
textLabel.layer.shadowOffset = CGSizeZero;
textLabel.layer.masksToBounds = NO;
NSString *uuidPatternString = @"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";