Skip to content

Instantly share code, notes, and snippets.

View lawrencelomax's full-sized avatar

Lawrence Lomax lawrencelomax

View GitHub Profile
@lawrencelomax
lawrencelomax / gist:4704470
Last active December 12, 2015 03:08
Enumeration of NULL terminated Varargs
#define ENUMERATE_NULL_TERMINATED_VARARGS(firstArgument, type, argumentName, operation) \
{ \
va_list arguments; \
va_start(arguments, firstArgument); \
type argumentName = firstArgument; \
while (argumentName) \
{ \
{ \
operation \
} \
@lawrencelomax
lawrencelomax / gist:4617449
Last active December 11, 2015 14:58
Variadic Macros for Pushing and Popping GL State
extern void bilContext_glClientState(dispatch_block_t contextBlock, GLenum clientState, ... )
{
va_list arguments;
GLenum value;
va_start(arguments, clientState);
for (value = clientState; value > 0; value = va_arg(arguments, GLenum))
{
glEnableClientState(value);
}
@lawrencelomax
lawrencelomax / gist:1670617
Created January 24, 2012 15:09
Simple progressive image loading
UIView * view = [[UIView alloc] initWithFrame:CGRectMake( 0.0f, 0.0f, kAffirmationThumbnailWidth, kAffirmationThumbnailHeight )];
view.backgroundColor = [UIColor grayColor];
UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kAffirmationThumbnailWidth, kAffirmationThumbnailHeight)];
imageView.backgroundColor = [UIColor clearColor];
imageView.alpha = 1.0;
[view addSubview:imageView];
// Background getting of small image and loading into memory
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
NSString * imagePathSmall = [NSString stringWithFormat:@"%@_small.jpg",[[affirmation imagePath] stringByDeletingPathExtension]];