Skip to content

Instantly share code, notes, and snippets.

View inamiy's full-sized avatar

Yasuhiro Inami inamiy

View GitHub Profile
@inamiy
inamiy / benchmark.swift
Created January 21, 2015 01:45
SwiftTask & ReactKit benchmark test. https://github.com/ReactKit/SwiftTask/pull/22
for i in 0..<5 {
let startTime: CFAbsoluteTime = CFAbsoluteTimeGetCurrent();
for _ in 0..<100 {
let task = Task<Float, String, NSError> { p, f, r, c in }
//let signal = Signal<Int>.never()
}
let elapsedTime: CFAbsoluteTime = CFAbsoluteTimeGetCurrent() - startTime;
@inamiy
inamiy / mutableArrayValueForKey-weak.m
Created March 23, 2015 01:17
mutableArrayValueForKey + weak is not really weak...
- (void)testExample {
MyObject* obj = [[MyObject alloc] init];
obj.array = @[];
NSMutableArray* array = [obj mutableArrayValueForKey:@"array"];
// NSMutableArray* array = @[].mutableCopy; // using this will pass test
__weak NSMutableArray* weakArray = array;
@inamiy
inamiy / gist:b75cba8916716c81dd7d
Created December 5, 2015 15:51
swift-package-manager + SwiftState 4.0.0-RC build failure in Ubuntu 14.04
root@7093981bc8fc:~/PackageTest# swift build
Compiling Swift Module 'SwiftState' (14 sources)
swift: /home/buildslave/jenkins/workspace/oss-swift-linux-packages-ubuntu_14_04-one-off-build/swift/lib/SILPasses/IPO/CapturePromotion.cpp:831: swift::SILFunction *constructClonedFunction(swift::PartialApplyInst *, swift::FunctionRefInst *, IndicesSet &): Assertion `!genericSig && "Function type has Unexpected generic signature!"' failed.
0 swift 0x0000000002f15268 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x0000000002f13a36 llvm::sys::RunSignalHandlers() + 54
2 swift 0x0000000002f15d9a
3 libpthread.so.0 0x00007f1e39e14340
4 libc.so.6 0x00007f1e3903ccc9 gsignal + 57
5 libc.so.6 0x00007f1e390400d8 abort + 328
6 libc.so.6 0x00007f1e39035b86
@inamiy
inamiy / String+Horspool.swift
Last active April 1, 2016 15:45
Boyer-Moore-Horspool Algorithm in Swift
extension String
{
// https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm
// http://www.cin.br/~paguso/courses/if767/bib/Horspool_1980.pdf
public func indexOf_horspool(pattern: String) -> String.Index?
{
let patternLength = pattern.characters.count
assert(patternLength > 0)
assert(patternLength <= self.characters.count)
@inamiy
inamiy / deckset-hyperlink-test.md
Created August 7, 2016 02:13
Deckset v1.6.2 hyperlink bug
@inamiy
inamiy / iOSDC-Japan-2016.md
Last active November 5, 2018 01:04
Reactive State Machine | iOSDC Japan 2016

2016/08/20 13:00 Track A Speaker: 稲見 泰宏 (@inamiy)

概要

ここ1, 2年のSwiftの登場とFunctional Reactive Programming (FRP)の普及によって、iOSアプリ開発の現場では劇的なパラダイムシフトが起きています。しかし一方で、副作用を伴うアプリの状態管理に苦労する点が未だ多くあり、バグの温床となっています。このプレゼンでは、状態管理の基礎理論であるオートマトン(ステートマシン)を基に、Reduxなどのフレームワークとの対比も交えながら、FRPでの効率的な設計手法について探ります。

スライド (日本語)

@inamiy
inamiy / DiscardableResultBug.swift
Last active September 18, 2016 18:16
@discardableResult bug in Swift 3 (Xcode 8) when Optional chaining + Optional return value https://bugs.swift.org/browse/SR-2687
// # Bug description
// `@discardableResult` won't work when:
// 1. optional chaining
// 2. function returns Optional + non-Void value
//
// ## See also
// - https://bugs.swift.org/browse/SR-1052
// - https://bugs.swift.org/browse/SR-1681
// - https://bugs.swift.org/browse/SR-1929
@inamiy
inamiy / SignalProducerSpec.diff
Created November 3, 2016 05:09
ReactiveSwift 1.0.0-alpha.3 (RAC5) Bug: Inner signal not interrupted on outer signal disposal
diff --git Tests/ReactiveSwiftTests/SignalProducerSpec.swift Tests/ReactiveSwiftTests/SignalProducerSpec.swift
index 21362e7..a363327 100644
--- Tests/ReactiveSwiftTests/SignalProducerSpec.swift
+++ Tests/ReactiveSwiftTests/SignalProducerSpec.swift
@@ -1413,13 +1413,14 @@ class SignalProducerSpec: QuickSpec {
}
}
- describe("disposal") {
+ fdescribe("disposal") {
@inamiy
inamiy / SwiftElmFrameworkList.md
Last active March 11, 2024 10:20
React & Elm inspired frameworks in Swift
@inamiy
inamiy / void-func-type-inference-swift4.swift
Last active June 11, 2017 16:20
'() -> ()' type inference doesn't work in Swift 4
func test<T>(_ f: (T) -> Void) {}
let intF: (Int) -> Void = { _ in }
let voidF: () -> Void = { }
test(intF) // works
//test(voidF) // error: cannot convert value of type '() -> Void' to expected argument type '(_) -> Void'
//: # Workaround for zero-argument func to be passed into `test`