Skip to content

Instantly share code, notes, and snippets.

View amanshuraikwar's full-sized avatar

Amanshu Raikwar amanshuraikwar

View GitHub Profile
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@amanshuraikwar
amanshuraikwar / coroutines-cookbook-1.kt
Last active May 11, 2020 01:54
Coroutines - runBlocking - GlobalScope - join()
import kotlinx.coroutines.*
fun main() = runBlocking {
val job = GlobalScope.launch { // launch a new coroutine and keep a reference to its Job
delay(1000L)
println("World!")
}
println("Hello,")
job.join() // wait until child coroutine completes
}
@amanshuraikwar
amanshuraikwar / adbwificonnect.sh
Last active January 11, 2022 10:22
Shell script to connect a USB connected device via adb over WiFi
# Purpose: Shell script to connect a USB connected device via adb over WiFi
#
# Author: Amanshu Raikwar
#
# Assumptions:
# 1. USB debugging is enabled in the Android device
# 2. The Android device is connected to the computer via USB
# 3. The Android device is connected to the same wifi as the computer
# 4. The Android device is accessible through port 5555 over the wifi network
#
@amanshuraikwar
amanshuraikwar / simple-demonstration.kt
Created December 30, 2018 15:50
RxJava Thread Switching like a Pro - Medium Article - 2
/*
* RxJava simple demonstration of subscribeOn() and observeOn()
*/
println("Calling function : Thread = ${Thread.currentThread().id}")
Observable
.just(1)
.doOnNext {
println("OnNext : Val = $it : Thread = ${Thread.currentThread().id}")
@amanshuraikwar
amanshuraikwar / no-multi-threading.kt
Last active December 30, 2018 15:47
RxJava Thread Switching like a Pro - Medium Article - 1
/*
* RxJava without any multi-threading
*/
println("Calling function : ${Thread.currentThread().id}")
val obs = Observable
.just(1)
.doOnNext {
println("OnNext : Val = $it : Thread = ${Thread.currentThread().id}")