Skip to content

Instantly share code, notes, and snippets.

@timothyekl
timothyekl / gist:6604488
Created September 18, 2013 04:17
Abstract superclass initializers in Objective-C
#import <Foundation/Foundation.h>
@interface Parent : NSObject
@end
@implementation Parent
- (id)init;
{
if (!(self = [super init]))
return nil;
#import <Foundation/Foundation.h>
@interface NSString (Reversing)
- (NSString *)reverseString;
@end
@implementation NSString (Reversing)
- (NSString *)reverseString;
{
NSMutableString *reversedString = [NSMutableString stringWithCapacity:[self length]];
str = "noël" # decomposed
puts str.reverse # expect lëon
puts str[0..2] # expect noë
puts str.length # expect 4
str = "😸😾" # emoji
puts str.reverse # expect 😾😸
puts str[1..str.length] # expect 😾
puts str.length # expect 2
package main
import (
"time"
)
func IntRangeGenerator(min, max int) <-chan int {
output := make(chan int)
go func() {
for i := min; i < max; i++ {
@timothyekl
timothyekl / UIImage+NFExtensions.h
Created April 12, 2016 01:31
UIImage(NFExtensions), a category for rescaling UIImage instances to generate thumbnails. Originally distributed as part of the UW PCE iOS course; now available under the MIT License.
// Copyright Tim Ekl 2014–2016. Available under MIT License.
#import <UIKit/UIKit.h>
@interface UIImage (NFExtensions)
- (UIImage *)scaledImageConstrainedToSize:(CGSize)size;
@end