Skip to content

Instantly share code, notes, and snippets.

Adam Sharp sharplet

Block or report user

Report or block sharplet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sharplet
sharplet / NSArray+indexPathKeyedSubscript.m
Last active Dec 17, 2015
Category on NSArray to allow subscripting via an NSIndexPath.
View NSArray+indexPathKeyedSubscript.m
//
// Category on NSArray to allow subscripting via an NSIndexPath.
//
// Adam Sharp
// May 27, 2013
//
// Given this array:
//
// NSArray *matrix = @[
// @[ @1, @2 ],
View git-remove-submodule
#!/bin/sh
#
# Adam Sharp
# Aug 21, 2013
#
# Usage: Add it to your PATH and `git remove-submodule path/to/submodule`.
#
# Does the inverse of `git submodule add`:
# 1) `deinit` the submodule
# 2) Remove the submodule from the index and working directory
@sharplet
sharplet / README.md
Last active Jun 8, 2018
Unearned Stack Overflow badges Dashing widget
View README.md

Badge Overflow

An exceptionally handsome way to track your Stack Overflow badges.

Created by Adam & Stephanie Sharp.

Unearned Badges widget

A Dashing widget that tracks your progress toward unearned badges on Stack Overflow.

@sharplet
sharplet / composite_task.rb
Last active Aug 29, 2015
Normally a rake task won't complete if one of its prerequisites fails. Define a composite task to allow them all to run, capturing exceptions and reporting them only after all have completed.
View composite_task.rb
# Take for example a convenience task, all_tests, that runs our app's
# test suite for multiple architectures:
#
# task :all_tests => [:test_64_bit, :test_32_bit]
#
# Defined as a regular task, Rake will bail out early if
# test_64_bit failed, never getting to the 32 bit tests.
#
# A composite task is almost identical in declaration:
#
@sharplet
sharplet / method.swift
Created Jan 13, 2015
Mapping with methods
View method.swift
/// Convert a free method into a regular funcion accepting an instance as the first parameter.
func method<A, B>(m: A -> () -> B) -> A -> B {
return { m($0)() }
}
let strings = ["1", "2", "3", "foo"]
strings.map(method(String.toInt))
// => [{Some 1}, {Some 2}, {Some 3}, nil]
@sharplet
sharplet / ConcatenateSequence.swift
Created Feb 9, 2015
Generic concatenation of sequences in Swift
View ConcatenateSequence.swift
func + <S: SequenceType, E where S.Generator.Element == E> (lhs: S, rhs: S) -> GeneratorOf<E> {
var (g, h) = (lhs.generate(), rhs.generate())
return GeneratorOf {
g.next() ?? h.next()
}
}
@sharplet
sharplet / .clang-format
Created Apr 13, 2015
clang-format file for Objective-C projects
View .clang-format
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
BasedOnStyle: LLVM
BreakBeforeBraces: Attach
ColumnLimit: 120
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
@sharplet
sharplet / rake.log
Created Apr 15, 2015
Rake output building a framework and XCTest bundle from the command line
View rake.log
$ rake
mkdir -p Build
mkdir -p Build/Switch.framework
mkdir -p Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule
ln -sf A Build/Switch.framework/Versions/Current
ln -sf Versions/Current/Modules Build/Switch.framework/Modules
ln -sf Versions/Current/Switch Build/Switch.framework/Switch
xcrun -sdk macosx swiftc -module-name Switch -emit-library -o Build/Switch.framework/Versions/Current/Switch -- Source/Switch.swift
xcrun -sdk macosx swiftc -module-name Switch -emit-module-path Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule/x86_64.swiftmodule -- Source/Switch.swift
touch Build/Switch.framework
@sharplet
sharplet / rake.log
Last active Feb 3, 2018
Building a Swift framework, then building and running Quick specs, *without Xcode*
View rake.log
# View on GitHub: https://github.com/sharplet/Switch
# Try it yourself: git clone https://github.com/sharplet/Switch.git && cd Switch && rake
$ rake
mkdir -p Build
mkdir -p Build/Switch.framework
mkdir -p Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule
ln -sf A Build/Switch.framework/Versions/Current
ln -sf Versions/Current/Modules Build/Switch.framework/Modules
ln -sf Versions/Current/Switch Build/Switch.framework/Switch
xcrun -sdk macosx swiftc -module-name Switch -emit-library -o Build/Switch.framework/Versions/Current/Switch -- Source/Array+Ext.swift Source/Option.swift Source/ParseResult.swift Source/Parser.swift Source/String+Ext.swift
View Kiwi.swift
import Kiwi
import XCTest
class KiwiSpec: KWSpec {
override class func buildExampleGroups() {
it("has a test") {
XCTAssert(1 + 1 == 2)
}
}
}
You can’t perform that action at this time.