This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Date.getPassedTime(): String { | |
val millis = Date().time - this.time | |
val sec = millis / 1000 | |
val min = millis / (60 * 1000) | |
val hour = millis / (60 * 60 * 1000) | |
val day = millis / (24 * 60 * 60 * 1000) | |
val week = millis / (7 * 24 * 60 * 60 * 1000) | |
val month = (millis / (30.5 * 24 * 60 * 60 * 1000)).toInt() | |
//val year = day / 365 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm -Rf ~/Library/Preferences/AndroidStudio | |
rm -Rf ~/Library/Preferences/com.google.android | |
rm -Rf ~/Library/Preferences/com.android | |
rm -Rf ~/Library/Application/Support/AndroidStudio | |
rm -Rf ~/Library/Logs/AndroidStudio | |
rm -Rf ~/Library/Caches/AndroidStudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter("textResId") | |
fun TextView.setStringResId(@StringRes value: Int) { | |
if (value == 0) return | |
setText(value) | |
} | |
@BindingAdapter("textColorResId") | |
fun TextView.setTextColorResId(@ColorRes value: Int) { | |
if (value == 0) return | |
setTextColor(ContextCompat.getColor(context, value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified T : AppCompatActivity> Context.startActivity( | |
vararg extras: Pair<String, Any?>, | |
intentAction: Intent.() -> Unit = {} | |
) { | |
startActivity(Intent(this, T::class.java).apply { | |
putExtras(bundleOf(*extras)) | |
intentAction() | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified T : Fragment> FragmentManager.replaceFragment( | |
@IdRes containerViewId: Int, | |
vararg param: Pair<String, Any?>, | |
tag: String = T::class.java.simpleName | |
): T? { | |
return findFragment() ?: T::class.java.newInstance().also { newFragment -> | |
newFragment.arguments = bundleOf(*param) | |
beginTransaction() | |
.replace(containerViewId, newFragment, tag) | |
.commitAllowStateLoss() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🌞 Morning 73 commits ▉░░░░░░░░░░░░░░░░░░░░ 4.5% | |
🌆 Daytime 644 commits ████████▎░░░░░░░░░░░░ 39.8% | |
🌃 Evening 691 commits ████████▉░░░░░░░░░░░░ 42.7% | |
🌙 Night 209 commits ██▋░░░░░░░░░░░░░░░░░░ 12.9% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This script should be run via curl: | |
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# or via wget: | |
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# or via fetch: | |
# sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# | |
# As an alternative, you can first download the install script and run it afterwards: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Suppress("UNCHECKED_CAST") | |
@BindingAdapter("itemsWithListAdapter") | |
fun <T, VH : RecyclerView.ViewHolder> setItemsWithListAdapter( | |
recyclerView: RecyclerView, | |
items: List<T>? | |
) { | |
(recyclerView.adapter as? ListAdapter<T, VH>)?.let { adapter -> | |
val newList = if (items == null || items.isEmpty()) null else ArrayList(items) | |
adapter.submitList(newList) | |
if (newList == null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -u | |
abort() { | |
printf "%s\n" "$@" | |
exit 1 | |
} | |
if [ -z "${BASH_VERSION:-}" ]; then | |
abort "Bash is required to interpret this script." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -u | |
abort() { | |
printf "%s\n" "$@" | |
exit 1 | |
} | |
if [ -z "${BASH_VERSION:-}" ]; then | |
abort "Bash is required to interpret this script." |
OlderNewer