Skip to content

Instantly share code, notes, and snippets.

View hungnphan's full-sized avatar

Hung Phan hungnphan

  • Earth, Milky Way galaxy
View GitHub Profile
#!/bin/bash
# Target date in seconds since epoch (May 29, 2025, 13:42 GMT+7)
TARGET_DATE=$(date -d "2025-05-29 13:42:00 +0700" +%s)
# Check if we have permission to read journal
if ! journalctl --list-boots >/dev/null 2>&1; then
echo "Error: Cannot access journal. You may need to run this script with sudo or be in the 'adm' or 'systemd-journal' group."
exit 1
fi
@hungnphan
hungnphan / app.py
Created May 7, 2024 13:35 — forked from vovavili/app.py
Streamlit + Firebase authorization example
"""Module for handling authentication, interactions with Firebase and JWT cookies.
This solution is refactored from thestreamlit_authenticatorpackage . It leverages JSON
Web Token (JWT) cookies to maintain the users login state across browser sessions. For the
backend, It uses Googles Firebase Admin Python SDK. This solution ensures that the content
of the page and user settings panel are only displayed if the user is authenticated. Similarly,
the login page can only be accessed if the user is not authenticated. Upon registration, the
user is sent a verification link to their e-mail address.
Important - to make this app run, put the following variables in your secrets.toml file:
COOKIE_KEY - a random string key for your passwordless reauthentication
@hungnphan
hungnphan / git_submodules.md
Created December 30, 2023 15:24 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@hungnphan
hungnphan / pdfmod.py
Created September 11, 2023 01:36 — forked from jrsmith3/pdfmod.py
Convert specified pages from a PDF to png
"""
This script was used to create the figures for http://jrsmith3.github.io/sample-logs-the-secret-to-managing-multi-person-projects.html from a PDF file containing some old CMU sample logs.
"""
import PyPDF2
from wand.image import Image
import io
import os
@hungnphan
hungnphan / comprehensive_header.py
Created February 2, 2023 07:11 — forked from NicolasBizzozzero/comprehensive_header.py
Python template of a comprehensive header, with shebang, docstring, GPLv3 license and all metadata.
#!/usr/bin/env python
""" Short description of this Python module.
Longer description of this module.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
@hungnphan
hungnphan / Kubeflow.md
Created June 6, 2022 05:14 — forked from John-Lin/Kubeflow.md
Kubeflow on Minikube

Deploy Kubeflow on Minikube

Install minikube

Please see How to Minikube

Running a minikube with 4CPUs and 8GB memory

$ minikube start --cpus 4 --memory 8192

Installing the NVIDIA driver, CUDA and cuDNN on Linux (well-tested on Ubuntu 20.04)

This is a special note after my painful trials with NVIDIA driver+CUDA+cuDNN installation on Ubuntu 20.04 LTS because they have some different update w.r.t Ubuntu 18.04. In particular, the aim is to install the following pieces of software:

At the time of writing (2022-May-15), the NVIDIA driver v510.68.02 is the lastest version. My earlier note was moved to achieve because it is outdated on Ubuntu 20.04.

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@hungnphan
hungnphan / automated_opencv_compilation_in_docker.sh
Last active July 19, 2021 03:15 — forked from ntcuong777/automated_opencv_compilation_in_docker.sh
Install OpenCV 4.5.1 as root user inside Docker - not tested on parent OS
#!/bin/bash
# THIS FILE WILL REQUIRES SUDO
# NOTE: Use <full path>, dont use ~/ to point to home, since it will point to /root/ if you use `sudo`
# or if you are currently the `root` user, IDK.
# Set your OpenCV install prefix path for CMake here
OPENCV_PREFIX_PATH=/home/cuong/compiled_libraries
OPENCV_DOWNLOAD_LINK=https://github.com/opencv/opencv/archive/4.5.1.zip
OPENCV_CONTRIB_DOWNLOAD_LINK=https://github.com/opencv/opencv_contrib/archive/4.5.1.zip
@hungnphan
hungnphan / xsukax-ffmpeg-installer.sh
Created June 8, 2021 06:42
Installing ffmpeg on Kali Linux 2.0
#!/bin/bash
echo "---------------------"
echo "Installing ffmpeg ..."
echo "---------------------"
cd /root/Desktop/
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure
make
make install