Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View amberstar's full-sized avatar

Amber Star amberstar

View GitHub Profile
@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;
@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"
@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);
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)
@davedelong
davedelong / UpdateRepositories.swift
Last active January 30, 2017 12:43
A headless Swift program that keeps a directory of git repositories up-to-date
#!/usr/bin/swift
import Foundation
func scanForRepositories(directory: NSURL, root: NSURL) {
let fileManager = NSFileManager.defaultManager()
let options: NSDirectoryEnumerationOptions = .SkipsSubdirectoryDescendants | .SkipsPackageDescendants
if let contents = fileManager.contentsOfDirectoryAtURL(directory, includingPropertiesForKeys: [NSURLIsDirectoryKey], options: options, error: nil) {
let urls = contents as Array<NSURL>
@mackworth
mackworth / Obectivej-C to Swift Syntax Translation.md
Last active October 13, 2017 10:57
Table showing the major translations from Objective-C to Swift syntax

Conversion Process from Objective-C syntax to Swift The most important first step is to run Apple's "Convert to Modern Objective-C Syntax" refactoring, so that you're using array/dictionary literals and bracket-accesses; these will then be usable in Swift. Note also that I'm a beginner in Swift, so my apologies for any mistakes or incompleteness here.

When you see this pattern Replace with this
Module
@interface *newType* : *superType* <*protocol1*, *protocol2*> class *newType* : *superType*, *protocol1*, *protocol2*
@implementation OR @synthesize OR @end Delete
Properties
@subdigital
subdigital / pns.m
Created January 5, 2013 21:59
What are your favorite Xcode Snippets? Add them in the comments.
// Property Nonatomic Strong
// Platform: All
// Completion Scopes: ClassInterfaceMethods
@property (nonatomic, strong) <# class_name #> *<# variable_name #>;
@JadenGeller
JadenGeller / Cluster.swift
Created March 13, 2017 01:27
Class Cluster
class Number /* class cluser */ {
class Int8: Number {
var value: Swift.Int8
init(_ value: Swift.Int8) { self.value = value }
}
class Int: Number {
var value: Swift.Int
init(_ value: Swift.Int) { self.value = value }
}
anonymous
anonymous / App Store Refund
Created January 23, 2014 17:34
You can get a refund for any app on the App Store by following this process:
1. Visit https://reportaproblem.apple.com
2. Sign In with your Apple ID.
3. Click “Report a Problem” on the offending app.
4. Choose “Problem is not listed here” and be sure to mention that you are asking for a refund because it doesn’t work as expected.
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.