Skip to content

Instantly share code, notes, and snippets.

View engmsaleh's full-sized avatar

Mohamed Saleh Zaied engmsaleh

View GitHub Profile
// An example viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadWebView];
}
// The example loader
//
// Assumes you have an IBOutlet for the UIWebView defined: @property (strong, nonatomic) UIWebView *wv;
sudo su postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
#import <Foundation/Foundation.h>
#import "Contact.h"
@interface AddressBookManager : NSObject
+ (NSString *)nameForContactWithPhoneNumber:(NSString *)phoneNumber;
+ (UIImage *)photoForContactWithPhoneNumber:(NSString *)phoneNumber;
@end
- (UIImage *)drawTextOnImage:(NSString *)text :(UIImage *)img {
UIGraphicsBeginImageContext(img.size);
CGRect imageBoundaries = CGRectMake(0,0, img.size.width, img.size.height);
[img drawInRect:imageBoundaries];
[[UIColor grayColor] set];
[text drawInRect:imageBoundaries withFont:[UIFont boldSystemFontOfSize:15] lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentCenter];
UIImage *theImage=UIGraphicsGetImageFromCurrentImageContext();
package kr.pe.meinside.android.apkx;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.zip.CRC32;
import kr.pe.meinside.android.apkx.sampleapp.R;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
#import "ParseApiClient.h"
static NSString * const kSDFParseAPIBaseURLString = @"https://api.parse.com/1/";
static NSString * const kSDFParseAPIApplicationId = YOUR_APPLICATION_ID;
static NSString * const kSDFParseAPIKey = YOUR_PARSE_API_KEY;
@implementation ParseApiClient
+ (ParseApiClient *)sharedClient {
static ParseApiClient *sharedClient = nil;
NSArray *allEntities = [NSManagedObjectModel MR_defaultManagedObjectModel].entities;
[allEntities enumerateObjectsUsingBlock:^(NSEntityDescription *entityDescription, NSUInteger idx, BOOL *stop) {
[NSClassFromString([entityDescription managedObjectClassName]) MR_truncateAll];
}];
NSDate *timenow=[NSDate date];
NSLog(@"Date before date2dot net=%@",[timenow description]);
NSString *date2DotNet=[timenow dateToDotNet];
NSLog(@"Dot net version of now = %@",date2DotNet);
timenow=[NSDate dateFromDotNet:date2DotNet];
NSLog(@"Date back from date2dot net=%@",[timenow description]);
@engmsaleh
engmsaleh / mr-save-patterns.md
Last active August 29, 2015 14:26 — forked from tonyarnold/mr-save-patterns.md
Common save patterns for use with MagicalRecord

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) {