Skip to content

Instantly share code, notes, and snippets.

@takaishota
takaishota / gist:4f881fe019940281c8f417554f686457
Last active September 20, 2020 04:23
Failed to start launchd_simエラーでSimulatorが起動できなくなった時の対処方法

Xcode12にアップデートした後にiOS Simulatorが下記のエラーが出て起動できなくなった。

Failed to start launchd_sim: could not bind to session, launchd_sim may have crashed or quit responding Domain: com.apple.SimLaunchHostService.RequestError

↓これを参考に

https://stackoverflow.com/questions/40238266/launchd-sim-crashing-could-not-create-temporary-state-directory

/Volumes/.../private/tmpディレクトリの権限を変更したら、起動できるようになった。

@takaishota
takaishota / device-suffix.md
Last active June 18, 2020 11:19
実機でSuffix付きのアプリをビルドする(React Native)
npx react-native run-android --appIdSuffix staging
@takaishota
takaishota / git_log_diff_filter_d.md
Last active March 18, 2019 15:47
過去に削除したファイルの検索
# 過去に削除したファイルの検索
git log --diff-filter=D --summary
@takaishota
takaishota / firstResponder.swift
Created February 22, 2019 18:14
current firstResponder
// https://stackoverflow.com/a/1823360
extension UIView {
var firstResponder: UIView? {
guard !isFirstResponder else { return self }
for subview in subviews {
if let firstResponder = subview.firstResponder {
return firstResponder
}
}
@takaishota
takaishota / IntrinsicTableView.swift
Created February 8, 2019 03:06
Fix UITableView height inside UIStackView after rotated
import UIKit
class IntrinsicTableView: UITableView {
override var contentSize:CGSize {
didSet {
self.invalidateIntrinsicContentSize()
}
}
override var intrinsicContentSize: CGSize {
@takaishota
takaishota / findingRealmFile.md
Last active June 7, 2018 16:10
Finding a Realm File for iOS

pause the simulator and enter the following into the LLDB console

po Realm.Configuration.defaultConfiguration.fileURL
@takaishota
takaishota / disable_section_header.swift
Last active August 13, 2018 03:43
UITableViewのセクションヘッダーがスクロール時に上で止まらないようにする
// disable sticky section header
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y <= tableView.sectionHeaderHeight && scrollView.contentOffset.y >= 0 {
scrollView.contentInset = UIEdgeInsets(top: -scrollView.contentOffset.y, left: 0, bottom: 0, right: 0)
} else if scrollView.contentOffset.y >= tableView.sectionHeaderHeight {
scrollView.contentInset = UIEdgeInsets(top: -tableView.sectionHeaderHeight, left: 0, bottom: 0, right: 0)
}
}
@takaishota
takaishota / changelog_based_on_merge_commits.sh
Created April 2, 2018 02:11
直近のタグからHEADまでのマージコミットのbody(PRのタイトル)の一覧を表示するコマンド
git log $(git describe --abbrev=0 --tags).. --merges --pretty=format:"%b" | sed -e "s/^/* [ ] /"
@takaishota
takaishota / gist:836f3f383deaa2f670a3006ab76a37f8
Created March 24, 2018 05:31
Androidのエミュレータを起動するコマンド
emulator -list-avds
emulator -avd avd_name
@takaishota
takaishota / getStrongStrings.swift
Created October 30, 2017 06:45
Strinfからstrongタグで囲まれた要素を抽出する
private func getStrongStrings(_ text: String) -> [String]? {
let pattern = "(?<=<strong>)(.[^>]*)(?=</strong>)"
guard let regex = try? NSRegularExpression(pattern: pattern) else {
Log.fatal(message: "regular expression pattern is invalid")
return nil
}
let matches = regex.matches(in: text, range: NSRange(text.startIndex..., in: text))
let strings = matches.map {
String(text[Range($0.range, in: text)!])