Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block nosix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nosix / LiveDataEditor.kt
Created Oct 9, 2019
How to make MutableLiveData declaration unnecessary in ViewModel.
View LiveDataEditor.kt
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlin.reflect.KProperty
abstract class LiveDataEditor<R> {
fun <T> propertyOf() = LiveDataProperty<T>()
nosix / capture.bat
Last active Jun 24, 2019
Batch file to start Android device screen capture. Please put it in the scrcpy folder and execute it.
View capture.bat
@echo off
cd %~dp0
set CMD=adb devices
for /f "usebackq tokens=1,2,3*" %%a in (`%CMD%`) do (
if "%%b" == "device" (
set DEVICE_ID=%%a
nosix / ExampleTest.kt
Created Jul 12, 2018
pass JSONCompareMode to JSONAssert when testing with WebTestClient
View ExampleTest.kt
class ExampleTests {
private lateinit var client: WebTestClient
fun test_of_get() {
nosix / coroutineSample.kt
Last active Sep 3, 2019
Promise and async/await sample in Kotlin/JS
View coroutineSample.kt
fun main(args: Array<String>) {
launch {
fun launch(block: suspend () -> Unit) {
block.startCoroutine(object : Continuation<Unit> {
override val context: CoroutineContext get() = EmptyCoroutineContext
override fun resume(value: Unit) {}
nosix / limitedExtensions.kt
Created Sep 7, 2017
How to limit the scope of extension functions in Kotlin.
View limitedExtensions.kt
interface Extension
// Why is keyword `class` instead of `object`?
// Because we can use the `foo` function after importing ``.
class FooExtension : Extension {
fun String = "Foo${this}"
class BarExtension : Extension {
fun String = "Bar${this}"
nosix / after.kt
Created Sep 4, 2017
convert deprecated @nativeGetter/@nativeSetter to inline extension function
View after.kt
external interface MethodMap
inline operator fun MethodMap.get(propertyName: String): Function<Any>? = this.asDynamic()[propertyName]
inline operator fun MethodMap.set(propertyName: String, value: Function<Any>?) {
this.asDynamic()[propertyName] = value
nosix / generated_sample.js
Last active Sep 5, 2017
union type in Kotlin/JS
View generated_sample.js
function sample$lambda() {
return 'Bar';
function sample() {
var v1 = 'Foo';
var v2 = sample$lambda;
nosix / Application.kt
Last active Jul 12, 2019
Google App Engine Standard Environment in Java8 with Kotlin and SpringBoot
View Application.kt
package com.example
import com.example.mapper.json.JsonObjectMapper
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.context.annotation.Bean
import org.thymeleaf.spring4.SpringTemplateEngine
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver
import org.thymeleaf.spring4.view.ThymeleafViewResolver
nosix / pidep
Last active Dec 16, 2016
bash command to deploy and run python on remote Raspberry Pi.
View pidep
CMD=`basename $0`
usage() {
echo "Usage: $CMD [-r script] [-d dst] [-s src]" 1>&2
nosix / AngularJSDialect.kt
Last active Nov 22, 2016
Spring Boot (1.4.2.RELEASE) + Thymeleaf (2.1.5) configuration sample (no escape single quote)
View AngularJSDialect.kt
package xxx.thymeleaf
import org.thymeleaf.processor.IProcessor
import org.thymeleaf.spring4.dialect.SpringStandardDialect
class AngularJSDialect : SpringStandardDialect() {
companion object {
private val attributes = arrayOf(
"ng-class", "ng-model", "ng-show",
You can’t perform that action at this time.