Skip to content

Instantly share code, notes, and snippets.

@griotspeak
griotspeak / nah_xcode_uncrustify.rb
Created October 23, 2012 01:59 — forked from mnem/nah_xcode_uncrustify.rb
Script file to be run as an Xcode 4 behaviour which uncrustifies the project source using reasonable Objective-C formatting defaults. Alternatively, you can run it and pass a path to uncrustify.
#!/usr/bin/env ruby
###########################################################################
# Script to be called as an Xcode 4 behaviour which will attempt to
# uncrustify all source files in the open project.
#
# (c) Copyright 2012 David Wagner.
#
# Complain/commend: http://noiseandheat.com/
#
#*************************************************************************#
@griotspeak
griotspeak / unix_instruments.sh
Created October 25, 2012 02:11 — forked from jonathanpenn/unix_instruments.sh
Make Instruments play nice with unix by returning > 0 status code if build fails
#!/usr/bin/env bash
#
# Copyright (c) 2012 Jonathan Penn (http://cocoamanifest.net)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#define STRUNG_ENUM(THE_ARGS...) STRUNG_SOMETHING(NS_ENUM, THE_ARGS)
#define STRUNG_OPTIONS(THE_ARGS...) STRUNG_SOMETHING(NS_OPTIONS, THE_ARGS)
#define STRUNG_SOMETHING(TARGET_NS_MACRO, ENUM_BASE_TYPE, ENUM_NULL_VALUE, ENUM_NAME, ENUM_VALUES...) typedef TARGET_NS_MACRO (ENUM_BASE_TYPE, ENUM_NAME) { \
ENUM_VALUES \
}; \
\
\
\
static NSString * ENUM_NAME ## ToDebugString(int enumValue) { \
struct Tree<A> {
let val: A
let left: @autoclosure () -> Tree<A>
let right: @autoclosure () -> Tree<A>
}
struct Stream<A> {
let val: A
let next: @autoclosure () -> Stream<A>
}
@griotspeak
griotspeak / FirstOpenSwiftDoc
Created November 3, 2014 16:04
Applescript to switch to first open tab ending with ".swift"
set current_document_path to ""
tell application "Xcode"
set last_word_in_main_window to ".swift"
if (last_word_in_main_window is "Edited") then
display notification "Please save the current document and try again"
-- eventually we could automatically save the document when this becomes annoying
else
set current_document to document 1 whose name ends with last_word_in_main_window
set current_document_path to path of current_document
@griotspeak
griotspeak / zipTailAndReduce.swift
Last active August 29, 2015 14:11
zipTailAndReduce
extension Slice {
func zipWithTail() -> Zip2<Slice<T>, Slice<T>> {
return Zip2(self, dropFirst(self))
}
}
extension Array {
func zipWithTail() -> Zip2<[T], Slice<T>> {
return Zip2(self, dropFirst(self))
//
// NUIBezierPath.h
// NUIKit
//
// Created by Robert Widmann on 10/11/13.
// Copyright (c) 2013 CodaFi. All rights reserved.
// Released under the MIT license.
//
#import <Foundation/Foundation.h>
@griotspeak
griotspeak / Set+TJU.swift
Created June 1, 2015 16:10
Swift.Set extensions
//
// Set.swift
// TonalKit
//
// Created by TJ Usiyan on 3/2/15.
// Copyright (c) 2015 buttons-and-lights. All rights reserved.
// https://gist.github.com/17d2f63780e9549a3335.git
import Foundation
@griotspeak
griotspeak / Optional_TJU.swift
Created June 1, 2015 16:12
Swift.Optional extensions
//
// Optional.swift
// TonalKit
//
// Created by TJ Usiyan on 11/4/14.
// Copyright (c) 2014 Buttons and Lights LLC. All rights reserved.
// https://gist.github.com/d9d826ed242b89ff2d85.git
extension Optional {
@griotspeak
griotspeak / Array+TJU.swift
Last active August 29, 2015 14:22
Swift.Array extensions
//
// Array.swift
// TonalKit
//
// Created by TJ Usiyan on 11/8/14.
// Copyright (c) 2014 Buttons and Lights LLC. All rights reserved.
// https://gist.github.com/7a9444caf1b225070b88.git
public func reduceR<S : CollectionType, U, IndexType : BidirectionalIndexType where S.Index == IndexType>(sequence: S, initial: U, combine: (U, S.Generator.Element) -> U) -> U{