Skip to content

Instantly share code, notes, and snippets.

View jblocksom's full-sized avatar

Jonathan Blocksom jblocksom

View GitHub Profile
@jblocksom
jblocksom / Constants.m
Last active December 21, 2015 09:39
Helpers for Quartz chapter
#define RANGE (700.0f)
// RANGE is the range of values that are OK
#define B_MARGIN (10.0f)
// B_MARGIN is the bottom margin in points
#define T_MARGIN (10.0f)
// T_MARGIN is the top margin in points
#define H_GAP (10.4f)
for (BNRNerd *nerd in self.nerds) {
[self.geocodeQueue addOperationWithBlock:^{
NSOperationQueue *managingQueue = [NSOperationQueue currentQueue];
[geocoder geocodeAddressString:nerd.locationStr completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = placemarks[0];
nerd.location = placemark.location;
[self fetchWeatherForNerd:nerd];
[managingQueue setSuspended:NO];
}];
[managingQueue setSuspended:YES];
GLfloat boxVerts[] = {
// left side
-1.0, -1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, 1.0, 1.0,
// right side
@jblocksom
jblocksom / pg76.m
Created January 7, 2014 18:02
Some handy snippets for the iCloud chapter
#pragma mark - iCloud
- (BOOL)hasiCloud
{
BOOL hasiCloud = ([self ubiquitousDocumentsURL] != nil);
return hasiCloud;
}
- (void)setUseiCloud:(BOOL)value
{
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
-(void)initOffscreenContext
{
CGSize layerSize = [self bounds].size;
layerSize.height = floorf(layerSize.height);
layerSize.width = floorf(layerSize.width);
if (layerSize.height <= 0 || layerSize.width <=0)
{
self.offscreenContext = nil;
return;
Last summer Apple introduced Metal, a new 3D graphics API for iOS devices featuring faster, more detailed access to the graphics hardware. In this session we will introduce programmers to the Metal API. We will start with a high level overview of Metal and how it compares to OpenGL, comparing the two and seeing what the cost is for the extra graphics speed. We will look at using Metal for GPU based computation, using the Metal Shading Language for rendering, and how to combine them for intense GPU powered apps.