Skip to content

Instantly share code, notes, and snippets.

View trinnguyen's full-sized avatar

Tri Nguyen trinnguyen

View GitHub Profile
@trinnguyen
trinnguyen / RectDrawable.kt
Created March 22, 2023 10:18
Draw rect drawable to overlay, best for testing Camera Preview
class RectDrawable(rect: Rect): Drawable() {
private val boundingRectPaint = Paint().also {
it.style = Paint.Style.STROKE
it.color = Color.RED
it.strokeWidth = 4f
it.alpha = 255
}
init {
@trinnguyen
trinnguyen / JsonExt.kt
Last active March 13, 2023 08:21
Kotlin serialization json object
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.decodeFromStream
import java.io.InputStream
/**
@trinnguyen
trinnguyen / gist:0cf7f8197ee720c6fe78fa796d55636b
Created November 25, 2022 06:21
Unix cmd list disk size of files and folders
du -sh */ | sort -hr
@trinnguyen
trinnguyen / docker-compose.yml
Created September 10, 2022 10:53
A docker compose that just works with Wordpress + MariaDB
services:
db:
image: mariadb
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
@trinnguyen
trinnguyen / antlr
Created April 6, 2022 10:07
Quick bash script to execute jar file
#!/bin/bash
java -jar $(dirname "$0")/antlr.jar $@
@trinnguyen
trinnguyen / Makefile
Created May 22, 2021 21:39
generate TLS keypair
generate-ca-key-cert:
openssl req -x509 -newkey rsa:4096 -days 3650 -keyout ca-key.pem -out ca-cert.pem
print-ca-cert:
openssl x509 -in ca-cert.pem -noout -text
server-req:
openssl req -x509 -newkey rsa:4096 -days 365 -keyout ca-key.pem -out ca-cert.pem
server-cert:
openssl x509 -req -in server-req.pem -days 60 -extfile v3_req.ext -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem
print-server:
openssl x509 -in server-cert.pem -noout -text
@trinnguyen
trinnguyen / CmakeLists.txt
Created April 19, 2021 11:27
pbes solver ubuntu
cmake_minimum_required(VERSION 3.17)
project(pbesproxy)
set(CMAKE_CXX_STANDARD 17)
set(PBES_DIR "/usr")
set(PBES_LIB_DIR "${PBES_DIR}/lib")
set(PBES_INCLUDE_DIR "${PBES_DIR}/include")
find_library(MCRL2_ATERMPP libmcrl2_atermpp.so PATHS ${PBES_LIB_DIR})
find_library(MCRL2_BES libmcrl2_bes.so PATHS ${PBES_LIB_DIR})
@trinnguyen
trinnguyen / machine.js
Last active January 13, 2021 15:13
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@trinnguyen
trinnguyen / hotspot.md
Last active November 14, 2020 12:58
Apple Hotspot login
@trinnguyen
trinnguyen / download_website
Created October 26, 2020 13:17
Download wesite with wget
wget -H -E -k -p WEB_URL