Skip to content

Instantly share code, notes, and snippets.

View jumbo-in-Jap's full-sized avatar

Ken Jumbo Haneda jumbo-in-Jap

View GitHub Profile
@jumbo-in-Jap
jumbo-in-Jap / speaker_override.swift
Created August 7, 2017 05:52
スピーカーの出力先を変える
// 出力先判定
static func IsHeadSetConnected() -> Bool{
let route = AVAudioSession.sharedInstance().currentRoute;
for desc in route.outputs
{
let portType = desc.portType;
if (portType == AVAudioSessionPortHeadphones)
{
return true;
}
// MARK: Authorized Property
var audioAuthorized = Variable<Bool>(false)
var videoAuthorized = Variable<Bool>(false)
-----
func bind(){
// どちらも許可されたら通信開始
Observable
.combineLatest(audioAuthorized.asObservable(), videoAuthorized.asObservable())
@jumbo-in-Jap
jumbo-in-Jap / times.swift
Created August 7, 2017 05:33
再接続処理のタイマー実装
let timer: Observable<Int> = Observable.interval(30.0, scheduler: MainScheduler.instance)
timer
.subscribe(onNext: { (notice) in
// 再接続処理
if self.viewModel.chatStatus.value == LessonViewModel.ChatStatus.DisConnectedWithTutor{
self.viewModel.recallTo()
}
}).addDisposableTo(disposeBag)
@jumbo-in-Jap
jumbo-in-Jap / gist:29abf2cefcf0848700915f7b6ace37f8
Last active August 7, 2017 05:25
RxLessonViewModel.swift
class LessonViewModel {
// MARK: SkyWay Connection Property
fileprivate var _peer:SKWPeer?
fileprivate var _mediaConnection:SKWMediaConnection?
fileprivate var _dataConnection:SKWDataConnection?
var remoteStream = Variable<SKWMediaStream?>(nil)
var localStream = Variable<SKWMediaStream?>(nil)
var chatMessages = Variable<[JSQMessage]>([])
let disposeBag = DisposeBag()
environment 'production'
port 9000
daemonize true
state_path 'tmp/pids/puma.state'
pidfile 'tmp/pids/puma.pid'
threads 0,16
workers 2
@jumbo-in-Jap
jumbo-in-Jap / TwicastLoginWebViewController.swift
Last active January 28, 2017 05:24
「ハッカソン当日より前の開発環境の構築やプロトタイプの作成など、事前準備を可とします」とのことなので、ツイキャスハッカソン用にOauth2のログインでAccessTokenを取得するとこをSwift3で書きました
//
// TwicastLoginWebViewController.swift
// TwicasHackathonTest
//
// Created by HanedaKentarou on 2017/01/16.
// Copyright © 2017年 com.adriablue. All rights reserved.
//
/* How to use.
@jumbo-in-Jap
jumbo-in-Jap / SlackFeedback.kt
Last active January 6, 2017 02:07
post slack feedback image and, comment fragment
package jp.co.rarejob.views.fragments.common
import android.graphics.Bitmap
import android.os.Bundle
import android.support.v4.app.Fragment
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.LayoutInflater
import android.view.View
//
// AnyAudioPlayer.swift
// audioSample
//
// Created by HanedaKentarou on 2016/04/12.
// Copyright © 2016年 Kaumo. All rights reserved.
//
import UIKit
import AVFoundation
for subview in testButton.subviews where subview is UIButton {
subview.removeFromSuperview()
}