Skip to content

Instantly share code, notes, and snippets.

View sendoa's full-sized avatar

Sendoa Portuondo sendoa

View GitHub Profile
@sendoa
sendoa / UIUtil.h
Created January 24, 2013 16:08
Obtenido de http://www.integratingstuff.com/2012/02/25/some-ios-development-tips/ Macro para programar apps universales y ejemplo
#ifdef UI_USER_INTERFACE_IDIOM()
#define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#else
#define IS_IPAD() (false)
#endif
#import "UiUtil.h"
@implementation UiUtil
@sendoa
sendoa / cs_xproj_validate.sh
Created December 20, 2012 14:00 — forked from rjstelling/cs_xproj_validate.sh
Script que comprueba si el archivo de proyecto tiene la config de CODE_SIGN_IDENTITY corrupta. http://stackoverflow.com/q/13962341/89035
# /bin/bash
#Usage: $ ./cs_xproj_validate.sh path/to/xcode/project/file/theproject.xcodeproj
#More info: http://stackoverflow.com/q/13962341/89035
PROJECT_FILE="$1/project.pbxproj"
PREVIOUS_LINE=-1
for LINE in `cat "$PROJECT_FILE" | grep -n CODE_SIGN_IDENTITY | grep -o -E '^([0-9]*)'`
@sendoa
sendoa / gist:4320773
Created December 17, 2012 18:42 — forked from twobitlabs/gist:4226365
Ejemplos de declaraciones de blocks
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@sendoa
sendoa / gist:4272498
Created December 12, 2012 23:04
Eliminar elementos duplicados de un NSArray
// Eliminar elementos duplicados en un NSArray
NSArray *cleanedArray = [[NSSet setWithArray:dates] allObjects];
@sendoa
sendoa / archivo.m
Created November 27, 2012 14:56
Modern enum en Objective-C
// http://objective-c.es/modern-objective-c-enum/
// http://nshipster.com/ns_enum-ns_options/
typedef NS_ENUM(NSUInteger, GBDaysOfWeek) {
GBSunday,
GBMonday,
GBTuesday,
GBWednesday,
GBThursday,
GBFriday,
@sendoa
sendoa / AppDelegate.h
Created November 27, 2012 14:52
AppDelegate accesible de forma global
#import <UIKit/UIKit.h>
#define ApplicationDelegate ((QBKAppDelegate *)[UIApplication sharedApplication].delegate)
@interface QBKAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (copy, nonatomic) NSString* unaCadena;
@end
@sendoa
sendoa / gist:4135566
Created November 23, 2012 13:13
Obtener UUID
//http://mobiledevelopertips.com/core-services/create-universally-unique-identifier-uuid-the-ios-6-way.html
//The class NSUUID implements RFC 4122 creating values that are 128 bits long and guaranteed to be unique across space and time by using a unique value on the device as well as a value representing the elapsed time since October 15, 1582 at 00:00:00.
// iOS 6
NSUUID *uuid = [NSUUID UUID];
NSLog(@"UUID: %@", [uuid UUIDString]);
// Output: UUID: A84AFC3C-B3A7-31C7-B3E9-234AF423C6B1
@sendoa
sendoa / gist:4135483
Created November 23, 2012 12:52
Leer valores de Info.plist desde código
# http://mobiledevelopertips.com/core-services/read-info-plist-key-value-pairs.html
NSNumber *prefSet = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"PreferencesSet"];
NSLog(@"PreferencesSet: %@", prefSet);
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
NSLog(@"CFBundleVersion: %@", version);
NSArray *customURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
debug(@"Custom URL: %@", customURL);
@sendoa
sendoa / gist:4135421
Created November 23, 2012 12:29
NSLog rápidos de CGRect o CGPoint
// http://mobiledevelopertips.com/debugging/print-cgrect-and-cgpoint-using-nslog.html
struct CGPoint {
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
struct CGRect {
CGPoint origin;
@sendoa
sendoa / gist:4135388
Created November 23, 2012 12:22
Seleccionar registros repetidos en MySQL
SELECT email, COUNT(email) as total_registros
FROM clientes
GROUP BY email
HAVING COUNT(email)>1
# http://webintenta.com/seleccionar-registros-repetidos-en-mysql.html
# Consulta SQL que nos permite seleccionar una serie de registros repetidos de un campo e-mail, nif o cualquiero otro campo que debería ser único en nuestra tabla. En el siguiente ejemplo se ha consultado la tabla "clientes" para seleccionar los correos electrónicos repetidos y la cantidad de veces que aparecen en la tabla.