Skip to content

Instantly share code, notes, and snippets.

View rashanjyot's full-sized avatar

Rashanjyot Singh Arora rashanjyot

  • Marks and Spencer
  • London
View GitHub Profile
@rashanjyot
rashanjyot / structured_concurrency_example3.kt
Last active May 3, 2021 06:55
Structured Concurrency (Example 3)
val parallelJob = launch {
delay(1000)
}
val parentJob = launch {
val childJob = launch(parallelJob) { // Notice how the context is explicitly provided
var count = 1
while (count <= 5) {
println("Count: $count")
delay(100)
@rashanjyot
rashanjyot / structured_concurrency_example2.kt
Last active May 2, 2021 22:16
Structured Concurrency (Example 2)
val parentJob = launch {
val childJob = launch {
var count = 1
val startTime = System.currentTimeMillis()
var nextPrintTime = startTime
while (count <= 5) {
if (System.currentTimeMillis() >= nextPrintTime) {
println("Count: $count")
nextPrintTime += 100L
count++
@rashanjyot
rashanjyot / structured_concurrency_example1.kt
Last active May 2, 2021 21:19
Structured concurrency - example1
val parentJob = launch {
val childJob = launch {
var count = 1
while (count <= 5) {
println("Count: $count")
delay(100)
count++
}
}
}
@rashanjyot
rashanjyot / .htaccess
Created April 12, 2020 15:31
How to show content of subdirectory, even if url is of root directory
lsapi_phpini /home/shilurss/public_html/php.ini
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://xyz.com/$1 [R,L]
// suppose the file is located in public_html/abc/index.html
now currently, xyz.com/abc/ loads the file