Skip to content

Instantly share code, notes, and snippets.

View kevboh's full-sized avatar

Kevin Barrett kevboh

View GitHub Profile
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@darkseed
darkseed / Reachability.h
Created August 30, 2011 23:16 — forked from dhoerl/Reachability.h
Reachability (iOS) ARCified
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 2.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
@kevinbarrett
kevinbarrett / NSFileManager+DoNotBackup.h
Created March 8, 2012 18:02 — forked from tibr/NSFileManager+DoNotBackup.h
Setting the do not backup attribute in different iOS versions
@interface NSFileManager (DoNotBackup)
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
@end
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@lxcid
lxcid / receipt.json
Created December 27, 2012 03:42
Sample Sandbox In-App Purchase Receipt that is expired.
{
"status": 21006,
"receipt": {
"original_purchase_date_ms": "1335927991000",
"original_purchase_date_pst": "2012-05-01 20:06:31 America\/Los_Angeles",
"transaction_id": "1000000060958597",
"quantity": "1",
"bid": "kh.com.ctn.plus",
"original_transaction_id": "1000000046496076",
"unique_vendor_identifier": "1E8A3A6A-F455-4020-8194-7BC14991A00A",
@nonamelive
nonamelive / CollectionViewFloatingHeaderFlowLayout.m
Created May 17, 2013 19:28
A collection view flow layout with floating headers support, compatible with PSTCollectionView. Thanks to @cocotutch! The original answer on StackOverflow can be found at http://stackoverflow.com/questions/13511733/how-to-make-supplementary-view-float-in-uicollectionview-as-section-headers-do-i/13678922#13678922
#import "PSTCollectionView.h"
@implementation CollectionViewFloatingHeaderFlowLayout
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
NSMutableArray *answer = [[super layoutAttributesForElementsInRect:rect] mutableCopy];
PSTCollectionView *const cv = self.collectionView;
CGPoint const contentOffset = cv.contentOffset;
@clayton
clayton / ffmpeg-install.sh
Created August 9, 2013 18:55
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
@mutewinter
mutewinter / commit_format.txt
Created March 19, 2014 18:52
My commit message format.
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.

CocoaPods + Xcode Continuous Integration

Script:

cd ${SRCROOT}
if [ -e "Pods" ]
then
pod install
else
touch Pods
@landonf
landonf / 1-README.md
Last active June 2, 2016 06:49
Swift Result Type

A result type (based on swiftz) that can represent either an error or success:

enum Result<X, T> {
  case Err(() -> X)
  case Ok(() -> T)
}

Now we need a way to chain multiple results together without lots of nesting of if statements -- or exceptions. To do so, we can define a new bind (result, next) operator (implementation borrowed from swiftz) that operates on Result types (a.k.a flatMap or >>=):

  • If the result is Err, the result is immediately returned.