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 / gist:b1389a04a0207448aa50
Last active Aug 29, 2015
installing pod : permission denied
View gist:b1389a04a0207448aa50
sudo chown -R `whoami` path/to/project/
if that doesn't help, you can also try
sudo chown -R `whoami` ~/.cocoapods
sudo chown -R `whoami` ~/Library/Caches/CocoaPods
View .gitignore
# Copyright: Benjamin Weiss (keyboardsurfer) https://github.com/keyboardsurfer
# Under CC-BY-SA V3.0 (https://creativecommons.org/licenses/by-sa/3.0/legalcode)
# built application files
*.apk
*.ap_
*.jar
!gradle/wrapper/gradle-wrapper.jar
# lint folder
@fahied
fahied / play2
Created Jun 26, 2014
Play framework 2.x.x Best Practices
View play2
########### Useful Commands ###########
# Download source code for Java API used in project
$ play "eclipse with-source=true"
# Run Play in https mode
$ JAVA_OPTS=-Dhttps.port=9001 play start
########### Useful Liberaries ###########
# Mongodb Wrapper for JAVA
http://jongo.org/
@fahied
fahied / gitcheat
Last active Aug 29, 2015
GIT Cheatsheet
View gitcheat
# Change the current branch to master in git #
You can rename/remove master on remote, but this will be an issue if lots of people have based their work on the remote master branch and have pulled that branch in their local repo.
That might not be the case here since everyone seems to be working on branch 'seotweaks'.
In that case you can:
(Make a git remote --show to check how your remote is declared within your local repo. I will assume 'origin')
(Regarding GitHub, house9 comments: "I had to do one additional step, click the 'Admin' button on GitHub and set the 'Default Branch' to something other than 'master', then put it back afterwards")
@fahied
fahied / jquery-uiwebview
Created Aug 26, 2014
jquery hash or query in UIWebview
View jquery-uiwebview
// set path for the file to load in uiwebview
NSString *filePath = [resourceDir stringByAppendingPathComponent:@"index.html"];
// convert to NSURL object, remember not to incoude #tag yet, as fileURLWithPath will replacce jquery # with %23
// and will cause trouble to load your page properly
NSURL *fileURL = [NSURL fileURLWithPath:menuPath];
// add hash here
fileURL = [NSURL URLWithString:@"#menu" relativeToURL:fileURL];
View mr-save-patterns.md

Common Save Patterns

Standard background save

Assuming that you don't care which NSManagedObjectContext is used, and you just want to make some changes and save them in the background, use the following method. 90% of the time, this is what you'll want.

NSManagedObjectSubclass *myObject = [NSManagedObjectSubclass MR_findFirst];

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
@fahied
fahied / multipartPutAFN
Last active Aug 29, 2015
Multipart-formdata PUT using AFNetworking
View multipartPutAFN
+(void)putMultipartWhereRoute:(NSString*)route jsonData:(NSData*)jsonData images:(NSArray*)images completion:(void (^)(NSError *error, NSDictionary *response))completion
{
NetworkManager *networkManger = [NetworkManager sharedManager];
NSString *serviceURL = [[networkManger.baseURL absoluteString] stringByAppendingString:route];
NSMutableURLRequest *request = [networkManger.requestSerializer multipartFormRequestWithMethod:@"PUT" URLString:serviceURL parameters:nil constructingBodyWithBlock:^(id formData) {
//append json data
[formData appendPartWithFormData:jsonData name:@"note"];
//append images
View logger.xml
<configuration>
<!-- this is plain logback config.
documentation: http://logback.qos.ch/manual/appenders.html
set -Dlogger.level like this:
/usr/java/latest/bin/java -Dconfig.file=/apps/YOURAPP/conf/application.conf -cp /apps/YOURAPP/staged/* -Dlogger.level=WARN play.core.server.NettyServer /apps/YOURAPP
-->
@fahied
fahied / afn_authentication
Created Sep 23, 2014
add Authentication to AFHTTPRequestOperation
View afn_authentication
//1. using completion block
[operation setAuthenticationChallengeBlock:
^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
NSURLCredential *cred = [NSURLCredential
credentialWithUser:@"username"
password:@"password"
persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:cred forAuthenticationChallenge:challenge];
}];
@fahied
fahied / delay
Created Oct 7, 2014
delay execution for time
View delay
double delayInSeconds = 600.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[weakself success:vc];
});
You can’t perform that action at this time.