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 kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.flow.receiveAsFlow | |
import kotlinx.coroutines.flow.collect | |
import kotlinx.coroutines.flow.collectLatest | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.delay | |
fun main() { | |
GlobalScope.launch { |
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 kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.flow.receiveAsFlow | |
import kotlinx.coroutines.flow.collect | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.GlobalScope | |
fun main() { | |
GlobalScope.launch { | |
val channel = Channel<String>(Channel.BUFFERED) // Replace it with RENDEZVOUS and behaviour will change, you won't see ABC printed | |
channel.send("ABC") |
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 os | |
import time | |
def measure_temp(): | |
temp = os.popen("vcgencmd measure_temp").readline() | |
return (temp.replace("temp=","")) | |
while True: | |
print(measure_temp()) | |
time.sleep(1) |
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
#Enable daemon | |
org.gradle.daemon=true | |
# Try and findout the best heap size for your project build. | |
org.gradle.jvmargs=-Xmx3096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | |
# Modularise your project and enable parallel build | |
org.gradle.parallel=true | |
# Enable configure on demand. |
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
public class SingletonClass implements Serializable { | |
private static volatile SingletonClass sSoleInstance; | |
//private constructor. | |
private SingletonClass(){ | |
//Prevent form the reflection api. | |
if (sSoleInstance != null){ | |
throw new RuntimeException("Use getInstance() method to get the single instance of this class."); |
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
Observable<String> database = Observable //Observable. This will emit the data | |
.just(new String[]{"1", "2", "3", "4"}); //Operator | |
Observer<String> observer = new Observer<String>() { | |
@Override | |
public void onCompleted() { | |
//... | |
} | |
@Override |
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
public class SingletonClass { | |
private static SingletonClass sSoleInstance; | |
//private constructor. | |
private SingletonClass(){ | |
//Prevent form the reflection api. | |
if (sSoleInstance != null){ | |
throw new RuntimeException("Use getInstance() method to get the single instance of this class."); |
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
#!/bin/bash | |
clear | |
for f in {1..7} | |
do | |
vcgencmd measure_temp | |
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run >/dev/null 2>&1 | |
done | |
vcgencmd measure_temp |
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
pi@raspberrypi:~ $ /opt/vc/bin/vcgencmd measure_temp | |
temp=56.9'C |
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
public class SingletonTester { | |
public static void main(String[] args) { | |
//Create the 1st instance | |
SingletonClass instance1 = SingletonClass.getInstance(); | |
//Create 2nd instance using Java Reflection API. | |
SingletonClass instance2 = null; | |
try { | |
Class<SingletonClass> clazz = SingletonClass.class; | |
Constructor<SingletonClass> cons = clazz.getDeclaredConstructor(); |
NewerOlder