Skip to content

Instantly share code, notes, and snippets.

nosix

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
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 {
loadAllFiles()
}
}
fun launch(block: suspend () -> Unit) {
block.startCoroutine(object : Continuation<Unit> {
override val context: CoroutineContext get() = EmptyCoroutineContext
override fun resume(value: Unit) {}
@nosix
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.boot.web.support.SpringBootServletInitializer
import org.springframework.context.annotation.Bean
import org.thymeleaf.spring4.SpringTemplateEngine
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver
import org.thymeleaf.spring4.view.ThymeleafViewResolver
@nosix
nosix / AndroidManifest.xml
Last active Jul 3, 2019
Floating App for Android (SDK 21) in Kotlin 1.0.3
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxx">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
...
<service android:name=".FloatingAppService"/>
@nosix
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
setlocal
set CMD=adb devices
for /f "usebackq tokens=1,2,3*" %%a in (`%CMD%`) do (
if "%%b" == "device" (
set DEVICE_ID=%%a
@nosix
nosix / AndroidManifest.xml
Last active Mar 5, 2019
Writting to external storage (SD card) for Android (SDK 23) in Kotlin 1.0.3.
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="xxx">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
</manifest>
@nosix
nosix / AndroidManifest.xml
Last active Nov 13, 2018
How to resolve the memory leak for Android (SDK 22) in Kotlin 1.0.2. (InputMethodManager refer to RecyclerView)
View AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="xxx">
<application
android:name=".MyApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
...
@nosix
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 `FooExtension.foo`.
class FooExtension : Extension {
fun String.foo(): String = "Foo${this}"
}
class BarExtension : Extension {
fun String.bar(): String = "Bar${this}"
@nosix
nosix / ExampleTest.kt
Created Jul 12, 2018
pass JSONCompareMode to JSONAssert when testing with WebTestClient
View ExampleTest.kt
@RunWith(SpringRunner::class)
@SpringBootTest
@AutoConfigureWebTestClient
class ExampleTests {
@Autowired
private lateinit var client: WebTestClient
@Test
fun test_of_get() {
client.get().uri("/api/todo")
@nosix
nosix / MainActivity.kt
Last active May 26, 2018
DialogFragment for Android (SDK 22) in Kotlin 1.0.2
View MainActivity.kt
class MainActivity : AppCompatActivity(), SeekDialogFragment.SeekDialogListener {
companion object {
private val TAG = MainActivity::class.qualifiedName;
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
@nosix
nosix / Capture.kt
Created Sep 18, 2016
Taking a snapshot of the screen for Android (SDK 21) in Kotlin 1.0.3
View Capture.kt
package xxx
import android.content.Context
import android.graphics.Bitmap
import android.graphics.PixelFormat
import android.hardware.display.DisplayManager
import android.hardware.display.VirtualDisplay
import android.media.ImageReader
import android.media.projection.MediaProjection
import android.util.Log
You can’t perform that action at this time.