Skip to content

Instantly share code, notes, and snippets.

View anhtuank7c's full-sized avatar

Tuan Nguyen anhtuank7c

View GitHub Profile
@anhtuank7c
anhtuank7c / API_guideline.md
Created November 29, 2024 08:00
RESTful Guideline

I'll help you improve the API security and design. Let's analyze the current issues and implement better security practices.

Current Issues:

  1. Exposing secret key as a query parameter is insecure because:
    • It appears in server logs
    • It's visible in browser history
    • It can be intercepted in network traffic
    • It might get cached or bookmarked

Here's a comprehensive solution to improve your API security:

@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.