Skip to content

Instantly share code, notes, and snippets.

View kevalpatel2106's full-sized avatar
:bowtie:
while(true){ 👨🏻‍💻 }

Keval Patel kevalpatel2106

:bowtie:
while(true){ 👨🏻‍💻 }
View GitHub Profile
@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")
@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
class DownloadWorker : Worker() {
/**
* This function will be called whenever the work manager run the work.
*/
override fun doWork(): WorkerResult {
//Do some work
Thread.sleep(5000)
// Indicate success or failure with your return value.
package com.kevalpatel2106;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
/**
* Created by Keval on 06/05/18.
/**
* Add the view to the phone's window.
*/
private void addToWindow() {
//Add the view to the window.
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
# OUTPUT:
# speech recognization
# Hello earnest...
# Say something!
# Got it! Now to recognize it...
# You said hello
# Install speech recognisation
sudo pip install SpeechRecognition
Amazon music:
intentFilter.addAction("com.amazon.mp3.playstatechanged");
intentFilter.addAction("com.amazon.mp3.metachanged");
Spotify:
intentFilter.addAction("com.spotify.music.playbackstatechanged");
intentFilter.addAction("com.spotify.music.metadatachanged");
Samsung Music:
intentFilter.addAction("com.samsung.sec.android.MusicPlayer.metachanged");
@kevalpatel2106
kevalpatel2106 / github-clone.sh
Last active April 5, 2018 07:13
Clone all the repo from Github.
#!/bin/bash
echo "Enter the access key. Tou can generate access key from \"https://github.com/settings/tokens\".:"
read ACCESS_TOKEN
echo "Enter to host url of the GitHub: (e.g. github.com)"
read GITHUB_INSTANCE
echo "Enter to the page number: (Script will download 100 repos per page.)"
read PAGE
@kevalpatel2106
kevalpatel2106 / AndroidManifest.xml
Created July 27, 2017 12:00 — forked from riggaroo/AndroidManifest.xml
Custom Android Espresso Test Runner - Unlocking a Device, Granting Permission to turn animations off, turning the Screen on.
<?xml version="1.0" encoding="utf-8"?>
<!-- Put this file in the "debug" folder so it only gets merged into debug builds -->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.bookdash.android">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Disable animations on debug builds so that the animations do not interfere with Espresso