Skip to content

Instantly share code, notes, and snippets.

View chrismiles's full-sized avatar

Chris Miles chrismiles

View GitHub Profile
@chrismiles
chrismiles / CoreGraphicsCMExtras.c
Created June 8, 2011 02:04
Core Graphics Extra Convenience Functions
/*
Example:
CGRect fillRect = CGRectMake(0.0, 0.0, 50.0, 100.0);
size_t locationCount = 2;
CGFloat locationList[] = {0.0, 1.0};
CGFloat colorList[] = {
//red, green, blue, alpha
244.0/255.0, 207.0/255.0, 80.0/255.0, 1.0,
255.0/255.0, 161.0/255.0, 59.0/255.0, 1.0,
@chrismiles
chrismiles / NSDate+CMExtras.h
Created June 6, 2011 10:34
NSDate category extension - handy convenience methods
@interface NSDate ( CMExtras )
- (NSDate *)stripTimeComponent;
@end
@chrismiles
chrismiles / random_funcs.c
Created June 6, 2011 07:05
Random number on iOS
/* Return a random integer number between low and high inclusive */
int randomInt(int low, int high)
{
return (arc4random() % (high-low+1)) + low;
}
/* Return a random BOOL value */
BOOL randomBool()
{
return (BOOL)randomInt(0, 1);
@chrismiles
chrismiles / BaseViewController.m
Created May 21, 2011 03:14 — forked from boctor/BaseViewController.m
A base view controller class that when running on the simulator in debug mode, will auto simulate a memory warning every time the view controller's viewDidAppear is called
//
// BaseViewController.m
//
// Created by Peter Boctor on 5/4/11.
//
// Copyright (c) 2011 Peter Boctor
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@chrismiles
chrismiles / MyLayer.m
Created March 14, 2011 07:35
Animate a custom property in a CALayer example.
//
// MyLayer.m
//
// Created by Chris Miles on 14/03/11.
// Copyright 2011 Chris Miles.
//
/*
Animate custom property example: