Skip to content

Instantly share code, notes, and snippets.

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

Slowhand Slowhand0309

🏠
Working from home
View GitHub Profile
@Slowhand0309
Slowhand0309 / UIButton+Rx.swift
Created August 17, 2019 09:03
[UIButton enable style binder] #iOS
import UIKit
import RxSwift
import RxCocoa
extension Reactive where Base: UIButton {
var enabledStyle: Binder<Bool> {
return Binder(self.base) { base, enabled in
base.isEnabled = enabled
base.backgroundColor = enabled ? UIColor.xxx : UIColor.xxx
base.setTitleColor(enabled ? UIColor.xxx : UIColor.xxx, for: .normal)
@Slowhand0309
Slowhand0309 / ArrayExtensions.swift
Created August 17, 2019 09:26
[Swift extensions] #iOS
public extension Array {
/// Secure access at index.
///
/// let array = [1, 2]
/// array[safe: 0] // Optional(1)
/// array[safe: 1] // Optional(2)
/// array[safe: 2] // nil
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
@Slowhand0309
Slowhand0309 / sample.kt
Last active October 10, 2020 16:55
[Callback to Coroutines] use suspendCoroutine. #Kotlin
/*
before
fun asyncLoad(callback: (result: String) -> Unit) {
load { result ->
callback(result)
}
}
*/
suspend fun asyncLoad(): String = suspendCoroutine { continuation ->
@Slowhand0309
Slowhand0309 / ViewController.swift
Created September 12, 2019 02:27
[ダブルタップをUITapGestureRecognizerで設定する] #iOS
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let gesture = UITapGestureRecognizer()
gesture.numberOfTapsRequired = 2 // ここで回数を設定する
gesture.rx.event.asSignal()
.emit(onNext: { [weak self] _ in
// do somthing...
@Slowhand0309
Slowhand0309 / APIRequest.swift
Last active October 10, 2020 16:56
[APIKitのBasic認証] #iOS
import APIKit
import Foundation
protocol APIRequest: Request {}
// https://github.com/ishkawa/APIKit/issues/121
// https://stackoverflow.com/questions/47983026/error-copying-matching-creds-swift-rest-api-call
extension APIRequest {
var baseURL: URL {
return URL(string: "https://api.xxx.com")!
@Slowhand0309
Slowhand0309 / MainActivity.kt
Created September 24, 2019 15:46
[Backボタン制御] #Android
// legacy
public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_BACK){
    // do something...
  } else {
    return super.onKeyDown(keyCode, event);
  }
}
@Slowhand0309
Slowhand0309 / ItemTableViewCell.swift
Last active October 10, 2020 16:58
UICollectionView in UITableView
import UIKit
class ItemTableViewCell: UITableViewCell {
@IBOutlet weak var collectionView: UICollectionView! {
didSet {
let nib = UINib(nibName: "ItemCollectionViewCell", bundle: nil)
collectionView.register(nib, forCellWithReuseIdentifier: "ItemCollectionViewCell")
}
}
@Slowhand0309
Slowhand0309 / branch.sh
Created May 14, 2020 03:07
[シェル内でgit branch存在チェック] #Script
if [ `git branch --list $branch_name` ]; then
echo "Branch name $branch_name already exists."
else
echo "Branch named $branch_name does not exist"
fi
@Slowhand0309
Slowhand0309 / doc.md
Last active September 28, 2020 02:04
[Riverpod FutureProvider] sample, links #Flutter
@Slowhand0309
Slowhand0309 / README.md
Last active September 28, 2020 04:26
[Alfred workflow - numbering test account] show numbering test account via input number #Alfred

Alfred

  1. Create new「Script Filter」
  2. Edit Script Filter
  3. Connect 「Copy to Clipboard」

image