Skip to content

Instantly share code, notes, and snippets.

@ikesyo
ikesyo / DescriptionBuilder.podspec
Created July 30, 2012 07:39
DescriptionBuilder.podspec
Pod::Spec.new do |s|
s.name = 'DescriptionBuilder'
s.version = '0.1'
s.platform = :ios
s.summary = 'DescriptionBuilder is helper class to make easier implementing NSObject description method.
Or dump all instance variables of any object. '
s.homepage = 'https://github.com/kishikawakatsumi/DescriptionBuilder'
s.author = { 'KISHIKAWA Katsumi' => 'kishikawakatsumi@gmail.com' }
s.source = { :git => 'https://github.com/kishikawakatsumi/DescriptionBuilder.git', :branch => 'master' }
@ikesyo
ikesyo / main.js
Last active December 15, 2015 09:59
Parse Cloud Code: Make role
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.define("hello", function(request, response) {
var acl = new Parse.ACL();
var role = new Parse.Role("testRole", acl);
role.save();
response.success("Hello world!");
});
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "2.0-RC1"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Justin Spahr-Summers" => "jspahrsummers@github.com", "Josh Abernathy" => "josh@github.com" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :tag => "v#{s.version}" }
s.license = { :type => 'MIT', :file => 'LICENSE.md' }
s.description = "ReactiveCocoa (RAC) is an Objective-C framework for Functional Reactive Programming. It provides APIs for composing and transforming streams of values."
@ikesyo
ikesyo / Mantle.podspec
Created October 3, 2013 15:18
Renaming version of Mantle.podspec
Pod::Spec.new do |s|
s.name = "Mantle"
s.version = "1.3"
s.summary = "Model framework for Cocoa and Cocoa Touch."
s.homepage = "https://github.com/github/Mantle"
s.license = 'MIT'
s.author = { "GitHub" => "support@github.com" }
s.source = { :git => "https://github.com/github/Mantle.git", :tag => "1.3" }
@ikesyo
ikesyo / ReactiveCocoa.podspec
Created October 3, 2013 15:55
non-renaming version of ReactiveCocoa.podspec
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "2.1"
s.summary = "A framework for composing and transforming streams of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "josh@github.com" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :tag => "v#{s.version}" }
s.license = 'MIT'
s.description = "ReactiveCocoa (RAC) is an Objective-C framework for Functional Reactive Programming. It provides APIs for composing and transforming streams of values."
@ikesyo
ikesyo / gist:2e192261ec265239cd86
Last active August 29, 2015 14:00
RAC: map: and flattenMap:
RACSignal *numberSignal = @[ @1, @2, @3 ].rac_sequence.signal;
// signal of @2, @4, @6
[numberSignal map:^ id (NSNumber number) {
return @(number.integerValue * 2);
}];
// signal of something like
// @{ @"id": @1, @"name": @"Name 1" },
// @{ @"id": @2, @"name": @"Name 2" },
@ikesyo
ikesyo / gist:9a2a6dd683f0382b804d
Created June 5, 2014 13:20
Extensions version of http://maxs.io/typeclass-encoding-in-swift/ instead of explicit type class instance
protocol Num {
typealias N
class func zero() -> N
func succ() -> N
func add(other: N) -> N
func multiply(other: N) -> N
}
extension Int8: Num {
typealias N = Int8
@ikesyo
ikesyo / gist:0c556e5fa116663583e2
Last active May 20, 2017 06:52
How to use Associated Object in Swift
import Foundation
class ABC {}
let abc = ABC()
// in-out expression can be used for CConstVoidPointer parameter.
var key: Void?
objc_setAssociatedObject(abc, &key, "value", UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
@ikesyo
ikesyo / gist:ddf44b1f15d6f5bb33ce
Last active August 29, 2015 14:20
Optional.map/flatMap
// https://twitter.com/akisutesama/status/596501848313372672
// https://twitter.com/_ishkawa/status/596504826655088640
var god: String? = "god"
func makeItFuck(x: String) -> String {
return x + " fuck"
}
var godfuck1 = god.map { $0 + " fuck" } // String?
@ikesyo
ikesyo / gist:afb5aa47e3e605c41350
Last active August 29, 2015 14:20
Create curried initializer function
func curry<A, B, C, Result>(f: (A, B, C) -> Result) -> A -> B -> C -> Result {
return { a in { b in { c in f(a, b, c) } } }
}
struct Hoge {
let a: String
let b: Int
let c: Bool?
}