Skip to content

Instantly share code, notes, and snippets.

View sendoa's full-sized avatar

Sendoa Portuondo sendoa

View GitHub Profile
@sendoa
sendoa / UIImageViewRounded.h
Created June 1, 2012 08:35
Categoría para UIImageView con bordes redondeados
//
// UIImageRounded.h
// BDD Restaurantes
//
// Created by Sendoa Portuondo on 03/10/11.
// Copyright 2011 Qbikode Solutions, S.L. All rights reserved.
//
#import <UIKit/UIKit.h>
@sendoa
sendoa / gist:2887604
Created June 7, 2012 09:02
Evitar que la pantalla se bloquee (iOS)
// Disable the idle timer
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
// Or for those who prefer dot syntax:
[UIApplication sharedApplication].idleTimerDisabled = YES;
@sendoa
sendoa / gist:2896994
Created June 8, 2012 17:21
Recibir un mail cada vez que Google visita la web
<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false ) {
mail('tu_direccion@correo.com','Aviso: Googlebot ha visitado tu web','El Googlebot ha visitado tu página: http://tu_dominio.com'. $_SERVER['REQUEST_URI']);
}
?>
@sendoa
sendoa / gist:3033254
Created July 2, 2012 13:30
Método adicional para jQuery Validator de comprobación de hora (hh:mm)
// Hay que añadirlo a additional-methods.js
jQuery.validator.addMethod("horahhmm", function(value, element) {
var res = false;
// Formato hh:mm
res = this.optional(element) || /^\d{2}[:]\d{2}$/.test(value);
var hora = value.split(':');
var hh = parseInt(hora[0],10);
var mm = parseInt(hora[1],10);
@sendoa
sendoa / proyecto.pch
Created November 20, 2012 10:05
Alternatives to NSLog
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#ifdef DEBUG
# define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
# define ULog(...)
@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.
@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: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: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 / 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