Skip to content

Instantly share code, notes, and snippets.

Nikolaj Schumacher nschum

Block or report user

Report or block nschum

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
@nschum
nschum / indent.swift
Last active Jul 18, 2016
Indenting chained methods
View indent.swift
// 1
myvariable.mymethod(bla)
.mymethod(bla, bla, bla)
.mymethod(bla, bla)
.mymethod() {
doSomething()
}
// 2
myvariable.mymethod(bla)
@nschum
nschum / Precondition.swift
Created Jul 10, 2015
Testing precondition (or assert) in Swift
View Precondition.swift
/// Our custom drop-in replacement `precondition`.
///
/// This will call Swift's `precondition` by default (and terminate the program).
/// But it can be changed at runtime to be tested instead of terminating.
func precondition(@autoclosure condition: () -> Bool, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UWord = __LINE__) {
preconditionClosure(condition(), message(), file, line)
}
/// The actual function called by our custom `precondition`.
var preconditionClosure: (Bool, String, StaticString, UWord) -> () = defaultPreconditionClosure
@nschum
nschum / README.md
Created Sep 21, 2014
OS X Yosemite Messages database merger
View README.md

OS X Yosemite Messages database merger

Early betas of OS X Yosemite had a bug where the library of old messages wasn't migrated. Instead a new library was created and all old messages were gone.

The bug has been fixed, but if you were affected, you still have two separate libraries. This script merged them for me. Use it at your own risk! You might end up worse than before. Backup everything beforehand. Twice.

This is what your ~/Library/Messages folder will look like if you're affected:

  • chat.db
@nschum
nschum / gist:2626303
Created May 7, 2012
better "enum class" indent in Emacs
View gist:2626303
;; This hack fixes indentation for C++11's "enum class" in Emacs.
;; http://stackoverflow.com/questions/6497374/emacs-cc-mode-indentation-problem-with-c0x-enum-class/6550361#6550361
(defun inside-class-enum-p (pos)
"Checks if POS is within the braces of a C++ \"enum class\"."
(ignore-errors
(save-excursion
(goto-char pos)
(up-list -1)
(backward-sexp 1)
@nschum
nschum / NSString+UUID.h
Created Jan 1, 2011
UUID and unique file names on iOS
View NSString+UUID.h
@interface NSString(UUID)
+ (NSString *)stringWithUUID;
+ (NSString *)stringWithUniquePath;
@end
You can’t perform that action at this time.