Skip to content

Instantly share code, notes, and snippets.

@mralexgray
mralexgray / gist:3280086
Created August 7, 2012 00:52 — forked from cweider/gist:2465637
CTUIImage+Extensions
//
// CTUIImage+Extensions.h
// MineSweeper
//
// Created by Chad Weider on 3/29/12.
// Copyright (c) 2012 Chad Weider. All rights reserved.
//
#import <UIKit/UIKit.h>
@jacksonh
jacksonh / gist:3267802
Created August 5, 2012 23:13 — forked from bvanderveen/gist:3260382
Objective-C assertion ideas
- (void) assertionIdeasLikeNUnit
{
[Assert that:@"foobar" is:[Equal to:@"other"]];
[Assert that:@"foobar" isNot:[Equal to:@"other"]];
[Assert that:collection isAll:[Less than:@10]];
[Assert that:collection isAll:[Less thanOrEqualTo:@10]];
[Assert that:collection isAll:[Less thanOrEqualTo:@10]];
[Assert that:collection isAll:[Greater than:@10]];
[Assert that:collection isAll:[Greater thanOrEqualTo:@10]];
@dbrajkovic
dbrajkovic / AsyncSenTestingKitTests.h
Created August 4, 2012 21:17 — forked from akisute/AsyncSenTestingKitTests.h
SenAsyncTestCase - Asynchronous capable SenTestCase
//
// AsyncSenTestingKitTests.h
// AsyncSenTestingKitTests
//
// Created by 小野 将司 on 12/03/17.
// Copyright (c) 2012年 AppBankGames Inc. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#import "SenAsyncTestCase.h"
@evanlong
evanlong / fun.m
Created August 4, 2012 20:54
ParticleFun
- (void)viewDidLoad {
[super viewDidLoad];
UIView *holderView = [[UIView alloc] initWithFrame:CGRectMake(50.0f, 50.0f, 200.0f, 200.0f)];
CAEmitterLayer *emitterLayer = [CAEmitterLayer layer];
emitterLayer.frame = CGRectMake(0.0f, 0.0f, 200.0f, 200.0f);
emitterLayer.emitterSize = CGSizeMake(20.0f, 20.0f);
emitterLayer.emitterPosition = CGPointMake(90.0f, 90.0f);
@SONIC3D
SONIC3D / NSMutableStringSample.m
Created August 4, 2012 17:31
NSMutableString Code Snippet
// life cycle
NSMutableString *s1 = [NSMutableString stringWithCapacity:10];
NSMutableString *s2 = [[NSMutableString alloc] initWithCapacity:10];
[s2 release];
// fill string
[s1 appendFormat:@"%@ Objective-C!", @"Hello"];
NSLog(@"%@", s1);
// append string
[s1 appendString:@" Glad to be here."];
NSLog(@"%@", s1);
@codeswimmer
codeswimmer / ios_predicate_filter.txt
Created August 3, 2012 16:48
iOS: Using an NSPredicate for filtering an array
NSArray *retailerList = ((RetailerDetailsResponseV1*)[RetailerDetailsResponseV1 readFromFile:kBNCloudFileNameRetailers]).retailerList;
if (retailerList.count > 0) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"retailerId != [cd] %@ AND countryId == [cd] %@", @"NOK", countryCode];
NSArray *retailer = [retailerList filteredArrayUsingPredicate:predicate];
if (retailer) {
return [[retailer objectAtIndex:0] valueForKey:@"retailerId"];
}
}
@briangonzalez
briangonzalez / gist:3242283
Created August 2, 2012 23:57
Running Applescript from Cocoa
NSString *someScript = [[NSBundle mainBundle] pathForResource:@"some_script" ofType:@"osascript"];
NSString *contents = [NSString stringWithContentsOfFile:someScript encoding:NSUTF8StringEncoding error:nil];
NSAppleScript *script =[[NSAppleScript alloc] initWithSource:contents];
[script executeAndReturnError:nil];
@fogus
fogus / family-trees.txt
Created August 2, 2012 00:58 — forked from zerokarmaleft/family-trees.txt
Game of Thrones Challenge #65
AA = Rickard Stark (M) AB = Eddard Stark (M) AC = Catelyn Tully (F)
AD = Brandon Stark (M) AE = Benjen Stark (M) AF = Jon Snow (M)
AG = Robb Stark (M) AH = Sansa Stark (F) AI = Arya Stark (F)
AJ = Bran Stark (M) AK = Rickon Stark (M) AL = Hoster Tully (M)
AM = Minisa Whent (F) AN = Edmure Tully (M) AO = Lysa Tully (F)
AP = Jon Arryn (M) AQ = Robert Arryn (M) AR = Tytos Lannister (M)
AS = Tywin Lannister (M) AT = Joanna Lannister (F) AU = Kevan Lannister (M)
AV = Cersei Lannister (F) AW = Jamie Lannister (M) AX = Tyrion Lannister (M)
AY = Robert Baratheon (M) AZ = Joffrey Baratheon (M) BA = Myrcella Baratheon (F)
BB = Tommen Baratheon (M) BC = Lancel Lannister (M) BD = Steffon Baratheon (M)
@t3db0t
t3db0t / eeprom_rw_test.ino
Created August 1, 2012 19:53
Arduino EEPROM Read-Write Example
/******************************************************
Arduino EEPROM Read-Write Test
by Ted Hayes 2012
[email protected]
Demonstrates the usage of the EEPROM Library for checking the state of a single value,
changing it, and resetting it. To use:
1) Put a momentary switch between ground and pin 11 on your Arduino.
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
This example code is in the public domain.
*/
int brightness = 0; // how bright the LED is