Skip to content

Instantly share code, notes, and snippets.

@akolov
akolov / TestCase.swift
Created September 18, 2014 12:37
Testing for XCTAssertThrows in Swift
class ExceptionTestCase: XCTestCase {
func raisesException() {
var exception = NSException(name: NSInternalInconsistencyException, reason: "Testing exceptions", userInfo: nil)
XCTAssertThrows({ exception.raise() }, "Should raise an exception)
XCTAssertThrowsSpecific({ exception.raise() }, NSInternalInconsistencyException, "Should raise NSInternalInconsistencyException")
}
}
@staltz
staltz / introrx.md
Last active July 27, 2024 04:59
The introduction to Reactive Programming you've been missing
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode, add the script's path to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset
@mattstevens
mattstevens / embedded_resource.m
Last active December 20, 2015 20:08
Access embedded resource in command line tool
#import <Foundation/Foundation.h>
#import <mach-o/dyld.h>
#import <mach-o/getsect.h>
#import <mach-o/ldsyms.h>
// Embed via other linker flags: -sectcreate __TEXT test $(PROJECT_DIR)/test.txt
// Names are limited to 16 characters.
NSData *MSEmbeddedResourceDataWithName(NSString *name) {
unsigned long size = 0;
uint8_t *data = getsectiondata(&_mh_execute_header, "__TEXT", [name UTF8String], &size);
@parente
parente / runinenv.sh
Created February 15, 2011 01:54
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"