Skip to content

Instantly share code, notes, and snippets.

@xinsight
xinsight / DoubleLabel.h
Created March 2, 2012 08:09
Tap label to toggle between two pieces of text. A nice trick to de-clutter an interface.
//
// DoubleLabel.h
// LongTermTimer
//
// Created by Jason Moore on 11-05-31.
// Copyright 2011 xinsight. All rights reserved.
//
#import <UIKit/UIKit.h>
@xinsight
xinsight / PlaylistItem.m
Created March 2, 2012 08:28
Draw method for a playlist item that shows the playhead position. Uses path clipping to round corners on top and bottom. (2009)
#define CORNER_RADIUS 10
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.5); // black
if ([type isEqualToString:@"top"]) { // curved top
CGContextBeginPath (context);
CGContextMoveToPoint(context, 0, self.frame.size.height); // start: bottom-left
@xinsight
xinsight / gist:4690180
Last active December 12, 2015 01:18
example of AFNetworking's nice wrapper to the Apple's hairy Reachability code.
_reachability = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://api.rdio.com/"]];
[_reachability setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusNotReachable:
[self.reachabilityDelegate networkIsReachable:NO];
break;
case AFNetworkReachabilityStatusReachableViaWiFi:
case AFNetworkReachabilityStatusReachableViaWWAN:
[self.reachabilityDelegate networkIsReachable:YES];
break;
@xinsight
xinsight / gist:4717701
Created February 5, 2013 21:12
List Comprehension
NSArray *a = @[@"Hello", @"Will This work?", @"can it work?", @"Yes!"];
// sure, this works...
NSMutableArray *b = [NSMutableArray arrayWithCapacity:[a count]];
[a enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
[b insertObject: [obj uppercaseString] atIndex: idx];
}];
@xinsight
xinsight / asicon.sh
Last active December 19, 2015 03:29 — forked from lexrus/asicon.sh
#!/bin/bash
# According to https://developer.apple.com/library/ios/#qa/qa1686/_index.html
# Install ImageMagick with MacPort: sudo port install ImageMagick
# Install ImageMagick with Homebrew: brew install ImageMagick
# Assume source icon is 1024x1024
blur0=""
blur3="-gaussian-blur 3x3"
blur4="-gaussian-blur 4x4"
blur7="-gaussian-blur 7x7"
blur8="-gaussian-blur 8x8"