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
// mono | |
// data = [[-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1], [-1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1], [-1, -1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, -1, -1, -1], [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, -1], [1, 1, 0, 1, 3, 2, 1, 1, 1, 3, 2, 1, 0, 1, 1, -1], [-1, 1, 0, 1, 2, 2, 1, 1, 1, 2, 2, 1, 0, 1, -1, -1], [-1, -1, 0, 1, 4, 4, 1, 1, 1, 4, 4, 1, 0, -1, -1, -1], [-1, -1, -1, 0, 1, 1, 1, 2, 1, 1, 1, 0, -1, -1, -1, -1], [-1, -1, -1, -1, 0, 0, 1, 1, 1, 0, 0, -1, -1, -1, -1, -1], [-1, 1, -1, -1, -1, -1, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1], [-1, 0, -1, -1, -1, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1], [-1, 0, 0, -1, -1, 0, 0, 1, 0, 0, -1, -1, -1, -1, -1, -1], [-1, -1, 0, 0, 0, 0, 1, 1, 1, 0, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1], [-1, -1, -1, 0, 0, 1, 1, 0, 1, 1, 0, 0, -1, -1, -1, -1]]; | |
// height = [3, 1, 2, 1, 1]; | |
// mario flower power | |
// data = [[-1, -1, -1, -1, 0, 0, 0, 0, |
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
/* | |
* 6-sided play cube | |
*/ | |
DRAW_DOTS = 0; | |
DRAW_CHATS = 1; | |
// font face | |
font_face="Arial"; | |
// font style |
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
import json | |
import codecs | |
locales = ["es", "en", "pt", "de", "it", "hi"] | |
input_file = file("translations.json", "r") | |
data = json.loads(input_file.read().decode("utf-8-sig")) | |
for locale in locales: | |
loc = data['translations'][locale] |
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
{ | |
"translations": { | |
"en": { | |
"hello": "Hello", | |
"world": "World" | |
}, | |
"es": { | |
"hello": "Hola", | |
"world": "Mundo" | |
}, |
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
sealed class Notifications() { | |
// Main | |
data class NewsGetItemsNotification(val ex: Throwable) : Notifications() | |
// Navigation | |
data class NavigationNotification(val ex: Throwable) : Notifications() | |
} |
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
sealed class Commands { | |
// Main | |
data class MainNavigationCommand(val item: MainNavigationState) : Commands() | |
// News | |
data class NewsGetItemsCommand(val limit: Int = 10) : Commands() | |
data class ReloadNewsCommand(val limit: Int = 10) : Commands() |
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 notification(notification: Notifications): DeferredK<Unit> = when (notification) { | |
is Notifications.NewsGetItemsNotification -> DeferredK { | |
viewState.postValue(ViewState.FailedViewState(notification.ex)) | |
} | |
else -> notification.toDeferred() | |
} |
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
newsModel.dispatch(NewsGetItemsCommand()).unsafeRunAsyncWithException { | |
newsModel.notification(Notifications.NewsGetItemsNotification(it)) | |
} |
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
sealed class ViewState { | |
object IdleViewState : ViewState() | |
object WaitingViewState : ViewState() | |
object SuccessViewState : ViewState() | |
data class FailedViewState(val throwable: Throwable) : ViewState() |
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
val newsState = State<States.NewsState>() | |
val viewState = State<ViewState>(ViewState.IdleViewState) | |
fun dispatch(command: Commands): DeferredK<Unit> = when (command) { | |
is Commands.NewsGetItemsCommand -> { | |
DeferredK.monad().binding { | |
val newsList = newsState.getValue() | |
if (newsList?.items?.isEmpty() == false) { | |
"Loading data from state".logD() | |
viewState.postValue(ViewState.SuccessViewState) |
NewerOlder