Skip to content

Instantly share code, notes, and snippets.

Muhammad Fahied fahied

Block or report user

Report or block fahied

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
@fahied
fahied / apns-pem
Created Dec 12, 2016
Create pem file for apple push notifications
View apns-pem
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
@fahied
fahied / iosFonts.m
Created Mar 23, 2016
How to find available fonts in iOS app
View iosFonts.m
Following is code for find all fonts from the system:
for(NSString *fontfamilyname in [UIFont familyNames])
{
NSLog(@"Family:'%@'",fontfamilyname);
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname])
{
NSLog(@"\tfont:'%@'",fontName);
}
NSLog(@"~~~~~~~~");
@fahied
fahied / apns
Created Mar 20, 2016
How to create APNS Certificates and merge into one PEM
View apns
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
Step 4: Now we have to merge the Key .pem and Certificate .pem to get Development .pem needed for Push Notifications in Development Phase of App
@fahied
fahied / bitmask
Created Jan 2, 2016
Typical Bit Mask Operations
View bitmask
Typical Bit Mask Operations
Set a flag or overlay multiple values
flags | flagbitN
Unset a flag (zero-out a bit or set a bit to zero)
flags & ~flagbitN
Check if a bit is set
(flags & flagbitN) == flagbitN
@fahied
fahied / gist:9f7f8b7323641e4f44b4
Created Oct 5, 2015 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
View gist:9f7f8b7323641e4f44b4

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@fahied
fahied / 3DAnimation
Created Aug 23, 2015
Animate UITableViewCell along with Scrolling
View 3DAnimation
/*
You have to hijack the scrollView (Add yourself as a ScrollViewDelegate alongside TableViewDelegate)
and the table view will automatically forward scrollview events along side tableview events.
(self.tableView.delegate = self) is really talking to both
<UIScrollViewDelegate, UITableViewDelegate>
I have a helper function in the example that also calculates distance to the top of the cell.
*/
@fahied
fahied / accessibilityTableCell
Last active Aug 29, 2015
Set Accessibility to custom UITableViewCell
View accessibilityTableCell
In Voice-Over , in order to make an element accessible :-
1. you have to set setIsAccessibilityElement property as true which i don't find in your code.
2; The other important point is that to make child elements (subviews) to be accessible , you have to seperately make them accessible while the parent should not be accessible(you have to specify this also).
Implement the UIAccessibilityContainer Protocol in your custom - cell.
NSString *title = titleofcell;
cell.accessibilityValue = title;
cell.accessibilityLabel = [NSString stringWithFormat:@"item %ld", (long)indexPath.row];
cell.accessibilityTraits = UIAccessibilityTraitButton;
@fahied
fahied / collectionAccessibility
Created Jul 1, 2015
add UIAccessiblity to UICollectionViewCell
View collectionAccessibility
// Option 1: In ViewController, set the cell instance to have accessibility.
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
[cell setIsAccessibilityElement:YES];
// Option 2: Implement the accessibility interface in the cell object:
// implementation file of Cusome CollectionViewCell
- (BOOL)isAccessibilityElement
{
return YES;
}
@fahied
fahied / MACROS
Created Jun 22, 2015
iOS Useful Macros
View MACROS
// Constants
#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define APP_NAME [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
#define APP_DELEGATE [[UIApplication sharedApplication] delegate]
#define USER_DEFAULTS [NSUserDefaults standardUserDefaults]
#define APPLICATION [UIApplication sharedApplication]
#define BUNDLE [NSBundle mainBundle]
#define MAIN_SCREEN [UIScreen mainScreen]
#define DOCUMENTS_DIR [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]
@fahied
fahied / requestAlwaysAuthorization
Created Feb 26, 2015
NSLocationWhenInUseUsageDescription
View requestAlwaysAuthorization
/*
So the first thing you need to do is to add one or both of the following keys to your Info.plist file:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Both of these keys take a string which is a description of why you need location services. You can enter a string like “Location is required to find out where you are” which, as in iOS 7,
can be localized in the InfoPlist.strings file.
*/
You can’t perform that action at this time.