Skip to content

Instantly share code, notes, and snippets.

View kishorek's full-sized avatar

Kishore Kumar Uthirapathy kishorek

View GitHub Profile
@kishorek
kishorek / Show all errors warnings in PHP
Created April 11, 2011 02:06
Show all errors warnings in PHP
error_reporting(E_ALL);
ini_set('display_errors', '1');
@kishorek
kishorek / PHP Curl example
Created April 11, 2011 02:08
PHP Curl function
<?php
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
@kishorek
kishorek / iFrame to parent javascript
Created May 5, 2011 06:10
iFrame to parent javascript
To get the parent's location from iFrame: parent.location
To restrict the pages to be embedded inside iFrame:
if(document.location != parent.location){
parent.location = document.location
}
@kishorek
kishorek / gist:2214415
Created March 27, 2012 09:40 — forked from MugunthKumar/gist:2036521
UIView Shadow within PNG
self.myView.layer.masksToBounds = NO;
self.myView.layer.shadowColor = [UIColor blackColor].CGColor;
self.myView.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
self.myView.layer.shadowOpacity = 0.7f;
self.myView.layer.shadowRadius = 3.0f;
@kishorek
kishorek / mobile-meta-links.html
Created March 27, 2012 09:41
iOS Web App Configuration
@kishorek
kishorek / gist:2214429
Created March 27, 2012 09:43 — forked from jchatard/gist:375738
UINavigationController background
// #Lighter r,g,b,a #Darker r,g,b,a
#define MAIN_COLOR_COMPONENTS { 0.153, 0.306, 0.553, 1.0, 0.122, 0.247, 0.482, 1.0 }
#define LIGHT_COLOR_COMPONENTS { 0.478, 0.573, 0.725, 1.0, 0.216, 0.357, 0.584, 1.0 }
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
if (imageReady) {
UIImage *img = [UIImage imageNamed: @"navigation_background.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
@kishorek
kishorek / gist:2214434
Created March 27, 2012 09:43 — forked from darkseed/gist:1144990
Custom UINavigation background
@interface UINavigationBar (MyCustomNavBar)
@end
@implementation UINavigationBar (MyCustomNavBar)
- (void) drawRect:(CGRect)rect {
//matching the button color with the bar color
[self setTintColor:[UIColor colorWithRed:0.85f green: 0 blue:0 alpha:1]];
UIImage *barImage = [UIImage imageNamed:@"image.png"];
[barImage drawInRect:rect];
}
@end
@kishorek
kishorek / multi line label.m
Created March 27, 2012 09:45 — forked from darkseed/multi line label.m
How to make a multiline label with dynamic text on the iphone and get the correct height
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 9999)];
myLabel.lineBreakMode = UILineBreakModeWordWrap;
myLabel.numberOfLines = 0;
myLabel.text = @"Some \n dynamic \n multiline \n text";
[myLabel sizeToFit]; // This shrinks the 9999 down to the size of the text
NSLog(@"Actual height is: %f", myLabel.frame.size.height); // Use this for spacing any further elements
[self.view addSubview:title]; // Or add it to a scroll view, or whatever...
[myLabel release];
@kishorek
kishorek / gist:2214440
Created March 27, 2012 09:45 — forked from darkseed/gist:1159376
iPhone check for multitasking
- (BOOL) isMultitaskingCapable
{
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;
return backgroundSupported;
}
@kishorek
kishorek / gist:2214441
Created March 27, 2012 09:45 — forked from darkseed/gist:1159375
Check for photos and camera
// Method returns no, when the user doesn't have any photos
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];
// Check for camera
- (BOOL) isVideoCameraAvailable
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
[picker release];