Skip to content

Instantly share code, notes, and snippets.

View romyilano's full-sized avatar
😎
improving

Romy romyilano

😎
improving
View GitHub Profile
@davepeck
davepeck / BinaryDataScanner.h
Created April 27, 2009 04:35
Two simple Objective-C classes that make it crazy easy to read data from sequential binary files.
//
// BinaryDataScanner.m
//
// Copyright 2009 Dave Peck <davepeck [at] davepeck [dot] org>. All rights reserved.
// http://davepeck.org/
//
// This class makes it quite a bit easier to read sequential binary files in Objective-C.
//
// This code is released under the BSD license. If you use it in your product, please
// let me know and, if possible, please put me in your credits.
@henrik
henrik / example.m
Created June 27, 2010 11:48
Locating the keyboard (UIKeyboard) on iOS 4, to e.g. add a custom button.
- (void)someSetupMethod {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
}
- (void)someTeardownMethod {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
}
@kwylez
kwylez / gist:1348851
Created November 8, 2011 19:30
Loading Local UIWebView with GCD
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
webView.delegate = self;
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]isDirectory:NO];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
@justin
justin / gist:1586083
Created January 10, 2012 00:56
UIAccessibilityTraits Example
- (UIAccessibilityTraits)accessibilityTraits
{
UIAccessibilityTraits traits = UIAccessibilityTraitButton | UIAccessibilityTraitAllowsDirectInteraction | UIAccessibilityTraitStaticText;
if (self.disabled == YES)
{
traits = traits | UIAccessibilityTraitNotEnabled;
}
return traits;
@codeswimmer
codeswimmer / ios_nav_bar_info_button.m
Created February 7, 2012 04:58
iOS: How to add an Info Button to the right button slot in a Navigation Bar
// This is assumed to be inside a UINavigationController
-(void)awakeFromNib
{
// How to turn a NavigationItem's rightBarButtonItem into an Info Button
// First, in your storyboard or xib add a Bar Button Item to the right slot in the navigation bar.
// Then, do this:
UIButton *infoLightButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
infoLightButton.frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
infoLightButton.backgroundColor = [UIColor clearColor];
[infoLightButton addTarget:self action:@selector(showInfo:) forControlEvents:UIControlEventTouchUpInside];
@paullewis
paullewis / gist:1981455
Created March 5, 2012 22:03
Quicksort in JavaScript
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@paullewis
paullewis / gist:1982121
Created March 5, 2012 23:44
Mergesort in JavaScript
/**
* An implementation for Mergesort. Less efficient
* than Quicksort. Again, you'd just use Array.sort
* but if you found yourself unable to use that
* there's always this option.
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
@sabarasaba
sabarasaba / gist:3080590
Created July 10, 2012 02:19
Remove directory from remote repository after adding them to .gitignore
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@toddlee
toddlee / masking-image.m
Created October 10, 2012 08:02
Masking a UIImage with a mask UIImage in iOS
- (UIImage *)maskImage:(UIImage *)image withMask:(UIImage *)maskImage
{
CGImageRef maskRef = maskImage.CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
@goblindegook
goblindegook / addObserver.m
Created December 2, 2012 21:18
Detect VoiceOver Status Changes
- (void)viewDidLoad {
...
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(didChangeVoiceOverStatus:)
name:UIAccessibilityVoiceOverStatusChanged
object:nil];
...
}