Skip to content

Instantly share code, notes, and snippets.

@nileshpunjabi
nileshpunjabi / ios-build-framework-script.sh
Last active January 2, 2017 05:49
iOS Generate Universal Framework
# For actual device testing, disabled the script running by uncomment following two lines.
##########################################################################################
#echo "SCRIPT RUNNING ABORTED. COMMENT THIS OUT TO GENERATE UNIVERSAL FRAMEWORK"
#exit 0
##########################################################################################
set -e
set +u
# Avoid recursively calling this script.
if [[ $SF_MASTER_SCRIPT_RUNNING ]]
@nileshpunjabi
nileshpunjabi / fix_symlinks_fmk_ios.sh
Created July 11, 2016 14:44 — forked from spawnrider/fix_symlinks_fmk_ios.sh
This script recreate corrupted Symlinks into iOS Frameworks
- (void)fillProfile
{
RevMobAds *revmob = [RevMobAds session];
[[FBRequest requestForGraphPath:@"me?fields=id,gender,age_range,birthday"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error == nil) {
NSString *gender = [result objectForKey:@"gender"];
if (gender != nil)
revmob.userGender = [gender isEqualToString:@"male"] ? RevMobUserGenderMale : RevMobUserGenderFemale;
NSNumber *minAge = [[result objectForKey:@"age_range"] objectForKey:@"min"];
@nileshpunjabi
nileshpunjabi / Text Input Limit By Characterset
Created October 31, 2014 06:03
Textfield input limit by character set
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789+-"] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
return [string isEqualToString:filtered];
}
@nileshpunjabi
nileshpunjabi / LaunchFiles
Last active August 29, 2015 14:07
Launch Image Size iPhone/iPad
PORTRAIT
----------------------------------------------
iPhone Retina HD 5.5 1242×2208
iPhone Retina HD 4.7 750×1334
iPhone Non Retina 3.5 320 x 480
iPhone Retina 3.5 640 x 960 pixels
iPhone Retina 4 inch 640 x 1136 pixels
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
- (void)statusBarFrameOrOrientationChanged:(NSNotification *)notification
{
/*
This notification is most likely triggered inside an animation block,
therefore no animation is needed to perform this nice transition.
@nileshpunjabi
nileshpunjabi / rotate_video.m
Last active October 16, 2018 12:41
Rotate Landscape video
//setting up the first video based on previous recording
CMTimeRange videoDuration = CMTimeRangeMake(kCMTimeZero, [self.previousRecording duration]);
AVAssetTrack *clipVideoTrack = [[self.previousRecording tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
AVAssetTrack *clipAudioTrack = [[self.previousRecording tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
[compositionVideoTrack insertTimeRange:videoDuration ofTrack:clipVideoTrack atTime:nextClipStartTime error:nil];
[compositionAudioTrack insertTimeRange:videoDuration ofTrack:clipAudioTrack atTime:nextClipStartTime error:nil];
//our first track instruction - set up the instruction layer, then check the orientation of the track
//if the track is in landscape-left mode, it needs to be rotated 180 degrees (PI)
AVMutableVideoCompositionLayerInstruction *firstTrackInstruction =
- (BOOL) validateEmail: (NSString *) candidate {
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:candidate];
}
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},