Skip to content

Instantly share code, notes, and snippets.

/**
* Wait for [AssestLibrary enumerateGroupsWithTypes: usingBlock:] to be completed, or how other
* people call it, [AssestLibrary enumerateGroupsWithTypes: usingBlock:] Asynchronous
* The following method should not be called on main thread, use
* [self performSelectorInBackground:@selector(getAllAssets) withObject:nil];
* to excecute it
*/
- (void)getAllAssets
//Milisegundos a días, horas, minutos y segundos en javascript
var x = difference / 1000
seconds = x % 60
x /= 60
minutes = x % 60
x /= 60
hours = x % 24
x /= 24
days = x;
@teofiloisrael
teofiloisrael / gist:6251624
Last active December 21, 2015 04:39
Para poder acceder a webservices desde un dispositivo Android.
//Muchas veces los permisos de internet en el AndroidManifest.xml no son sufucientes.
//Si en el emulador los webservices remotos funcionan bien, peron en el dispositivo real retornan null,
//es posible que se necesit configurar esto:
//nota: hay que colocar esto encima de la declaracion de la clase:
//@TargetApi(Build.VERSION_CODES.GINGERBREAD)
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
@teofiloisrael
teofiloisrael / gist:5855913
Last active December 18, 2015 22:39
Timer que se dispara cada media noche
//Update each midnight
NSCalendar *cal = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
[cal setTimeZone:[NSTimeZone systemTimeZone]];
NSDateComponents * comp = [cal components:( NSYearCalendarUnit| NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]];
[comp setMinute:0];
[comp setHour:0];
NSDate *startOfToday = [cal dateFromComponents:comp];
@teofiloisrael
teofiloisrael / gist:5385326
Last active December 16, 2015 05:38
Parseando JSON desde un API con Objective-C
#import "ViewController.h"
#import "JSONKit.h"
@interface ViewController ()
@property (nonatomic, retain) NSMutableData *response;
@end
@implementation ViewController