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 / new_gist_file
Created September 12, 2013 14:13
Ubuntu Server
sudo apt-get install php5-pgsql
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
sudo npm install -g karma
sudo apt-get install git
sudo npm install -g coffee-script
@jlcampana
jlcampana / new_gist_file
Created September 2, 2013 10:22
Check iOS version preprocessor
// e.g. check for iOS 6:
//#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
#ifdef __IPHONE_7_0
- (BOOL)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
#endif
@jlcampana
jlcampana / new_gist_file
Created August 29, 2013 08:54
Problemas con el desplazamiento de la linea de separación en celdas en iOS7
//Set the separator line on left=0
+ (void) setCellInsetsForVersion7:(UITableViewCell *)cell
{
if([cell respondsToSelector:@selector(setSeparatorInset:)])
{
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
if([self respondsToSelector:@selector(edgesForExtendedLayout)]){
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
@jlcampana
jlcampana / gist:5955410
Created July 9, 2013 07:35
Esconder teclado cuando se pulsa Enter y ejecutar algo
- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if([string isEqualToString:@"\n"]) {
[textField resignFirstResponder];
return NO;
}
return YES;
}
@jlcampana
jlcampana / NSDate+ISO8601.h
Created June 4, 2013 12:18
NSDate ISO8601
#import <Foundation/Foundation.h>
@interface NSDate (ISO8601)
+(NSDateFormatter*)ISO8601Formatter;
-(NSString*)ISO8601;
@end
@jlcampana
jlcampana / gist:5487482
Created April 30, 2013 08:52
Escapar URL
NSString *s = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef)[[self.app.externalURL absoluteString] mutableCopy], NULL, CFSTR("=,!$&'()*+;@?\n\"<>#\t :/"),kCFStringEncodingUTF8));
url =[NSURL URLWithString:s];
#import <Foundation/Foundation.h>
#import "DDXMLNode.h"
@interface DDXMLNode (CDATA)
/**
Creates a new XML element with an inner CDATA block
<name><![CDATA[string]]></name>
*/
+ (id)cdataElementWithName:(NSString *)name stringValue:(NSString *)string;
@jlcampana
jlcampana / gist:5371098
Created April 12, 2013 10:27
Predicate with block
//create predicate and filter the results
NSPredicate *distancePredicate = [NSPredicate predicateWithBlock:^BOOL(Establishment *a, NSDictionary *binding)
{
CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:[a.latitude doubleValue]
longitude:[a.longitude doubleValue]];
return [location distanceFromLocation:myLocation] <= __distance;
}];
NSArray *resultado = [shops filteredArrayUsingPredicate:distancePredicate];
@jlcampana
jlcampana / gist:5364260
Created April 11, 2013 15:21
Chequear si un objeto implementa un protocolo
if([self conformsToProtocol:@protocol(APIBicingNotificationCarriles)])
{
}