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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
requestNotificationPermission() | |
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
/* if you use AlarmManager.setRepeating(timeInMillis, timeInterval), note that the system will always delay your | |
alarm by 5 seconds and the interval must be at least 60 seconds+. However there's virtually no difference between |
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
fun main(){ | |
coroutineScope { | |
launch { findEvenNumbers(1,10..20) } | |
launch { findEvenNumbers(2,30..60) } | |
} | |
} | |
private fun findEvenNumbers(workerName:Int,range: IntRange){ | |
for (i in range){ | |
if (i%2==0) println("[$workerName]: even found $i") | |
} |
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 com.jakewharton.picnic.BorderStyle | |
import com.jakewharton.picnic.TextAlignment | |
import com.jakewharton.picnic.table | |
import java.net.URL | |
import kotlin.time.measureTime | |
fun main(args: Array<String>){ | |
fun String.toHtml() = URL(this).openStream().bufferedReader().use { it.readText() } | |
val baseUrlHtml ="https://leagueofcomicgeeks.com/comics".toHtml() | |
// issues based on publisher |
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 java.util.Objects | |
import java.util.concurrent.locks.ReentrantLock | |
import kotlin.math.max | |
fun main(args: Array<String>){ | |
val text ="A B C D E F G" | |
val trie = Trie(text) | |
println("${" ".repeat(10)}1.START${" ".repeat(10)}") | |
println(trie.addNodeToTrie(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
Regex ::= StartOfStringAnchor? Expression | |
Expression ::= Subexpression ("|" Expression)? | |
/* Anything that can be on one side of the alternation. */ | |
Subexpression ::= SubexpressionItem+ | |
SubexpressionItem | |
::= Match | |
| Group | |
| Anchor |
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
/* a fully fledged parser than parses regex expressions into AST on the fly | |
* note the parser is an LL(1), and the grammar used is context-free | |
* right recursive. | |
* Also, the parser does not tokenize the inputs thus making it a little | |
* faster than those that tokenize their inputs. | |
* Currently, it parses all regexes apart from those having | |
* back-references & Zero-Width Positive Lookahead Assertions '?=' | |
* For reference see: https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools | |
* */ |
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
package kotlinplayground | |
import java.io.IOException | |
import java.net.URI | |
import kotlin.system.measureTimeMillis | |
fun main(vararg args:String) { | |
val url = "https://rest.coinapi.io/v1/assets?apikey=14CCAB31-C529-424C-9407-F9CC89F4C055" | |
val bufferSize = 4096 | |
/* |
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 java.util.* | |
import kotlin.random.Random | |
// for references see https://swtch.com/~rsc/regexp/regexp-bytecode.c.txt | |
// https://swtch.com/~rsc/regexp/regexp1.html | |
fun makeRange(start: Char, end: Char): List<Char> { | |
val out = mutableListOf('(') | |
for (s in start until end) { |
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 java.util.* | |
import kotlin.random.Random | |
// for references see https://swtch.com/~rsc/regexp/regexp-bytecode.c.txt | |
// https://swtch.com/~rsc/regexp/regexp1.html | |
fun makeRange(start: Char, end: Char): List<Char> { | |
val out = mutableListOf('(') | |
for (s in start until end) { |
NewerOlder