Skip to content

Instantly share code, notes, and snippets.

View dimohamdy's full-sized avatar
🏠
Working from home

Dimo Hamdy dimohamdy

🏠
Working from home
View GitHub Profile
@devgeeks
devgeeks / raised-tabbar-snippet.m
Created December 2, 2012 09:23
Snippet needed to add a raised TabBar button in PhoneGap to the TabBar or NativeControls plugin on iOS
UIImage* buttonImage = [UIImage imageNamed:@"aperture-tab.png"];
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button setBackgroundImage:buttonImage forState:UIControlStateHighlighted];
CGFloat heightDifference = buttonImage.size.height - tabBar.frame.size.height;
CGPoint center = tabBar.center;
@mbinna
mbinna / podforceupdate.sh
Created December 4, 2012 09:43
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@toblerpwn
toblerpwn / CustomCollectionFlowLayout.h
Last active April 5, 2022 22:11
Sticky Headers at the top of a UICollectionView! -- // -- http://stackoverflow.com/questions/13511733/how-to-make-supplementary-view-float-in-uicollectionview-as-section-headers-do-i -- // -- still needs work around contentInsets.bottom and oddly-sized footers.
//
// CustomCollectionFlowLayout.h
// evilapples
//
// http://stackoverflow.com/questions/13511733/how-to-make-supplementary-view-float-in-uicollectionview-as-section-headers-do-i
//
//
#import <UIKit/UIKit.h>
@ohoachuck
ohoachuck / _appreviews-no-pythonista.py
Created April 19, 2013 09:39
Script for grabing AppStore review based on official Apple RSS feed. Work on Python 2.7 This script is an adaptation of _appreview.py script that was a pythonista (quick and dirty) test script. You might want to know that Apple official feed is bugged and review greater than page 10 does not appears (If I remember well). The best is to grab it f…
#!/usr/local/bin/python2.7
# Desktop version of pythonista script (no console usage nor clipboard)
# Script name: getreviews.py
# Author: Olivier HO-A-CHUCK
# License (OHO Ware): free to use modify, alter, re-use for commercial use or not! :)
# Date: Nov. 15th 2012
# Usage: _appreviews.py <appID>
# exemple: _appreviews.py 308816822
@alejandro-isaza
alejandro-isaza / gist:5717438
Last active June 22, 2017 09:51
UIImage category to normalize image orientation by rotating an image so that it's orientation is UIImageOrientationUp. Based on http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload/5427890#10611036
@interface UIImage (Orientation)
- (UIImage*)imageByNormalizingOrientation;
@end
@implementation UIImage (Orientation)
- (UIImage*)imageByNormalizingOrientation {
@asiviero
asiviero / child_window.js
Created November 7, 2013 01:43
Open a child window on Alloy/Titanium
$.child_window.open();
@keicoder
keicoder / snippet.m
Created January 9, 2014 04:13
objective-c : assign and copy properties
assign and copy properties
Property with ’retain (or strong)’ attribute must be of object type
so, declare a property as assign if it has a primitive value
@property (nonatomic, assign) int someNumber;
You also use assign for structs, because they aren’t objects either
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@mombrea
mombrea / iOS-UploadImage.h
Created January 17, 2014 01:49
example of a multi-part form post in objective-c
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setHTTPShouldHandleCookies:NO];
[request setTimeoutInterval:60];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"unique-consistent-string";
@homaily
homaily / gist:8672499
Last active May 7, 2024 05:37
Regex to validate saudi mobile numbers

السلام عليكم ، هذا كود ريجيكس بسيط للتحقق من صحة أرقام الجوالات السعودية ، يقوم الريجيكس بالتحقق من مفتاح الدولة ، مفتاح شركة الإتصالات لضمان صحة النص المدخل .

Hello, this is a simple regex to validate saudi mobile numbers, the code will validate country code, telecome company code and make sure the tested sting is correct .

/^(009665|9665|\+9665|05|5)(5|0|3|6|4|9|1|8|7)([0-9]{7})$/

Regex Breakdown - شرح الكود

@mrtj
mrtj / BouncyButtonViewController.h
Created February 19, 2014 10:56
iOS view controller demonstrating how to create a bouncy rubber button with the new UIView method animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion: of iOS 7
#import <UIKit/UIKit.h>
@interface BouncyButtonViewController : UIViewController
@end