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
// ViewState | |
sealed class ViewEffect { | |
data class ShowToast(val message: String) : ViewEffect() | |
} | |
// Set up LiveData | |
private val _viewEffectPublisher: MutableLiveData<Event<ViewEffect>>() | |
val viewEffectPublisher = LiveData<Event<ViewEffect>> | |
get() = _viewEffectPublisher |
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
class Event<out T>(private val content: T) { | |
var hasBeenHandled = false | |
private set | |
fun getContentIfNotHandled(): T? { | |
if (hasBeenHandled) { | |
return null | |
} else { | |
hasBeenHandled = true |
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
public class SingleLiveData<T> : MutableLiveData<T> { | |
private val pending = AtomicBoolean(false) | |
@MainThread | |
override fun observe(owner: LifecycleOwner, observer: Observer<T>) { | |
super.observe(owner, object : Observer<T>() { | |
override fun onChanged(t: T?) { | |
// compareAndSet(expect, update) | |
// here if `true` then set to false |
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 Project.getLocalOrDefaultProperties(): Map<String, Any?> { | |
return getEnvOrDefaultProperties("local.properties") | |
} | |
private fun Project.getEnvOrDefaultProperties(path: String): Map<String, Any?> { | |
return rootProject.file(path) | |
.takeIf { it.canRead() } | |
?.let { readProperties(it).toMap() as Map<String, Any?> } | |
?: properties.toMap() | |
} |
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
// To view the default settings, hold "alt" while clicking on the "Settings" button. | |
// For documentation on these settings, see: https://aka.ms/terminal-documentation | |
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"profiles": |
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 main(argv: Array<String>) { | |
val md5Result = "Hello World".saltMD5(null) | |
println("The Salted MD5 Hash is = $md5Result") | |
} | |
private fun String.saltMD5(salt: String?): String { | |
val saltedString = salt?.let { this + it } ?: this | |
val md5MessageDigest = MessageDigest.getInstance("MD5") | |
val digest = md5MessageDigest.digest(saltedString.toByteArray()) | |
val stringBuilder = StringBuilder() |
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
if (beta > 0 ) { | |
version = major * 1000000 + minor * 10000 + (bugfix -1) * 100 + beta | |
} else { | |
version = major * 1000000 + minor * 10000 + bugfix * 100; | |
} |
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
import React from 'react'; | |
import { StyleSheet, Text, Image, View } from 'react-native'; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<View style={{alignItems: 'center', marginTop: 250}} > | |
<Greeting name="Denkeni" relationship="Boss" /> | |
<Greeting name="Joan" relationship="Classmate" /> | |
<Greeting name="Billy" relationship="Roommate" /> |
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
if status is-interactive | |
# Commands to run in interactive sessions can go here | |
end | |
# Oh My Posh | |
oh-my-posh init fish --config ~/.config/ohmyposh/omp.toml | source | |
# Misc | |
set fish_greeting "Hello Fish!" | |
set TERM "xterm-256color" |
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
public class somebody { | |
public static void main(String[] argv) { | |
Store store = new Store(); | |
List<Cellphone> cellphones = store.getCellphones(); | |
for (int i = 0; i < cellphones; i++) { | |
cellphones[i].power(false); | |
} | |
iPhone iphoneX = new iPhone(); | |
cellphones.add(iphoneX); |