Skip to content

Instantly share code, notes, and snippets.

View engmsaleh's full-sized avatar

Mohamed Saleh Zaied engmsaleh

View GitHub Profile
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
// 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;
@engmsaleh
engmsaleh / Dismiss keyboard
Created June 1, 2014 13:29
This is how to dismiss iOS keyboard when click on UIView background
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// dismiss keyboard when background is touched
[self.view endEditing:YES];
}
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];
}];