This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SSMutableIndexPathSet.h | |
// MutableIndexPathSet Test | |
// | |
// Created by Colin Barrett on 11/19/10. | |
// Copyright 2010 __MyCompanyName__. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stringByAddingPercentEscapesUsingEncoding is pretty conservative about escaping characters, which is fine most of the time. This method however escapes *all special characters*, allowing any arbitrary string to be used when building any part of a URL. | |
// (c) 2011 Springs & Struts. Released under MIT-style license. See: http://www.opensource.org/licenses/mit-license.php | |
@interface NSString (SSURLEscaping) | |
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding; | |
@end | |
@implementation NSString (SSURLEscaping) | |
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am cbarrett on github. | |
* I am chbarrett (https://keybase.io/chbarrett) on keybase. | |
* I have a public key ASDhSCmtfibfvZ0Lo54bUO6YcFc7iqAiFDj0Um0oFWhc9wo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// type State = ... | |
// infix operator <>: AdditionPrecedence | |
// enum Either<A, B> { ... | |
struct Reducer<Action> { | |
let reduce: (Action, State) -> State | |
init(_ f: @escaping (Action, State) -> State) { | |
reduce = f | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2017 Colin Barrett, all rights reserved. | |
// License freely granted under the terms of CC-BY-NC <https://creativecommons.org/licenses/by-nc/4.0/>. | |
import Darwin | |
public class AtomicPointer<Pointee>: Equatable { | |
fileprivate var ptr: UnsafeMutablePointer<Pointee?> | |
fileprivate var flag: atomic_flag = atomic_flag() | |
public init(_ pointee: inout Pointee?) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dhall, a terminating configuration language | |
// Syntax: https://github.com/Gabriel439/Haskell-Dhall-Library/blob/master/src/Dhall/Core.hs | |
// This gist's history: | |
// 1. Contents at stream end | |
// 2. Clean up free vs. bound variables | |
enum Expr { | |
case constant(Int) | |
case variable(Bound) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Let's say you want to list all of the options to your program as an enum */ | |
enum Option { | |
OptionFoo, | |
OptionBar, | |
CountOfOption | |
} | |
/* You want to write a procedure to generate a help message for your program. Here's one way: */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addDependentTree :: FilePath -> Bool -> Q () | |
addDependentTree p inclFile = do | |
pwd <- runIO getCurrentDirectory | |
let p' = if not inclFile then dropFileName p else p | |
let paths = scanl (</>) pwd (splitDirectories p') | |
mapM_ addDependentFile paths -- We add every subdirectory along `p` in the hopes of catching any new files added therein |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang scheme | |
(require racket/control) | |
(require racket/match) | |
(define (create-signal didSubscribe) | |
(lambda (next error complete) | |
(match (shift k (didSubscribe k)) | |
[(list 'next v) (next v)] | |
[(list 'error e) (error e)] | |
[(list 'complete) (complete)]))) |
NewerOlder