Skip to content

Instantly share code, notes, and snippets.

View fahied's full-sized avatar

Muhammad Fahied fahied

  • Emirates Airlines
  • Dubai
View GitHub Profile
@fahied
fahied / apns
Created March 20, 2016 07:52
How to create APNS Certificates and merge into one PEM
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 January 2, 2016 09:44
Typical Bit Mask Operations
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 October 5, 2015 15:59 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

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 August 23, 2015 04:31
Animate UITableViewCell along with Scrolling
/*
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 March 13, 2020 03:23
Set Accessibility to custom UITableViewCell
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 July 1, 2015 10:11
add UIAccessiblity to UICollectionViewCell
// 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 June 22, 2015 05:10
iOS Useful 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 February 26, 2015 16:36
NSLocationWhenInUseUsageDescription
/*
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.
*/
@fahied
fahied / pairsum
Last active August 29, 2015 14:10
Given two sorted arrays of integers, find the pair of indices (one into each array) which identify elements which sum to a given integer
import java.util.ArrayList;
public class SearchMe {
static int[] intArrayA = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
static int[] intArrayB = {3,4,9,14};
public static void main (String[] args) throws java.lang.Exception
@fahied
fahied / lics
Created December 2, 2014 13:07
to find the longest increasing contiguous subsequence
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define ARRAY_SIZE(A) sizeof(A)/sizeof(A[0])