Skip to content

Instantly share code, notes, and snippets.

View ochim's full-sized avatar

munehiro ochi ochim

View GitHub Profile
@ochim
ochim / Android-Record-Video.md
Created February 17, 2021 09:50
Android - Record Video カメラアプリを呼んでビデオを撮る

カメラアプリを呼んでビデオを撮る

  • AndroidManifest.xml
<manifest ... >
    <uses-feature android:name="android.hardware.camera"
                  android:required="true" />
    ...
</manifest>
@ochim
ochim / print.swift
Last active November 13, 2020 10:30
swiftのprint()をカスタマイズ
func print(_ items: Any..., separator: String = " ", terminator: String = "\n") {
#if DEBUG
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
// 文頭に日時を付与する
Swift.print(formatter.string(from: Date()), terminator: " ")
Swift.print(items, separator: separator, terminator: terminator)
#else
// なにもしない
#endif
@ochim
ochim / inheritance.kt
Created October 15, 2020 08:39
Classes and inheritance in Kotlin
/**
* Program that implements classes for different kinds of dwellings.
* Shows how to:
* Create class hierarchy, variables and functions with inheritance,
* abstract class, overriding, and private vs. public variables.
*/
import kotlin.math.PI
import kotlin.math.sqrt
fun main() {
@ochim
ochim / Task-multiDexList-FAILED
Created August 7, 2020 07:12
[Android]Task :app:multiDexListDevelopDebug FAILED
Android Studio 4.0.1にて
classpath 'com.android.tools.build:gradle:3.5.3' →
classpath 'com.android.tools.build:gradle:4.0.1'
にupdateした。
Build APKすると
> Task :app:multiDexListDevelopDebug FAILED
AGPBI: {"kind":"error","text":"Type androidx.transition.R is defined multiple times: /Users/nijimac088/goo-memo-android/app/build/intermediates/transforms/RealmTransformer/develop/debug/1.jar:androidx/transition/R.class, /Users/nijimac088/goo-memo-android/app/build/intermediates/transforms/RealmTransformer/develop/debug/0/androidx/transition/R.class","sources":[{"file":"/Users/nijimac088/goo-memo-android/app/build/intermediates/transforms/RealmTransformer/develop/debug/1.jar"}],"tool":"D8"}
RealmTransformerとあるからRealm周りを疑ったが、結果違った。
@ochim
ochim / dice.kt
Last active July 31, 2020 14:44
dice.kt
/*
Android Basics: Add a button to an app
1.Classes and object instances in Kotlin
*/
fun main() {
val myFirstDice = Dice(6)
println("Your ${myFirstDice.numSides} sided dice rolled ${myFirstDice.roll()}!")
val mySecondDice = Dice(20)
println("Your ${mySecondDice.numSides} sided dice rolled ${mySecondDice.roll()}!")
@ochim
ochim / birthdayCake.kt
Created July 27, 2020 11:23
birthdayCake.kt
// Android Basics: Introduction to Kotlin
fun main() {
val age = 24
val layers = 5
printCakeCandles(age)
printCakeTop(age)
printCakeBottom(age, layers)
}
@ochim
ochim / ios-simple-alert.md
Last active June 19, 2020 10:59
[ios]簡易なアラートダイアログを表示する
extension UIViewController {
    // 簡易なアラートダイアログを表示する
    func showSimpleAlert(title: String?, message: String?, action: ((UIAlertAction) -> Void)? = nil) {
        let alertController = UIAlertController(title: title,
                                                message: message,
                                                preferredStyle: .alert)
        let defaultAction = UIAlertAction(title: "OK",
                                          style: .default,
 handler: action)
@ochim
ochim / ios-cornerRadius.md
Last active June 2, 2020 03:48
[ios]UIViewの角を一部だけ丸くする
  • example
class LineView: UIView {

    override func draw(_ rect: CGRect) {
        layer.cornerRadius = 5
        layer.masksToBounds = true
        // 左側だけ丸くする
        layer.maskedCorners = [.layerMinXMinYCorner, .layerMinXMaxYCorner]
 super.draw(rect)
#Device(UDID)追加時
developer portalで
1.Devices追加
2.Profiles編集
3.Profiles ダウンロード
4.BitriseのCode Signningに新しいProfilesをアップロード
5.XcodeのProject設定確認
・Manual signningにしてcommit
@ochim
ochim / PaddingLabel.md
Last active May 8, 2020 08:53
[iOS]PaddingLabel
  • Xcode: 11.3.1
  • Swift: 5
class PaddingLabel: UILabel {
    // paddingの値
    let padding = UIEdgeInsets(top: 4, left: 16, bottom: 4, right: 16)

    override func drawText(in rect: CGRect) {
        let newRect = rect.inset(by: padding)