Skip to content

Instantly share code, notes, and snippets.

View ahdidou-mohamed's full-sized avatar

Mohamed AHDIDOU ahdidou-mohamed

View GitHub Profile
@ahdidou-mohamed
ahdidou-mohamed / post.java
Created July 12, 2012 13:12
Post Data to Server -- ANDROID
String serverURL = "SERVER_URL"
DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost(serverURL);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(N);
nameValuePairs.add(new BasicNameValuePair("param1_name", param1_value));
nameValuePairs.add(new BasicNameValuePair("param2_name", param2_value));
*
*
@ahdidou-mohamed
ahdidou-mohamed / build_tesseract.sh
Created November 9, 2012 15:30 — forked from zbyhoo/build_tesseract.sh
Downloads and compiles Tesseract OCR library for iOS
#!/bin/sh
# build.sh
GLOBAL_OUTDIR="`pwd`/dependencies"
LOCAL_OUTDIR="./outdir"
LEPTON_LIB="`pwd`/leptonica-1.68"
TESSERACT_LIB="`pwd`/tesseract-3.01"
IOS_BASE_SDK="5.1"
IOS_DEPLOY_TGT="4.3"
@ahdidou-mohamed
ahdidou-mohamed / build_dependencies.sh
Created November 9, 2012 16:05
Compile tesseract for iOS SDK 6.0
#!/bin/sh
# build.sh
GLOBAL_OUTDIR="`pwd`/dependencies"
LOCAL_OUTDIR="./outdir"
LEPTON_LIB="`pwd`/leptonica-1.69"
TESSERACT_LIB="`pwd`/tesseract-r775"
IOS_BASE_SDK="6.0"
IOS_DEPLOY_TGT="4.3"
@ahdidou-mohamed
ahdidou-mohamed / makecall.m
Created November 23, 2012 10:31
makeCall in IOS
//The user won't be prompted to call
//That means that the dial app will be launched automatically
-(IBAction)makeCallWithoutPromt:(NSString *)tel(
NSString *phoneNumber = [NSString stringWithFormat: @"tel://%@",tel];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
)
//The user will be prompted to call
//That means that the dial app will be launched after the user clicked on OK when prompted
@ahdidou-mohamed
ahdidou-mohamed / crop.m
Created November 23, 2012 14:40
Cropping an image in IOS
-(UIImage *)cropImage:(UIImage *)image{
// Defining the rectangle we want to crop
CGRect newSize = CGRectMake(0.0, 50.0, 320.0, 430.0);
// Create a new image with new size and original image : Some Quartz code
CGImageRef tmp = CGImageCreateWithImageInRect([image CGImage], newSize);
// Get back to our UIImage class
UIImage *croppedImage = [UIImage imageWithCGImage:tmp];
@ahdidou-mohamed
ahdidou-mohamed / uilabel.m
Created November 29, 2012 16:22
Adjust UILabel Height
-(void)adjustLabelHeight:(UILabel * )label string :(NSString *)string{
//Calculate the expected size based on the font and linebreak mode of your label
CGSize maximumLabelSize = CGSizeMake(label.frame.size.width,9999);
CGSize expectedLabelSize = [string sizeWithFont:label.font constrainedToSize:maximumLabelSize lineBreakMode:label.lineBreakMode];
//adjust the label the the new height.
CGRect newFrame = label.frame;
newFrame.size.height = expectedLabelSize.height;
label.frame = newFrame;
@ahdidou-mohamed
ahdidou-mohamed / checkStringContainsSubstring.m
Created November 30, 2012 17:32
Check if a NSString contains substring
-(BOOL)checkString:(NSString *)originalString contains :(NSString *)subString{
BOOL found = NO;
if ([originalString rangeOfString:subString].location != NSNotFound) {
found = YES;
}
return found;
}
//first raw
NSMutableDictionary * dico10 = [NSMutableDictionary dictionaryWithCapacity:2];
[dico10 setObject:@"image0.png" forKey:@"image"];
[dico10 setObject:@"Mise à niveau du contrôle routier" forKey:@"titre"];
[dico10 setObject:@"Le nouveau Code recourt aux nouvelles technologies pour le contrôle routier. Radars fixes, radars mobiles, alcootests, stations de pesage automatique…, autant de moyens pour réduire significativement l’intervention de l’élément humain, le pouvoir discrétionnaire des agents et garantir la transparence du contrôle." forKey:@"text"];
NSMutableDictionary * dico11 = [NSMutableDictionary dictionaryWithCapacity:2];
[dico11 setObject:@"image1.png" forKey:@"image"];
[dico11 setObject:@"Responsabilités et peines privatives" forKey:@"titre"];
[dico11 setObject:@"Les sanctions privatives de liberté visent à punir les usagers enfreignant délibérément les règles de la circulation et commettant des accidents d’une extrême gravité (délits d’homicide ou de blessure
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@ahdidou-mohamed
ahdidou-mohamed / gist:798216c5502bfe6fe59d
Created November 24, 2014 17:48
Json_Users_Prestigia
[
{
"uid": "0",
"login": "",
"pass": "",
"nom_prenom": null
},
{
"uid": "1",
"login": "admin",