Skip to content

Instantly share code, notes, and snippets.

View bddckr's full-sized avatar

Christopher-Marcel Esser bddckr

View GitHub Profile
@bddckr
bddckr / Assertions.h
Last active December 19, 2015 07:59
Assertion macro that works exactly like NSAssert(), with the modification that a code block will be run if the condition is not met. Helps a lot to prevent repetitions when handling the condition a second time for release code (NSAssert will be stripped by default.) Thanks to @ merowing_ for https://gist.github.com/krzysztofzablocki/5921645 !
// See http://stackoverflow.com/a/257424/283482
// Normally a "do {…} while (0)" is used to prevent the problem described in the linked answer,
// but this would prevent us from using "continue" or "break" in the block parameter.
// The problem is fixed thanks to the "if (1) {…}", doing the same as the "do {…} while (0)".
#define AssertTrueOrRunBlock(condition, block, description, ...)\
if (1) {\
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS\
BOOL check = !!(condition);\
NSCAssert(check, (description), ##__VA_ARGS__);\
@bddckr
bddckr / alfred.txt
Last active December 15, 2015 08:49
Custom Alfred OpenGL ES Documentation search for gl{query}. Copy and paste into browser to open in Alfred.
alfred://customsearch/OpenGL%20ES%20Documentation%20for%20gl%7Bquery%7D/opengl/utf8/noplus/http://www.khronos.org/opengles/sdk/docs/man/xhtml/gl{query}.xml