This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
perl -MURI::Escape -ne 'print uri_escape($_)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import Foundation | |
let sleepMilliSecond = 1 | |
var initialSleepSec: UInt32? = 1000 | |
func _sleep() { | |
if let s = initialSleepSec { | |
initialSleepSec = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using RxSwift | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
rx.sentMessage(#selector(viewWillAppear(_:))) | |
.skip(1) | |
.subscribe(onNext: { | |
self.doSomething() | |
}) | |
.disposed(by: rx_disposeBag) | |
rx.sentMessage(#selector(viewDidLayoutSubviews)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// tvOS11HLSSample | |
// | |
// Created by 鈴木 俊裕 on 2017/06/06. | |
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | |
// | |
import UIKit | |
import AVKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player: AVPlayer? | |
func testDeallocatePlayerCrashes() { | |
player = MyPlayer() | |
// NSUnknownKeyException "...was sent to an object that is not KVC-compliant for the "bbbbbbb" property" | |
// player?.addObserver(self, forKeyPath: "bbbbbbb.aaaaaaaaa", options: [.new], context: nil) | |
// NSInternalInconsistencyException "...was deallocated while key value observers were still registered with it." | |
// player?.addObserver(self, forKeyPath: "", options: [.new], context: nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PathKit | |
var format = PropertyListSerialization.PropertyListFormat.xml | |
var raw = try! PropertyListSerialization.propertyList(from: data, format: &format) | |
(raw as AnyObject).setValue("3", forKeyPath: "archiveVersion") | |
// Using String Interporation is important and there is no other ways to write a valid pbxproj.. | |
try! Path("./updated.pbxproj").write("\(self.raw)\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SeeAlso: http://unix.stackexchange.com/questions/45404/why-cant-tr-read-from-dev-urandom-on-osx | |
LC_CTYPE=C tr -dc 'A-Z0-9' < /dev/urandom | head -c 32 | xargs echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// HelloRx | |
// | |
// Created by Toshihiro suzuki on 2017/03/30. | |
// Copyright © 2017 toshi0383. All rights reserved. | |
// | |
import UIKit | |
import RxSwift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// HelloRx | |
// | |
// Created by Toshihiro suzuki on 2017/03/30. | |
// Copyright © 2017 toshi0383. All rights reserved. | |
// | |
import UIKit | |
import RxSwift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| | |
- MP4 Header (UInt8 Array) Parsing | |
-} | |
import Data.Char (chr) | |
toInt32 :: [Int] -> Int | |
toInt32 (a:b:c:d:[]) = (a*256*256*256) + (b*256*256) + (c*256) + d | |
toInt32 x = error "Unexpected parameter" | |
toString32 :: [Int] -> String |