Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am omuomugin on github.
  • I am omuomugin (https://keybase.io/omuomugin) on keybase.
  • I have a public key ASAZCSIG2Qm2EQGhNn2kbQCmBH4zb39tXhuQfnKu0puGpgo

To claim this, I am signing this object:

@omuomugin
omuomugin / android_find_support_library_useage.sh
Last active August 24, 2021 11:59
Find your Android app uses old support library or not
# see also https://developer.android.com/jetpack/androidx/migrate/artifact-mappings for all the artifacts which are mapped androidx
./gradlew :app:dependencies | grep -e android.arch.core:common -e android.arch.core:core -e android.arch.core:core-testing -e android.arch.core:runtime -e android.arch.lifecycle:common -e android.arch.lifecycle:common-java8 -e android.arch.lifecycle:compiler -e android.arch.lifecycle:extensions -e android.arch.lifecycle:livedata -e android.arch.lifecycle:livedata-core -e android.arch.lifecycle:reactivestreams -e android.arch.lifecycle:runtime -e android.arch.lifecycle:viewmodel -e android.arch.paging:common -e android.arch.paging:runtime -e android.arch.paging:rxjava2 -e android.arch.persistence.room:common -e android.arch.persistence.room:compiler -e android.arch.persistence.room:guava -e android.arch.persistence.room:migration -e android.arch.persistence.room:runtime -e android.arch.persistence.room:rxjava2 -e android.arch.persistence.room:testing -e android.arch.persistence:db
@omuomugin
omuomugin / prepare.md
Created February 15, 2021 00:05
ISUCONの準備用

mysqlのクエリ分析

set global slow_query_log = 1; # スロークエリのみ抽出
set global slow_query_log_file = '/path/to/mysql-slow.log';
set global long_query_time = 0; # 全てのクエリが出力される
set global log_queries_not_using_indexes = 1 # インデックスを利用してないクエリ (ログの出力先は、スロークエリと同じ)

long_query_time は、MySQL 5.1から1秒未満の値も設定できるようになったらしい

// これはだめ
fun foo(s: String?) {
print(s.toUpperCase()) // s は nullable なので s? or s!! しないとメソッド呼び出しできない
}
// これはok
fun foo(s: String?) {
requireNotNull(s) // not null であることが事前条件に書かれてるのでこれ以降のスコープでは nonnullとして スマートキャストされる
print(s.toUpperCase())
}
@omuomugin
omuomugin / union.swift
Last active January 23, 2020 13:38
Union
fun unionFun(val a: {Hoge | Fuga | Poyo}) {
// only Hoge, Fuga, Poyo can pass to this function
// still you should cast them using instanceof
// but you know that only Hoge, Fuga and Poyo should be target of instance of
// so you can cover all the types that you want to do something
}
@omuomugin
omuomugin / color.xml
Created February 18, 2019 09:01
android-values-xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">@color/indigo_500</color>
<color name="colorPrimaryDark">@color/indigo_700</color>
<color name="colorAccent">@color/pink_A200</color>
<color name="red_50">#FFEBEE</color>
<color name="red_100">#FFCDD2</color>
<color name="red_200">#EF9A9A</color>
<color name="red_300">#E57373</color>
@omuomugin
omuomugin / else-if-elif.py
Last active October 25, 2017 05:18
python why elif not else if
if condition:
# do something
else condition1:
if condition2:
# else-if 1
else condition3:
if condition4:
# else-if 2
if condition: