Skip to content

Instantly share code, notes, and snippets.

View toshi0383's full-sized avatar
🏠
Working from home

Toshihiro Suzuki toshi0383

🏠
Working from home
  • Tokyo
View GitHub Profile
#!/bin/bash
perl -MURI::Escape -ne 'print uri_escape($_)'
//: 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
// 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))
@toshi0383
toshi0383 / ViewController.swift
Created June 23, 2017 00:17
[wip] trying to generate thumbnail using AVAssetImageGenerator but not working.
//
// ViewController.swift
// tvOS11HLSSample
//
// Created by 鈴木 俊裕 on 2017/06/06.
// Copyright © 2017 Toshihiro Suzuki. All rights reserved.
//
import UIKit
import AVKit
@toshi0383
toshi0383 / CodePiece.swift
Created June 13, 2017 01:47
なんぞこれ #CodePiece
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)
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")
@toshi0383
toshi0383 / -
Last active April 9, 2017 04:20
Generate random alphanumeric on bash on Mac
#!/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
//
// ViewController.swift
// HelloRx
//
// Created by Toshihiro suzuki on 2017/03/30.
// Copyright © 2017 toshi0383. All rights reserved.
//
import UIKit
import RxSwift
//
// ViewController.swift
// HelloRx
//
// Created by Toshihiro suzuki on 2017/03/30.
// Copyright © 2017 toshi0383. All rights reserved.
//
import UIKit
import RxSwift
{-|
- 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