This file contains hidden or 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 -i | |
### THIS IS A MODIFIED VERSION OF BEN GREEN'S SCRIPT LOCATED HERE: | |
### https://gist.githubusercontent.com/numtel/96dd51106f0e7e25c50dcf4a4f119499/raw/4d2cf0d17b26239b10050a0b35e6ed5646273a38/install_rai_node.sh | |
DATA_PATH="/home/$USER" # Change if desired, directory must exist! | |
DATA_DIRECTORY="RaiBlocks" # Determined by rai_node | |
sudo apt update | |
sudo apt upgrade |
This file contains hidden or 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
#!/usr/bin/env sh | |
compress() { | |
while [ "$1" ]; do | |
if [ -d "$1" ]; then | |
compress "$1"/* | |
else | |
zopflipng -m -y $1 $1 | |
fi | |
shift |
This file contains hidden or 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 <T> unsafeLazy(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer) |
This file contains hidden or 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
@JvmOverloads @Dimension(unit = Dimension.PX) fun Number.dpToPx( | |
metrics: DisplayMetrics = Resources.getSystem().displayMetrics | |
): Float { | |
return toFloat() * metrics.density | |
} | |
@JvmOverloads @Dimension(unit = Dimension.DP) fun Number.pxToDp( | |
metrics: DisplayMetrics = Resources.getSystem().displayMetrics | |
): Float { | |
return toFloat() / metrics.density |
This file contains hidden or 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
@ColorInt fun Context.getColorCompat(@ColorRes colorRes: Int): Int { | |
return ContextCompat.getColor(this, colorRes) | |
} | |
fun Context.getDrawableCompat(@DrawableRes drawableRes: Int): Drawable { | |
return AppCompatResources.getDrawable(this, drawableRes)!! | |
} |
This file contains hidden or 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 Context.toActivity(): Activity? { | |
var context = this | |
while (context is ContextWrapper) { | |
if (context is Activity) { | |
return context | |
} | |
context = context.baseContext | |
} | |
return null | |
} |
This file contains hidden or 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
@CheckResult fun Drawable.tint(@ColorInt color: Int): Drawable { | |
val tintedDrawable = DrawableCompat.wrap(this).mutate() | |
DrawableCompat.setTint(tintedDrawable, color) | |
return tintedDrawable | |
} | |
@CheckResult fun Drawable.tint(context: Context, @ColorRes color: Int): Drawable { | |
return tint(context.getColorCompat(color)) | |
} |
This file contains hidden or 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 Context.openWebPage(url: String): Boolean { | |
// Format the URI properly. | |
val uri = url.toWebUri() | |
// Try using Chrome Custom Tabs. | |
try { | |
val intent = CustomTabsIntent.Builder() | |
.setToolbarColor(getColorCompat(R.color.primary)) | |
.setShowTitle(true) | |
.build() |
This file contains hidden or 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") | |
@JvmOverloads fun <V : View> ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): V { | |
return LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) as V | |
} |
This file contains hidden or 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 <T> unsafeLazy(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer) | |
@JvmOverloads @Dimension(unit = Dimension.PX) fun Number.dpToPx( | |
metrics: DisplayMetrics = Resources.getSystem().displayMetrics | |
): Float { | |
return toFloat() * metrics.density | |
} | |
@JvmOverloads @Dimension(unit = Dimension.DP) fun Number.pxToDp( | |
metrics: DisplayMetrics = Resources.getSystem().displayMetrics |
OlderNewer