Skip to content

Instantly share code, notes, and snippets.

Muhammad Ishaq ishaq

Block or report user

Report or block ishaq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am ishaq on github.
  • I am ishaq (https://keybase.io/ishaq) on keybase.
  • I have a public key whose fingerprint is 8968 BA0F 9581 CF68 707F 13B8 A192 A810 3511 3085

To claim this, I am signing this object:

View DaysToNextBirthday.swift
class func daysToNextBirthday(birthdate: NSDate?) -> Int {
if (birthdate != nil) {
}
else {
return Int.max
}
let calender = NSCalendar.currentCalendar()
let now = NSDate()
let nowComponents = calender.components(NSCalendarUnit.MonthCalendarUnit | NSCalendarUnit.DayCalendarUnit | NSCalendarUnit.YearCalendarUnit, fromDate: now)
@ishaq
ishaq / ArchiveHousekeeper.sh
Created Jun 10, 2014
This script stops the build if git repository has uncommitted changes, useful when archiving because it makes sure releases (Archives) are created from a clean tree. Put this script in a target (say ArchiveHousekeeper) and update target scheme's Build section to add ArchiveHousekeeper as dependency for Archive operation.
View ArchiveHousekeeper.sh
#!/bin/sh
if [ -z "$(git status --porcelain)" ]; then
echo "Working directory clean, proceding to Archive"
exit 0
else
echo "error: Working directory dirty, stopping build"
exit 1
fi
@ishaq
ishaq / SortedCountryCodes.m
Last active Aug 29, 2015
Get a list of all country codes sorted by their localised names
View SortedCountryCodes.m
+ (NSArray *)getSortedCountryCodes {
NSLocale *locale = [NSLocale currentLocale];
NSArray *countryArray = [NSLocale ISOCountryCodes];
NSMutableDictionary *countriesDictionary = [[NSMutableDictionary alloc] initWithCapacity:countryArray.count];
for (NSString *countryCode in countryArray) {
NSString *localizedCountryName = [locale displayNameForKey:NSLocaleCountryCode value:countryCode];
countriesDictionary[countryCode] = localizedCountryName;
}
@ishaq
ishaq / NSDate+dateByRemovingFractionalSeconds.h
Created May 7, 2014
category to remove fractional seconds from an NSDate
View NSDate+dateByRemovingFractionalSeconds.h
#import <Foundation/Foundation.h>
@interface NSDate (dateByRemovingFractionalSeconds)
+ (NSDate *)dateWithoutFractionalSeconds;
- (NSDate *)dateByRemovingFractionalSeconds;
@end
@ishaq
ishaq / AppDelegate.m
Last active Sep 6, 2018
iOS: load main interface programmatically
View AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *mainStoryboard = nil;
BOOL showLogin = NO;
if(showLogin == NO)
{
// mainStoryboard method looks like:
// return [UIStoryboard storyboardWithName:@"Main" bundle:nil];
@ishaq
ishaq / NSDate+FormattedString.h
Last active Dec 28, 2015
NSString from NSDate and vice versa
View NSDate+FormattedString.h
#import <Foundation/Foundation.h>
@interface NSDate (FormattedString)
- (NSString *)mi_dateStringWithStyle:(NSDateFormatterStyle)style
timeStyle:(NSDateFormatterStyle)timeStyle;
- (NSString *)mi_dateStringWithFormat:(NSString *)format;
- (NSString *)mi_isoDateString;
- (NSString *)mi_ecma262DateString;
@end
@ishaq
ishaq / NSString+Kahaf.h
Last active Dec 28, 2015
useful NSString functions
View NSString+Kahaf.h
#import <Foundation/Foundation.h>
/**
* this category contains functions that either work on `NSString` or return `NSString`. The category is called <b>Kahaf</b>
* because these functions don't exactly fit into any other single category.
*/
@interface NSString (Kahaf)
/**
* Creates and returns a new UUID with RFC 4122 version 4 random bytes.
@ishaq
ishaq / KUtils.h
Last active Apr 16, 2019 — forked from jpwatts/xcode-git-version.sh
This Xcode build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository. To Use it, you 1) add the contents of `xcode-git-version.sh` to a "Run Script" build phase for your application target. 2) add a new value to your info plist called `FullVersion` …
View KUtils.h
#import <Foundation/Foundation.h>
@interface KUtils : NSObject
+ (NSString *)getVersionInfo;
@end
You can’t perform that action at this time.