Skip to content

Instantly share code, notes, and snippets.

View halsk's full-sized avatar

Hal Seki halsk

View GitHub Profile
@halsk
halsk / NSURL+dictionaryFromQueryString.h
Created February 28, 2013 08:46
URLのパラメータ部分を NSDictionary に変換する ref: http://qiita.com/items/413ec7902f48ec39821f
#import <Foundation/Foundation.h>
@interface NSURL (dictionaryFromQueryString)
-(NSDictionary *) dictionaryFromQueryString;
@end
@halsk
halsk / file0.txt
Created March 12, 2013 13:51
Kiwi + AFNetworking で Undefined symbols for architecture エラーが出た場合の対処 ref: http://qiita.com/items/79499813fac37ad5cd8a
platform :ios, '5.1'
pod 'AFNetworking', '1.1.0'
target :NSRemoteJsonObjectTests, :exclusive => true do
pod 'Kiwi'
end
@halsk
halsk / file0.txt
Created March 14, 2013 15:30
Spending.jp クローンサイトの立ち上げ手順 (OpenSpending 対応版) ref: http://qiita.com/hal_sk/items/d1cfa971fbbc09777d20
% git clone git@github.com:{ACCOUNT_NAME}/{ACCOUNT_NAME}.github.io.git
Cloning into '{ACCOUNT_NAME}.github.com'...
remote: Counting objects: 895, done.
remote: Compressing objects: 100% (366/366), done.
remote: Total 895 (delta 500), reused 880 (delta 486)
Receiving objects: 100% (895/895), 1.02 MiB | 368 KiB/s, done.
Resolving deltas: 100% (500/500), done.
@halsk
halsk / file0.txt
Created March 16, 2013 13:31
NSInvocation を使ってクラスメソッドを呼ぶ ref: http://qiita.com/items/947b1cdaae17e29ce082
// define selector
SEL selector = @selector(postToURL:withParams:async:);
// get method signeture
NSMethodSignature* signature = [[self class] methodSignatureForSelector: selector];
// make NSInvocation instance
NSInvocation* invocation = [ NSInvocation invocationWithMethodSignature: signature ];
[invocation setSelector:selector];
[invocation setTarget:[self class]];
[invocation setArgument:&strurl atIndex:2];
[invocation setArgument:&params atIndex:3];
@halsk
halsk / User.h
Created March 16, 2013 15:35
サーバの JSON テキストから Objective-C のインスタンスを生成するライブラリ、SimpleRemoteObject を公開しました。 ref: http://qiita.com/items/049b9c4584769fe37896
#import <SimpleRemoteObject/SRSimpleRemoteObject.h>
@interface User : SRSimpleRemoteObject
@property(nonatomic,retain) NSString *name;
@property(nonatomic,retain) NSString *email;
@property(nonatomic) int age;
@end
@halsk
halsk / test.m
Created March 19, 2013 13:49
Kiwi で非同期テストを行う ref: http://qiita.com/items/38b66294e5c0bc46d214
SPEC_BEGIN(PropertyUtil)
describe(@"SimpleRemoteObject", ^{
context(@"read timeout", ^{
beforeAll(^{
[SRRemoteConfig defaultConfig].baseurl = @"http://localhost:2000/";
[SRRemoteConfig defaultConfig].timeout = 2;
});
it(@"should timeout with specified second", ^{
@halsk
halsk / IKGrayButton.h
Created March 28, 2013 09:23
UIButton をグラデーションにする ref: http://qiita.com/items/200cafdf1ee381453f1a
//
// IKGrayButton.h
// Ikuzo
//
// Created by Haruyuki Seki on 3/28/13.
//
#import <UIKit/UIKit.h>
@interface IKGrayButton : UIButton
@halsk
halsk / Singleton.m
Created April 5, 2013 05:40
Objective-C で継承可能な Singleton Class を作る ref: http://qiita.com/items/b4e51c33e7c9d29964ab
@implementation Singleton
static NSMutableDictionary *_instances;
+ (id) sharedInstance {
__block Singleton *obj;
@synchronized(self) {
if ([_instances objectForKey:NSStringFromClass(self)] == nil) {
obj = [[self alloc] initSharedInstance];
}
}
@halsk
halsk / default.rb
Created April 10, 2013 06:48
Vagrant up 時に、 Chef のバージョンをあげる ref: http://qiita.com/items/f22609937b9328141faf
package 'curl'
execute "Opscode Chef Client Installer for Ubuntu" do
command 'curl -L https://www.opscode.com/chef/install.sh | sudo bash'
not_if '/usr/bin/chef-client --version | /bin/grep "Chef: 11."'
end
@halsk
halsk / GRViewController.m
Created December 8, 2013 16:47
MapBox for iOS SDK を使って、OpenStreetMap を iPhone で表示する ref: http://qiita.com/hal_sk/items/e0b3ca53303976bc0235
//
// GRViewController.m
// MapBoxSample
//
// Created by Haruyuki Seki on 12/9/13.
// Copyright (c) 2013 Georepublic. All rights reserved.
//
#import "GRViewController.h"
#import <MapBox/MapBox.h>