Skip to content

Instantly share code, notes, and snippets.

View amberstar's full-sized avatar

Amber Star amberstar

View GitHub Profile
anonymous
anonymous / modifiedCopy.swift
Created October 28, 2015 23:52
turn foo.xInPlace(arg) into a foo.x(arg)...
func modifiedCopy<Struct, Arg>(start: Struct, @noescape mutator: (inout Struct) -> Arg -> (), arg: Arg) -> Struct {
var new = start
mutator(&new)(arg)
return new
}
extension Array {
func arrayByAppending(e: Element) -> Array {
return modifiedCopy(self, mutator: Array.append, arg: e)
@bsneed
bsneed / NSObject+RFExtensions.h
Created October 6, 2012 06:36
perform a block in a background thread, and call a completion block on the main thread when its done.
//
// NSObject+RFExtensions.h
//
// Created by brandon on 10/5/12.
// Copyright (c) 2012 redf.net. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void (^NSObjectPerformBlock)(id userObject);
@odrobnik
odrobnik / gist:1789418
Created February 10, 2012 12:42
Asynchronous Deletion
//
// DTAsyncFileDeleter.m
// DTFoundation
//
// Created by Oliver Drobnik on 2/10/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
#import "DTAsyncFileDeleter.h"
@robin
robin / gist:62684
Created February 12, 2009 15:40
round corner uiimage
#import "ImageManipulator.h"
@implementation ImageManipulator
static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight)
{
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0) {
CGContextAddRect(context, rect);
return;