Skip to content

Instantly share code, notes, and snippets.

@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"];
}
}
@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);
@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);
@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"
@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]];
@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>

Funktioner

Init

Starta ett nytt projekt i nuvarande katalogen. Detta skulle vara gjort så att man inte behöver komma ihåg alla detaljer om det som skall göras.

  • Git init
  • Lägg till github repo som remote
  • Skapa config filer för deploy script
  • Installera valfritt projekt: drupal, wordpress, html5boilerplate
@maxkramer
maxkramer / NSArray - arrayCreate()
Created August 8, 2012 16:47
Quick NSArray creation objective-c
NSArray *arrayCreate(id firstObject, ...) {
NSMutableArray *objects = [NSMutableArray array];
[objects addObject:firstObject];
va_list args;
va_start(args, firstObject);
id arg;
while ((arg = va_arg(args, id))) {
if (arg == nil)
break;
[objects addObject:arg];
/**
* MCG
*/
body {
color: #333;
font-size: 14px;
font-family:'Radley', serif;
font-weight: 400;
}
@irace
irace / BITwitterAuthenticator.h
Created August 9, 2012 21:09
Objective-C Twitter three-legged authorization flow
//
// BITwitterAuthenticator.h
//
// Created by Bryan Irace on 8/9/12.
// http://bryan.mit-license.org
//
@interface BITwitterAuthenticator : NSObject
@property (nonatomic, copy) NSString *OAuthConsumerToken;