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
sealed class SqlStatement | |
// Select statement | |
data class Select( | |
val selectList: SelectList, | |
val from: TableReference, | |
val where: Condition? = null, | |
val groupBy: GroupBy? = null, | |
val orderBy: OrderBy? = null, | |
val limit: Limit? = null |
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
<sql_statement> ::= <select> | <insert> | <update> | <delete> // the full sql statement | |
<select> ::= "SELECT" <select_list> "FROM" <table_reference> ["WHERE <condition>"] ["GROUP BY" <column_list>] ["ORDER BY" <order_list> [<order_by_option>]] ["LIMIT" <number>] // select * from users where age > 12 or select name,age from users order by name ASC | |
<insert> ::= "INSERT INTO" <identifier> "("<column_list>")" "VALUES" "(" <value_list> ")" // insert into users (name,age) values ('John', 12) | |
<update> ::= "UPDATE" <identifier> "SET" <column_assignment> ["WHERE" <condition>] // update users set name='Alice' where id=1 | |
<delete> ::= "DELETE FROM" <identifier> ["WHERE" <condition>] // delete from users where age=12 | |
<table_reference> ::= <identifier> ["JOIN" <identifier> "ON" <condition>] // items or items JOIN orders ON users.id=orders.user_id | |
<select_list> ::= "*"| <column_list> // * name or * name,age,gender | |
<column_list> ::= <identifier>{","<identifier>} // name or name,age or name,age,gender | |
<order_by_option>::= "AS |
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
sealed class SqlStatement | |
// SELECT statement | |
data class Select( | |
val selectList: SelectList, | |
val tableReference: TableReference, | |
val whereCondition: Condition? = null, | |
val groupBy: ColumnList? = null, | |
val orderBy: OrderList? = null, | |
val orderByOption: OrderByOption? = null, |
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
<sql_statement> ::= <select> | <insert> | <update> | <delete> // the full sql statement | |
<select> ::= "SELECT" <select_list> "FROM" <table_reference> ["WHERE <condition>"] ["GROUP BY" <column_list>] ["ORDER BY" <order_list> [<order_by_option>]] ["LIMIT" <number>] // select * from users where age > 12 or select name,age from users order by name ASC | |
<insert> ::= "INSERT INTO" <identifier> "("<column_list>")" "VALUES" "(" <value_list> ")" // insert into users (name,age) values ('John', 12) | |
<update> ::= "UPDATE" <identifier> "SET" <column_assignment> ["WHERE" <condition>] // update users set name='Alice' where id=1 | |
<delete> ::= "DELETE FROM" <identifier> ["WHERE" <condition>] // delete from users where age=12 | |
<table_reference> ::= <identifier> ["JOIN" <identifier> "ON" <condition>] // items or items JOIN orders ON users.id=orders.user_id | |
<select_list> ::= "*"| <column_list> // * name or * name,age,gender | |
<column_list> ::= <identifier>{","<identifier>} // name or name,age or name,age,gender | |
<order_by_option>::= "AS |
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 org.example | |
import kotlinx.coroutines.* | |
import okhttp3.* | |
import okhttp3.HttpUrl.Companion.toHttpUrl | |
import org.example.DownloadProgress.Companion.calculateDownloadPercentageFromDownloadProgress | |
import org.example.Utils.ATTEMPT_COUNT | |
import org.example.Utils.DedicatedBlockingDispatcher | |
import org.example.Utils.combineSegmentsToFile | |
import org.example.Utils.copyToOutputStreamAsynchronously |
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)) |
NewerOlder