Skip to content

Instantly share code, notes, and snippets.

View matsuda's full-sized avatar

Kosuke Matsuda matsuda

  • Tokyo, Japan
View GitHub Profile
スクリーンショットの撮り方
https://support.google.com/nexus/answer/9075928?hl=ja
スクリーンショットをMacに転送する
https://www.android.com/filetransfer/
ショートカットを変更
* Control+Dでdelete
@matsuda
matsuda / Deallocation.swift
Last active September 15, 2020 09:37
Swizzling in Swift
// MARK: - check dealloc
private extension UIViewController {
// Add below to _swizzled_viewDidDisappear(_:)
func _checkDeallocation(afterDelay delay: TimeInterval = 1.5) {
if isMovingFromParent || rootParent.isBeingDismissed {
let disappearance = isMovingFromParent ? "removed from its parent" : "dismissed"
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
guard let self = self else { return }
let message = "\(String(describing: type(of: self))) not deallocated after being \(disappearance)"
@matsuda
matsuda / textView.swift
Created August 13, 2018 08:24
UITextViewの文字数制御
/// 文字数制御
/// refs: https://akaimo.hatenablog.jp/entry/2015/09/13/150241
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
self.previousText = textView.text
self.lastReplaceRange = range
self.lastReplacementString = text
return true
}
func textViewDidChange(_ textView: UITextView) {
@matsuda
matsuda / APIStubProtocol.swift
Last active March 22, 2018 06:43
XCTestにおけるスタブ(仮)
// テストターゲット=`SampleAppTest`
// ホストアプリ=`SampleApp`
import Foundation
import Alamofire
struct APIStub {
let statusCode: Int
let result: Result<Data>?
@matsuda
matsuda / install_nodebrew
Created October 4, 2017 06:22
Setup node.js
$ brew install nodebrew
==> Downloading https://github.com/hokaccha/nodebrew/archive/v0.9.7.tar.gz
==> Downloading from https://codeload.github.com/hokaccha/nodebrew/tar.gz/v0.9.7
######################################################################## 100.0%
==> Caveats
You need to manually run setup_dirs to create directories required by nodebrew:
/usr/local/opt/nodebrew/bin/nodebrew setup_dirs
Add path:
export PATH=$HOME/.nodebrew/current/bin:$PATH
@matsuda
matsuda / lldb_tips.txt
Last active August 23, 2021 00:58
LLDB tips
Simulator起動時に `Lost connection to the debugger` と表示されてディタッチされてしまう&Simulator上でアプリが起動しない
# https://developer.apple.com/forums/thread/681037
```
settings set plugin.process.gdb-remote.packet-timeout 300
```
@matsuda
matsuda / update_bundle_version.rb
Created September 1, 2017 02:12
CFBundleVersionを更新するためのFastlane action
module Fastlane
module Actions
module SharedValues
UPDATE_BUNDLE_VERSION = :UPDATE_BUNDLE_VERSION
end
class UpdateBundleVersionAction < Action
def self.run(params)
begin
path = File.expand_path(params[:path])
@matsuda
matsuda / mac_initial.txt
Last active November 11, 2020 01:47
Macを初期化する
初期設定
## Safari
* deleteキーで戻るように
```
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool YES
```
@matsuda
matsuda / new_gist_file
Created April 4, 2017 00:13
universal frameworkの作成スクリプト
INFO_PLIST="Info.plist"
FRAMEWORK_NAME=${PROJECT_NAME}
FRAMEWORK_VERSION_NUMBER=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ${SRCROOT}/${PROJECT_NAME}/${INFO_PLIST})
FRAMEWORK_VERSION=A
FRAMEWORK_BUILD_PATH="${SRCROOT}/build/${CONFIGURATION}-framework"
FRAMEWORK_DIR="${FRAMEWORK_BUILD_PATH}/${FRAMEWORK_NAME}.framework"
FRAMEWORK_PACKAGE="${FRAMEWORK_NAME}-${FRAMEWORK_VERSION_NUMBER}"
FRAMEWORK_PACKAGE_NAME="${FRAMEWORK_PACKAGE}.zip"
[ -d "${FRAMEWORK_BUILD_PATH}" ] && rm -rf "${FRAMEWORK_BUILD_PATH}"
@matsuda
matsuda / AppDelegate+APNs.swift
Created March 8, 2017 02:30
Implement APNs handling in Swift 3
import UserNotifications
import MuddlerKit
// MARK: - APNs utilities
extension AppDelegate {
func applicationWillRegisterForRemoteNotifications_compatible(_ application: UIApplication) {
if #available(iOS 10.0, *) {
applicationWillRegisterForRemoteNotifications(application)
} else {