This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
#define kAPIEndpointHost @"http://example.dev" | |
#else | |
#define kAPIEndpointHost @"http://www.example.com" | |
#endif | |
#define kAPIEndpointLatest (kAPIEndpointHost @"/api/latest_content") | |
#define kAPIEndpointMostPopular (kAPIEndpointHost @"/api/most_popular") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const char *s; // read as "s is a pointer to a char that is constant" | |
char c; | |
char *const t = &c; // read as "t is a constant pointer to a char" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## for (int i = 0; i < 10; i++) { } | |
LBL1: | |
cmpl $10, -4(%ebp) ## -4(%ebp) is the stack address of i. Check if it is less than 10 | |
jge LBL3 ## If the previous compare had a greater than or equal to result, exit the loop | |
jmp LBL2 ## Otherwise, jump to the next address (this instruction will get optimized away) | |
LBL2: | |
movl -4(%ebp), %eax ## Load i into the EAX register (where the arithmetic happens!) | |
addl $1, %eax ## Add 1 to the EAX register | |
movl %eax, -4(%ebp) ## Copy the EAX register back on to the stack at the address for i. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIViewController+SegueData.h | |
// SegueDataPassing - Helper method for performing a segue and passing data to | |
// the destination view controller. | |
// | |
// Created by John Hurliman on 10/21/14. | |
// Copyright (c) 2014 John Hurliman. Released under the MIT license. | |
// http://opensource.org/licenses/MIT | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List all font families and font names in iOS | |
for (NSString *familyName in UIFont.familyNames) { | |
NSLog(@"%@", familyName); | |
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { | |
NSLog(@" %@", fontName); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varying vec2 textureCoordinate; | |
uniform sampler2D inputImageTexture; | |
vec3 rgb2xyz(vec3 c) { | |
vec3 tmp; | |
tmp.x = (c.r > 0.04045) ? pow( (c.r + 0.055) / 1.055, 2.4) : c.r / 12.92; | |
tmp.y = (c.g > 0.04045) ? pow( (c.g + 0.055) / 1.055, 2.4) : c.g / 12.92; | |
tmp.z = (c.b > 0.04045) ? pow( (c.b + 0.055) / 1.055, 2.4) : c.b / 12.92; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varying vec2 textureCoordinate; | |
uniform sampler2D inputImageTexture; | |
vec3 lab2xyz(vec3 c) { | |
float fy = (c.x + 16.0) / 116.0; | |
float fx = c.y / 500.0 + fy; | |
float fz = fy - c.z / 200.0; | |
return vec3( 95.047 * ((fx > 0.206897) ? fx * fx * fx : (fx - 16.0 / 116.0) / 7.787), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ALPHABET = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; | |
function generateFirebaseID() { | |
var timestamp = +new Date(); | |
var chars = Array(20); | |
for (var i = 7; 0 <= i; i--) { | |
chars[i] = ALPHABET.charAt(timestamp % 64); | |
timestamp = Math.floor(timestamp / 64); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/utsname.h> | |
+ (BOOL)isIPhone6OrNewer | |
{ | |
static int major = -1; | |
if (major == -1) { | |
struct utsname unameData; | |
if (0 != uname(&unameData)) { | |
major = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (BOOL)isValidEmail:(NSString *)str | |
{ | |
NSString *emailRegex = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:str]; | |
} |