Skip to content

Instantly share code, notes, and snippets.

View mickeyl's full-sized avatar
🏠
Working from home

Dr. Mickey Lauer mickeyl

🏠
Working from home
View GitHub Profile
@zoul
zoul / UINavigationItemPlus.h
Created August 31, 2010 07:40
Multiple buttons in UINavigationItem
@interface UINavigationItem (Extensions)
- (void) setRightBarButtonItemsWithTotalWidth: (NSUInteger) width
items: (UIBarItem*) firstItem, ...;
@end
@josch
josch / n900-rootfs.sh
Created December 29, 2010 23:47
generates a rootfs for nokia n900
#!/bin/sh -e
ROOTDIR="n900-chroot"
PACKAGES="ifupdown,openssh-server,udev,procps,netbase,vim,console-setup-mini,man-db,iproute"
PACKAGES="$PACKAGES,module-init-tools,wget,openssh-client,locales,sysklogd,klogd,input-utils,dnsutils"
PACKAGES="$PACKAGES,alsa-base,ntpdate,debconf-english,screen,less,console-tools,iputils-ping,vpnc,rsync"
PACKAGES="$PACKAGES,i2c-tools,watchdog"
cdebootstrap --flavour=minimal --include=$PACKAGES sid "$ROOTDIR"
@eaigner
eaigner / NSURLConnection+Timeout.m
Created April 20, 2012 15:19
Synchronous NSURLConnection timeout
@implementation NSURLConnection (Timeout)
+ (dispatch_queue_t)timeoutLockQueue {
static dispatch_queue_t queue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
queue = dispatch_queue_create("timeout lock queue", DISPATCH_QUEUE_SERIAL);
});
return queue;
}
@TimOliver
TimOliver / TODrawInsetBevelRoundedRect.c
Last active February 13, 2016 08:40
A C function demonstrating how to draw the iOS 5-6 beveled effect that was prevalent in grouped UITableView implementations.
void DrawInsetBeveledRoundedRect( CGContextRef context, CGRect rect, CGFloat radius, UIColor *fillColor )
{
//contract the bounds of the rectangle in to account for the stroke
CGRect drawRect = CGRectInset(rect, 1.0f, 1.0f);
//contract the height by 1 to account for the white bevel at the bottom
drawRect.size.height -= 1.0f;
//Save the current state so we don't persist anything beyond this operation
CGContextSaveGState(context);
@n-b
n-b / Blocks.m
Last active August 24, 2016 11:37
#!/usr/bin/env objc-run
@import Foundation;
@interface NSBlock // bite me
@end
@implementation NSBlock (invoke)
- (void) invoke
{
@futuretap
futuretap / UIResponder+FTAdditions.h
Created September 14, 2016 18:18
Block based interface to UIKeyCommand
//
// UIResponder+FTAdditions.h
// Streets
//
// Created by Ortwin Gentz on 09.05.16.
// Copyright © 2016 FutureTap. All rights reserved.
//
#import <UIKit/UIKit.h>
@kastiglione
kastiglione / gcd_map.mm
Last active January 6, 2017 20:52
Concurrent map benchmark
#import <Foundation/Foundation.h>
#import <libkern/OSAtomic.h>
@interface NSArray (ConcurrentMap)
- (NSArray*)semaphore_map:(id (^)(id))block;
- (NSArray*)serial_map:(id (^)(id))block;
- (NSArray*)spinlock_map:(id (^)(id))block;
@end
@implementation NSArray (ConcurrentMap)
@gimenete
gimenete / UIView+ActivityIndicator.h
Created July 11, 2013 09:01
Show an activity indicator in any UIView. Example: [imageView showActivityIndicator]; Then hide it [imageView hideActivityIndicator];
#import <Foundation/Foundation.h>
@interface UIView (ActivityIndicator)
- (void)showActivityIndicator;
- (void)showActivityIndicatorWithStyle:(UIActivityIndicatorViewStyle)style;
- (void)hideActivityIndicator;
@end
@ShingoFukuyama
ShingoFukuyama / objective-c-ripple-effect.m
Last active December 11, 2017 02:14
Ripple Effect for iOS Objective-C
// @property (nonatomic, strong) NSArray *colors;
// macro from https://gist.github.com/uechi/7688152
//RGB color macro
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
@gjritter
gjritter / gist:4597854
Created January 22, 2013 19:52
The setSelected:animated: and setHighlighted:animated: methods of UITableViewCell appear to make all of the selected background view's subviews transparent. This is annoying when the selected background view contains views that you intend to be non-transparent (like the custom dividers in this example). It necessitates having to add the colors b…
- (id) initWithCoder:(NSCoder*) coder {
if (self = [super initWithCoder:coder]) {
self.backgroundView = [self createBackgroundViewWithBackgroundColor:[UIColor clearColor]];
self.selectedBackgroundView = [self createBackgroundViewWithBackgroundColor:[UIColor colorWithWhite:57.0f/255.0f alpha:1.0f]];
}
return self;
}
- (UIView*) createBackgroundViewWithBackgroundColor:(UIColor*) backgroundColor {
UIView* backgroundView = [[UIView alloc] initWithFrame:self.bounds];