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 / Commands-Xcode.txt
Last active July 27, 2019 05:27
[Command lists related to Xcode] #Xcode #Command
# Show current path
xcode-select -print-path
# Switch xcode
xcode-select --switch /Applications/XcodeXX.app
# Search active xcodebuild path
xcrun --find xcodebuild
# Show simulator list
@Slowhand0309
Slowhand0309 / ServiceGenerator.kt
Created June 3, 2018 22:34
Retrofit+Rx+Moshi+Log sample.
object ServiceGenerator {
private lateinit var moshi: Moshi
private lateinit var retrofit: Retrofit
/**
* Initialize{@link Moshi}and{@link Retrofit}
*/
fun init(context: Context?) {
moshi = Moshi.Builder()
@Slowhand0309
Slowhand0309 / gradle.properties
Last active September 18, 2020 07:48
[Android Gradleビルド高速化設定] gradle.propertiesの設定 #Android #Gradle
#メモリ -Xmx: AndroidStudio起動時
org.gradle.jvmargs=-Xmx3072M -Xmx4096M -XX:MaxPermSize=2048M
#並列ビルドモードを有効
org.gradle.parallel=true
#必要な部分をビルド
org.gradle.configureondemand=true
#デーモンプロセスを使う
org.gradle.daemon=true
@Slowhand0309
Slowhand0309 / ContextExt.kt
Created July 27, 2019 04:50
[Kotlin Extension Context] #Kotlin #Android
/**
* Toastの簡易版
*
* @param text 表示文字列
* @param duration デフォルト: Toast.LENGTH_LONG
* @return {@link Toast}
*/
@Suppress("NOTHING_TO_INLINE")
inline fun Context.toast(text: CharSequence, duration: Int = Toast.LENGTH_LONG): Toast {
@Slowhand0309
Slowhand0309 / ActivityExt.kt
Last active September 18, 2020 07:49
[Kotlin Extension Activity] #Kotlin #Android
/**
* カスタムActivityの取得
* 取得できない場合はnull
*/
val Activity.rootApplication: RootApplication?
get() = (application as? RootApplication)
/**
* 現在フォーカスされているViewを元にKeyboardを非表示にする
*/
@Slowhand0309
Slowhand0309 / ViewController.swift
Last active July 27, 2019 05:37
[Keyboard Event With RxSwift] #iOS
import RxSwift
import RxCocoa
class ViewController: UIViewController {
@IBOutlet private weak var bottomConstraint: NSLayoutConstraint!
private let disposeBag = DisposeBag()
override func viewDidLoad() {
@Slowhand0309
Slowhand0309 / app-build-google-services.gradle
Created July 28, 2019 06:49
[Gradle Tips] #Android #Gradle
// buildTypesに応じたgoogle-services.jsonをapp/.へコピー
gradle.taskGraph.beforeTask { Task task ->
if (task.name ==~ /process.*GoogleServices/) {
applicationVariants.all { variant ->
if (task.name ==~ /(?i)process${variant.name}GoogleServices/) {
copy {
from "src/${variant.name}"
into "."
include "google-services.json"
}
@Slowhand0309
Slowhand0309 / FAB.swift
Created August 1, 2019 08:48
[Floating Action Button for iOS] #iOS
@IBOutlet weak var floatingActionButton: UIView! {
didSet {
floatingActionButton.layer.cornerRadius = floatingActionButton.width / 2.0
floatingActionButton.layer.shadowOpacity = 0.8
floatingActionButton.layer.shadowOffset = CGSize(width: 2.0, height: 2.0)
floatingActionButton.layer.shadowColor = UIColor.darkGray.cgColor
}
}
@Slowhand0309
Slowhand0309 / ViewController.swift
Last active August 16, 2019 02:29
[UIImagePickerController sample] #iOS
import UIKit
import Photos
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
private func selectFromLibrary() {
@Slowhand0309
Slowhand0309 / UIPaddingTextField.swift
Last active October 10, 2020 16:54
[Padding UITextField] Add padding to UITextField #iOS
import UIKit
@IBDesignable class UIPaddingTextField: UITextField {
// MARK: Properties
@IBInspectable var padding: CGPoint = CGPoint(x: 8.0, y: 0.0)
// MARK: Internal Methods
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: self.padding.x, dy: self.padding.y)