Skip to content

Instantly share code, notes, and snippets.

View jlcampana's full-sized avatar
:octocat:
emu emu emu...

Jose Luis Campaña jlcampana

:octocat:
emu emu emu...
View GitHub Profile
@jlcampana
jlcampana / gist:5363837
Created April 11, 2013 14:31
Si algo no está en main thread ejecutarlo en el main thread
if(![NSThread isMainThread])
{
dispatch_sync(dispatch_get_main_queue(), ^{
// ... Ejecutar en main thread
completion();
});
}
@jlcampana
jlcampana / gist:5363601
Created April 11, 2013 13:59
Perform something on main thread
dispatch_sync(dispatch_get_main_queue(), ^{
completion();
});
@jlcampana
jlcampana / UIImage+H568.h
Created April 9, 2013 06:52
Carga de imágenes para iPhone5
//
// UIImage+H568.h
// AirportExperience
//
// Created by Juan Belmonte Rodríguez on 25/11/12.
//
//
#import <UIKit/UIKit.h>
@jlcampana
jlcampana / singleton_new_way.m
Last active December 15, 2015 12:39
Singleton
+ (instancetype)shared
{
static id _shared;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_shared = [self.alloc init];
});
return _shared;
}
@jlcampana
jlcampana / gist:5252922
Created March 27, 2013 09:20
Crear struct
typedef NS_ENUM(NSUInteger, MRImageType)
{
MRImageType_Full,
MRImageType_Medium,
MRImageType_Mini
};
@jlcampana
jlcampana / gist:5252843
Created March 27, 2013 09:01
Ejemplo bloque que no retiene...
__unsafe_unretained SlideShowCardView *me = self;
[slide.productPic setImageWithURL:[NSURL URLWithString:path]
placeholderImage:[UIImage imageNamed:@"logo_condis_imagenes_thumbnail"]
success:^(UIImage *image, BOOL cached)
[UIImage imageNamed:@"logo_condis_imagenes_thumbnail"]
/*
* 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)
BOOL proVersion = YES;
if (proVersion) {
return;
}
//create predicate and filter the results
NSPredicate *freePredicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *binding) {
InAppGame *game = (InAppGame *)evaluatedObject;
return game.isFree;
}];
- (void)drawTextInRect:(CGRect)rect
{
[super drawTextInRect:rect];
CGContextRef ctx = UIGraphicsGetCurrentContext();
NSString *fontName = self.font.fontName;
CGFloat fontSize = self.font.pointSize;
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)fontName, fontSize, NULL);
@jlcampana
jlcampana / gist:5047167
Created February 27, 2013 11:09
Unix timestamp
-(long long int)getUnixTimeStamp:(NSDate *)fecha
{
long long int ti = ( (long long int)[fecha timeIntervalSince1970]);
ti *= 1000;
return ti;
}