Skip to content

Instantly share code, notes, and snippets.

View anhtuank7c's full-sized avatar

Tuan Nguyen anhtuank7c

View GitHub Profile
@anhtuank7c
anhtuank7c / keycode_mapping.txt
Created November 8, 2024 07:36
Keycode mapping
KEYCODE_0 = 0
KEYCODE_SOFT_LEFT = 1
KEYCODE_SOFT_RIGHT = 2
KEYCODE_HOME = 3
KEYCODE_BACK = 4
KEYCODE_CALL = 5
KEYCODE_ENDCALL = 6
KEYCODE_0_ = 7
KEYCODE_1 = 8
KEYCODE_2 = 9
@anhtuank7c
anhtuank7c / multiprocess.py
Created November 7, 2024 12:52
Test multiprocess in Python
import concurrent.futures
import time
import schedule
from loguru import logger
# Define a sample job function that simulates a long-running process
def my_long_running_task(task_id: int) -> str:
logger.info(f"Task {task_id} started.")
time.sleep(10) # Simulate a task that takes 10 seconds to complete
@anhtuank7c
anhtuank7c / random.txt
Created November 6, 2024 05:24
just some random characters
NuGvJQtzZaR9q5LmK3H7b8
LJqsMbFYEBkgd7zA6wfX4W
jBL5kxuMgezTFPp9YDJ2Ct
pwvUCBMXuc3H75taQdxfys
N6PhxJGtSA8Vu9nCUfceTL
UjL4Adse6kYN7qJF8XyRZf
pxKdy4w9gk2nUGZq5jLBWM
txwS4JN8znD2LcVhYaZpPA
pN7Je2UvXVcGmhHwaW3DC4
LQ2s3n9qfCaTu4EbB6WMUd

Encrypting data with AES128 in JavaScript

Usage

AES128 uses a 16 byte secret key.

const key = new Uint8Array(16);
crypto.getRandomValues(key);
@anhtuank7c
anhtuank7c / rbac
Last active September 20, 2024 18:22
Casbin RBAC - Role Base Access Control
# model.conf
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _ # Role inheritance between users and roles
g2 = _,_ # Resource management between users and resources
@anhtuank7c
anhtuank7c / rbac_with_resource_roles
Last active September 20, 2024 18:22
Casbin RBAC with resource roles example
# model.conf
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _ # Role inheritance between users and roles
@anhtuank7c
anhtuank7c / @react-native-firebase+app+20.0.0.patch
Created August 27, 2024 13:49
Expo Firebase patch that ensure to remove the auth session once app got deleted
diff --git a/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js b/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js
index 8cf92f0..7840ebb 100644
--- a/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js
+++ b/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js
@@ -7,7 +7,13 @@ exports.withFirebaseAppDelegate = exports.modifyAppDelegateAsync = exports.modif
const config_plugins_1 = require("@expo/config-plugins");
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
const fs_1 = __importDefault(require("fs"));
-const methodInvocationBlock = `[FIRApp configure];`;
+const methodInvocationBlock = `[FIRApp configure];
@anhtuank7c
anhtuank7c / bootable-win-on-mac.md
Created August 10, 2024 13:24 — forked from acarril/bootable-win-on-mac.md
Create a bootable Windows USB using macOS

For some reason, it is surprisingly hard to create a bootable Windows USB using macOS. These are my steps for doing so, which have worked for me in macOS Monterey (12.6.1) for Windows 10 and 11. After following these steps, you should have a bootable Windows USB drive.

1. Download a Windows disc image (i.e. ISO file)

You can download Windows 10 or Windows 11 directly from Microsoft.

2. Identify your USB drive

After plugging the drive to your machine, identify the name of the USB device using diskutil list, which should return an output like the one below. In my case, the correct disk name is disk2.

@anhtuank7c
anhtuank7c / AdbCommands
Created August 5, 2024 00:51 — forked from Pulimet/AdbCommands
Adb useful commands list
Hi All!
I've recently launched a tool that wraps many of the commands here with a user interface. This desktop application is currently available for macOS. There's a roadmap outlining planned features for the near future.
Feel free to request any features you'd like to see, and I'll prioritize them accordingly.
One of the most important aspects of this application is that every command executed behind the scenes is displayed in a special log section. This allows you to see exactly what’s happening and learn from it.
Here's the link to the repository: https://github.com/Pulimet/ADBugger
App Description:
ADBugger is a desktop tool designed for debugging and QA of Android devices and emulators. It simplifies testing, debugging, and performance analysis by offering device management, automated testing, log analysis, and remote control capabilities. This ensures smooth app performance across various setups.
@anhtuank7c
anhtuank7c / install-nginx-mariadb-phpfpm-on-ubuntu-20.04.md
Created April 8, 2024 10:28 — forked from nd3w/install-nginx-mariadb-phpfpm-on-ubuntu-20.04.md
How to Install Nginx, MariaDB, PHP-FPM on Ubuntu 20.04

How to Install Nginx, MariaDB, PHP-FPM on Ubuntu 20.04

This is a way to install and set up Nginx, MariaDB and PHP-FPM on Ubuntu 20.04.

NOTE: This has been prepared for ease of use in mind, not security, mostly in development machine. Please do not use these instructions to setup on a public server environment. Use other proper manuals instead.

$ sudo apt update

Nginx