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

Keybase proof

I hereby claim:

  • I am ishaq on github.
  • I am 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 /
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.
if [ -z "$(git status --porcelain)" ]; then
echo "Working directory clean, proceding to Archive"
exit 0
echo "error: Working directory dirty, stopping build"
exit 1
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 / 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;
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 / 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
- (NSString *)mi_dateStringWithFormat:(NSString *)format;
- (NSString *)mi_isoDateString;
- (NSString *)mi_ecma262DateString;
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 / KUtils.h
Last active Apr 16, 2019 — forked from jpwatts/
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 `` 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;
You can’t perform that action at this time.