Skip to content

Instantly share code, notes, and snippets.

View Common-Currency.json
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
View USA_states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
View validateAnEmail.m
- (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];
}
@nileshpunjabi
nileshpunjabi / rotate_video.m
Last active Oct 16, 2018
Rotate Landscape video
View rotate_video.m
//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 =
View window_subview_rotate_by_orientation.m
[[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 / LaunchFiles
Last active Aug 29, 2015
Launch Image Size iPhone/iPad
View LaunchFiles
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
@nileshpunjabi
nileshpunjabi / Text Input Limit By Characterset
Created Oct 31, 2014
Textfield input limit by character set
View Text Input Limit By Characterset
-(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];
}
View gist:24e85b259fd21dc4666c
- (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 / fix_symlinks_fmk_ios.sh
Created Jul 11, 2016 — forked from spawnrider/fix_symlinks_fmk_ios.sh
This script recreate corrupted Symlinks into iOS Frameworks
View fix_symlinks_fmk_ios.sh
@nileshpunjabi
nileshpunjabi / ios-build-framework-script.sh
Last active Jan 2, 2017
iOS Generate Universal Framework
View ios-build-framework-script.sh
# 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 ]]