Skip to content

Instantly share code, notes, and snippets.

View BeokBeok's full-sized avatar
🖐️
Hi

Hyeonseok Kang BeokBeok

🖐️
Hi
View GitHub Profile
@BeokBeok
BeokBeok / DebugingAnddroidIntents.kt
Created October 13, 2022 00:40
Debugging Android Intents
fun Intent?.toDebugString(): String {
val intent = this ?: return ""
return StringBuilder().apply {
appendLine("--- Intent ---")
appendLine("type: ${intent.type}")
appendLine("package: ${intent.`package`}")
appendLine("scheme: ${intent.scheme}")
appendLine("component: ${intent.component}")
appendLine("flags: ${intent.flags}")
appendLine("categories: ${intent.categories}")
@BeokBeok
BeokBeok / pre-commit
Created November 24, 2020 13:59
.git/hooks 폴더에 넣으면, commit 시 ktlint 가 동작한다
#!/bin/sh
set -e
######## KTLINT-GRADLE HOOK START ########
CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.kts|\.kt/ { print $2}')"
if [ -z "$CHANGED_FILES" ]; then
echo "No Kotlin staged files."
exit 0
fi;
@BeokBeok
BeokBeok / settings.gradle.kts
Created August 24, 2020 04:38
Dynamic multi module
/**
* Dynamically discover and add modules in our project
* */
val moduleBuildFileName = "build.gradle.kts"
// A pattern to match the prefix of our modules
val eligibleModuleNamePattern = "a_pattern_to_match_our_module_names".toRegex() // (e.g.: (app|android-|kotlin-).*)
// Filter directories that indicate modules
val moduleFilter: FileFilter = FileFilter { pathname: File ->
@BeokBeok
BeokBeok / makeStashToPatch.txt
Last active October 30, 2023 02:35
[Git] Stash 를 패치파일로 만들기
git stash list // patch 파일 만들 stash 확인
git stash show -p stash@{0} > filename.patch
🌞 Morning 84 commits █████▏░░░░░░░░░░░░░░░ 24.5%
🌆 Daytime 193 commits ███████████▊░░░░░░░░░ 56.3%
🌃 Evening 6 commits ▎░░░░░░░░░░░░░░░░░░░░ 1.7%
🌙 Night 60 commits ███▋░░░░░░░░░░░░░░░░░ 17.5%
@BeokBeok
BeokBeok / startActivityUsingReified.kt
Last active May 5, 2020 14:42
제네릭을 활용한 startActivity 함수 간편하게 사용하기
inline fun <reified T : Activity> Context.startActivity() {
val intent = Intent(this, T::class.java)
startActivity(intent)
}
startActivity<MainActivity>()
@BeokBeok
BeokBeok / ShowKeyboard.kt
Last active May 5, 2020 14:43
키패드를 보여주는 extension 함수
fun View.focusAndShowKeyboard() {
/**
* This is to be called when the window already has focus.
*/
fun View.showTheKeyboardNow() {
if (isFocused) {
post {
// We still post the call, just in case we are being notified of the windows focus
// but InputMethodManager didn't get properly setup yet.
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager