Skip to content

Instantly share code, notes, and snippets.

View kevalpatel2106's full-sized avatar

Keval Patel kevalpatel2106

  • Bristol, UK
  • 11:16 (UTC)
View GitHub Profile
2025.08.11 - 2025.08.17
2025.08.04 - 2025.08.10
2025.07.28 - 2025.08.03
2025.07.14
@kevalpatel2106
kevalpatel2106 / Example.kt
Created July 19, 2021 07:46
Channel collection demo
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 {
@kevalpatel2106
kevalpatel2106 / Example.kt
Created July 19, 2021 07:40
Kotlin channel types demo
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")
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)
#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.
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.");
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
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.");
@kevalpatel2106
kevalpatel2106 / pi_performance.sh
Created June 26, 2019 17:11
Raspberry PI temperature measurement script
#!/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
pi@raspberrypi:~ $ /opt/vc/bin/vcgencmd measure_temp
temp=56.9'C