Skip to content

Instantly share code, notes, and snippets.

View LongClipeus's full-sized avatar
:atom:
Focusing

Long Le Van LongClipeus

:atom:
Focusing
View GitHub Profile
@LongClipeus
LongClipeus / FaceMeshConst.kt
Created April 28, 2023 03:52
The face mesh points to the lips in Mediapipe
object FaceMeshConst {
val FACEMESH_UPPER_RIGHT_LIPSS = listOf(
StraightLineFaceMesh(0, 267),
StraightLineFaceMesh(267, 11),
StraightLineFaceMesh(11, 0),
StraightLineFaceMesh(11, 302),
StraightLineFaceMesh(302, 267),
StraightLineFaceMesh(267, 11),
[
{
"id": "c154697af277016d452b1bc815f5d1787fa2d694",
"thumbnail": "https://media.guim.co.uk/9fd1d41b23d3831ee8b918930cdd1bdc0c8045e1/0_0_2560_1536/500.jpg",
"title": "There is a wounded pigeon in the garden. Should I intervene?",
"url": "https://www.theguardian.com/lifeandstyle/2022/oct/15/there-is-a-wounded-pigeon-in-the-garden-should-i-intervene",
"words": "795",
"section": "Life and style",
"date": "2022-10-15T05:00:58Z",
"image": "https://media.guim.co.uk/9fd1d41b23d3831ee8b918930cdd1bdc0c8045e1/0_0_2560_1536/1000.jpg",
{
"featuredComics": [
{
"name": "Thánh gióng 1",
"type": "Truyện Cổ Tích",
"listen_count": 100
},
{
"name": "Thánh gióng 2",
"type": "Truyện Cổ Tích",
@LongClipeus
LongClipeus / Bai_tap.md
Last active May 8, 2023 15:23
Bài tập lập trình cơ bản

Bài 1: viết chương trình "Hello world"

Bài 2: Viết chương trình hiển thị N dòng "Hello world", với N là số nguyên dương nhập vào từ bàn phím

Bài 3: Viết chương trình nhập vào 1 số X bất kỳ và hiển thị số vừa nhập, cho biết số đó là số thập phân, số nguyên âm hay nguyên dương

Bài 4: Viết chương trình tính tổng 3 số thực nhập vào từ bàn phím

Bài 5: Viết chương trình nhập vào 3 số thực và kiểm tra 3 số này có phải là cạnh của một tam giác hay không

import android.content.Context
import androidx.annotation.RawRes
import com.tech.melait.common.utils.ResourceUtils.readRawFile
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
suspend fun readRawFile(context: Context, @RawRes res: Int) = withContext(Dispatchers.Default) {
context.resources.readRawFile(res)
}
@LongClipeus
LongClipeus / PermissionUtils.kt
Last active September 25, 2021 07:41
How to know if user has disabled Picture in Picture feature permission?
const val ACTION_PIP_SETTING = "android.settings.PICTURE_IN_PICTURE_SETTINGS"
@RequiresApi(Build.VERSION_CODES.O)
fun AppCompatActivity.hasPictureInPicturePermission(): Boolean {
val appOps = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
val uid = android.os.Process.myUid()
val mode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
appOps.unsafeCheckOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, uid, packageName)
} else {
@Suppress("DEPRECATION")
@LongClipeus
LongClipeus / TrafficLightStatus.kt
Created August 3, 2021 15:45
How to make enum Parcelable in Kotlin?
import android.os.Parcel
import android.os.Parcelable
enum class TrafficLightStatus(val id: Int) : Parcelable {
RED(1),
YELLOW(2),
GREEN(3);
constructor(parcel: Parcel) : this(parcel.readInt())
@LongClipeus
LongClipeus / HashUtils.kt
Last active March 13, 2024 11:54
How to generate checksum hash for a file in Kotlin
import StringUtils.encodeHex
import java.io.File
import java.io.FileInputStream
import java.io.InputStream
import java.security.MessageDigest
object HashUtils {
const val STREAM_BUFFER_LENGTH = 1024
@LongClipeus
LongClipeus / ToastUtils.kt
Created July 22, 2021 03:37
custom toast in kotlin
fun showToastGreen(context: Context, message: String) {
val toast: Toast = Toast.makeText(context, "", Toast.LENGTH_LONG)
val view = toast.view
view.background.setColorFilter(
ContextCompat.getColor(context, R.color.green_dark),
PorterDuff.Mode.SRC_IN
)
val text = view.findViewById<TextView>(android.R.id.message)
text.setTextColor(ContextCompat.getColor(context, R.color.white))
text.text = message
#!/usr/bin/env python3
version= '3.0'
title = '''
_ \ __ \ __ \ ___| _) |
| | | | | | | | _ \ __| \___ \ __| __| | __ \ __|
___/ | | | | | | ( |\__ \ | ( | | | | |
_| \__, |____/ ____/ \___/ ____/ _____/ \___|_| _| .__/ \__|
____/ _|