Skip to content

Instantly share code, notes, and snippets.

View chrismiles's full-sized avatar

Chris Miles chrismiles

View GitHub Profile
@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:
@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 / 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 / NSDate+CMExtras.h
Created June 6, 2011 10:34
NSDate category extension - handy convenience methods
@interface NSDate ( CMExtras )
- (NSDate *)stripTimeComponent;
@end
@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 / UIView+CMExtras.h
Created June 9, 2011 09:24
UIView class extension with some of my handy convenience methods
//
// UIView+CMExtras.h
//
// Created by Chris Miles on 9/06/11.
// Copyright 2011 Chris Miles.
//
// 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@chrismiles
chrismiles / ModelUtil.h
Created June 22, 2011 08:28
My Core Data model helper functions
//
// ModelUtil.h
//
// Copyright 2011 Chris Miles. All rights reserved.
//
// 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@chrismiles
chrismiles / NSArray+CMRandomised.h
Created October 15, 2011 05:23
Return a randomised copy of an NSArray
//
// NSArray+CMRandomised.h
//
// Copyright 2011 Chris Miles. All rights reserved.
//
// 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@chrismiles
chrismiles / UIImageView+CMAsyncExtension.m
Created March 6, 2012 02:23
UIImageView (CMAsyncExtension) - async load image from URL
@interface UIImageView (CMAsyncExtension)
- (void)asyncLoadImageFromURL:(NSURL *)imageURL;
@end
@implementation UIImageView (CMAsyncExtension)
- (void)asyncLoadImageFromURL:(NSURL *)imageURL
{
@chrismiles
chrismiles / Main Program.h
Created February 3, 2013 08:01
Invalid source code generated by SLE Sensor Tag iOS app. Ref TI forum thread http://e2e.ti.com/support/low_power_rf/f/538/t/243474.aspx
//
// Main Program.h
//
//
// Created by BLE Sensor Tag.
//
//
#include <CoreBluetooth/CoreBluetooth.h>
#include "Sensors.h"