Skip to content

Instantly share code, notes, and snippets.

View MoathOthman's full-sized avatar
🎯
Focusing

Moath othman MoathOthman

🎯
Focusing
View GitHub Profile
@MoathOthman
MoathOthman / gist:a2164c62ac596f81c567
Created March 3, 2015 07:15
Path to app directory in simulator on OSX Yosemite
NSLog(@"app dir: %@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
@MoathOthman
MoathOthman / gist:8690ccefa3d6b19b3790
Created March 3, 2015 07:16
Register for push notifications - objc
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{ [[UIApplication sharedApplication] registerUserNotificationSettings:
[UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeSound |
UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
@MoathOthman
MoathOthman / gist:b3cef77057028e4c2e70
Created March 3, 2015 07:18
Convert from p12 to PEM Terminal
openssl pkcs12 -in Certificatesdev.p12 -out Certificatesdev.pem -nodes -clcerts
@MoathOthman
MoathOthman / gist:693de44543dd704a6c2e
Last active July 24, 2018 11:20
Commans to Close an application on some port on ubuntu/mac
fuser -v 8080/tcp -- give you list of pids using that port and that protocol
kill -s 15 pid -- kill //the process 15 could be 9 as well
or fuser -f ** not sure
- ps -aux |grep node
Close an application on some port on MAC
lsof | grep tcp
kill -9 ppid
@MoathOthman
MoathOthman / gist:32ca1c352450e54615ed
Created March 3, 2015 07:22
GET Number Of Commits in git Repo
git rev-list HEAD --count
@MoathOthman
MoathOthman / gist:b7b25f43220af52c4284
Created March 3, 2015 07:24
GET Number Of Lines of each file in a directory
find . -type f | xargs wc -l
For specific file extension
find . -name '*.m' | xargs wc -l
@MoathOthman
MoathOthman / gist:5aca6cc64fedeaa137ce
Last active April 28, 2016 09:33
Snippet for sizing the collectionViewCell depending on the screen size
Collection View Cell Size
Snippet for sizing the collectionViewCell depending on the screen size
Given its original designed for 4.7" inches
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
return CGSizeMake(<#currentWidthfor4.7inches#> *self.view.bounds.size.height/667.0, <#height#>*self.view.bounds.size.width/375.0);
}
@MoathOthman
MoathOthman / gist:c6b0729f45edbac1a46f
Created March 22, 2015 17:08
Custom UINavigationController back button
Snippet From Apple sample Code
UIImage *backButtonBackgroundImage = [UIImage imageNamed:@"back"];
// The background should be pinned to the left and not stretch.
float margin = 12.0;
backButtonBackgroundImage = [backButtonBackgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, backButtonBackgroundImage.size.width - margin, 0, 0)];
id appearance = [UIBarButtonItem appearanceWhenContainedIn:[
CustomBackButtonNavController class], nil];
@MoathOthman
MoathOthman / findXY
Created October 25, 2015 22:38
Find x point and y point of a UIView related to the main screen in swift
/** Find the Y point of a view related to the main screen
@pramater UIView the view to start
@return CGFloat the y point to the main screen
*/
func findOutTheYPointToTheScreen(view: UIView) -> CGFloat {
var ypointSummation: CGFloat = view.frame.origin.y
var tView = view
while let v = tView.superview {
ypointSummation += v.frame.origin.y
//
// DetectBlur.swift
//
// Created by Moath_Othman on 2/9/16.
//
import Foundation
//inpired by https://gist.github.com/mortenbekditlevsen/5a0ee16b73a084ba404d
extension UIDevice {
public func MO_isBlurAvailable() -> Bool {