Skip to content

Instantly share code, notes, and snippets.

View NonCoderF's full-sized avatar

Nizamuddin Ali Ahmed NonCoderF

View GitHub Profile
@NonCoderF
NonCoderF / Observer.kt
Created July 17, 2023 16:29
Modified Observer with single JSON Object design
import org.json.JSONObject
typealias JsonObserver = (jsonObject: JSONObject) -> Unit
class JSONSubject {
companion object {
fun instance() = JSONSubject()
}
Generating SHA256 hash of public key from a certificate (mycertfile.pem)
openssl x509 -in mycertfile.pem -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
fun main() {
val fun1: (Int) -> Int = { x -> x + 1 }
val fun2: (String) -> String = { x -> x.reversed() }
val fun3: (List<Int>) -> Int = { x -> x.sum() }
val fun4: (Double) -> Double = { x -> x * x }
val result1: (Int) -> Any = ::fun4::fun3::fun2::fun1
val result2: (Int) -> Any = fun4::fun3::fun2::fun1
val fun5: (Any) -> String = { x -> x.toString() }
@NonCoderF
NonCoderF / ComposeChatBox.kt
Last active December 27, 2022 03:12
Jetpack compose chat box path sample
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.unit.dp
@NonCoderF
NonCoderF / SortingAnalyser.kt
Created December 11, 2022 09:50
Code to analyse time for various sorting algorithms
import java.util.*
fun main() {
println("Analyzing algorithms...")
val array = IntArray(1000000) { Random().nextInt() }
analyseAlgorithms("quikSort" , { quikSort(it) }, array)
analyseAlgorithms("mergeSort" , { mergesort(it) }, array)
interface AppUpdater {
fun checkUpdate()
}
class AppUpdaterImpl(val activity: AppCompatActivity) : AppUpdater {
companion object {
private const val APP_UPDATE_REQUEST_CODE = 1991