Skip to content

Instantly share code, notes, and snippets.

@rais38
rais38 / BETTestSemaphor.h
Created March 26, 2014 02:05
Semaphor for wait a action.
//
// BETTestSemaphor.h
// TwitterClient
//
// Created by Rafael Aguilar Martín on 11/11/12.
// Copyright (c) 2012 Rafael Aguilar Martín. All rights reserved.
//
#import <Foundation/Foundation.h>
@rais38
rais38 / gist:9957819
Last active August 29, 2015 13:58
Remove multiple (same) entries on "open with" (OSX)
$ /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\LaunchServices.framework/Versions/A/Support/\
lsregister -kill -r -domain local -domain user
$ killall Finder
@rais38
rais38 / gist:6d8f1b49da73e6fab743
Created July 18, 2014 19:24
UITextViews in a UITableView link detection bug in iOS 7
# http://stackoverflow.com/a/23119866/1379492
- (void)prepareForReuse
{
[super prepareForReuse];
self.textView.editable = YES;
self.textView.editable = NO;
self.textView.text = nil;
}
@rais38
rais38 / CachingGithubPassword.md
Created October 17, 2014 11:34
Caching your GitHub password in Git
@rais38
rais38 / gist:4690624
Created February 1, 2013 10:51
Calculate the region needed to show a number of POIs in MKMapView
/**
MKCoordinateRegion viewRegion = [self RegionForAnnotations:_arrayPois];
[_mapView setRegion:viewRegion animated:YES];
*/
- (MKCoordinateRegion)RegionForAnnotations:(NSArray *)records {
MKCoordinateRegion region;
// center the map arround our records
// @see https://devforums.apple.com/message/48525#48525
@rais38
rais38 / gist:4690587
Last active December 12, 2015 01:19
Resize UIImage
/**
@see http://stackoverflow.com/questions/3889687/how-to-compress-an-image-taken-by-the-camera-in-iphone-sdk
UIImage *image = [self scaleImage:myImage toSize:CGSizeMake(320.0,480.0)];
*/
-(UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {
UIGraphicsBeginImageContext(newSize);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@rais38
rais38 / gist:4730084
Last active December 12, 2015 06:38
UIView with rounded corners
/**
@see http://www.dbsnippets.com/2012/09/11/objective-c-redondear-esquinas-de-un-uiview/
You must import basic Core Animation classes
#import <QuartzCore/QuartzCore.h>
Example:
[self roundView:backgroundColorView onCorner:(UIRectCornerAllCorners) radius:10.0];
[self roundView:imgView onCorner:(UIRectCornerTopLeft|UIRectCornerBottomLeft) radius:5.0];
*/
@rais38
rais38 / gist:4758465
Last active December 12, 2015 10:19
Detect If Your Application Is Running In The Debugger
static bool debuggerRunning(void) {
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
info.kp_proc.p_flag = 0;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
__weak typeof(self) weakSelf = self;
@rais38
rais38 / gist:7038167
Created October 18, 2013 08:12
Reveal
#pragma mark - Reveal
#import <dlfcn.h>
- (void)startReveal
{
NSString *revealLibName = @"libReveal";
NSString *revealLibExtension = @"dylib";
NSString *dyLibPath = [[NSBundle mainBundle] pathForResource:revealLibName ofType:revealLibExtension];
NSLog(@"Loading dynamic library: %@", dyLibPath);
void *revealLib = NULL;