Skip to content

Instantly share code, notes, and snippets.

View anhtuank7c's full-sized avatar
🎯
Focusing

Tuan Nguyen anhtuank7c

🎯
Focusing
View GitHub Profile
@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

@anhtuank7c
anhtuank7c / AesUtil.ts
Created March 17, 2024 03:11 — forked from btxtiger/AesUtil.ts
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
/**
* Cryptography Functions
*
* Forked from AndiDittrich/AesUtil.js
* https://gist.github.com/AndiDittrich/4629e7db04819244e843
*/
import crypto, { CipherGCM, CipherGCMTypes, DecipherGCM } from 'crypto';
import { Password } from './types';
@anhtuank7c
anhtuank7c / clean_code.md
Created January 21, 2024 09:03 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@anhtuank7c
anhtuank7c / useToggleStorybook.ts
Created October 19, 2023 09:44 — forked from MarceloPrado/useToggleStorybook.ts
Dynamically toggle between storybook and app
import { config } from "@/app/config";
import { createLogger } from "@/app/observability";
import { useEffect } from "react";
const { appEnv } = config;
const logger = createLogger("developer/storybook");
export const useToggleStorybook = () => {
const [isStorybookEnabled, setIsStorybookEnabled] = useState(false)
@anhtuank7c
anhtuank7c / .gitignore
Created June 21, 2023 09:24 — forked from tatsuyasusukida/.gitignore
Node.js Docker Image that can uses FFmpeg
/out.mp4
@anhtuank7c
anhtuank7c / react-native-reanimated-drag-sort_apple-music.jsx
Created March 22, 2022 01:31 — forked from eveningkid/react-native-reanimated-drag-sort_apple-music.jsx
React Native Reanimated 2 Multiple Drag and Sort: Apple Music Example
// Expo SDK40
// expo-blur: ~8.2.2
// expo-haptics: ~8.4.0
// react-native-gesture-handler: ~1.8.0
// react-native-reanimated: ^2.0.0-rc.0
// react-native-safe-area-context: 3.1.9
import React, { useState } from 'react';
import {
Image,
/*
Before Septemper 15 2018, Vietnam has phone number start with 09*, 01(2|6|8|9).
After that, the phone number can start with 03, 05, 07 or 08.
So this function provide a way to validate the input number is a Vietnamese phone number
*/
function isVietnamesePhoneNumber(number) {
return /(03|05|07|08|09|01[2|6|8|9])+([0-9]{8})\b/.test(number);
}
@anhtuank7c
anhtuank7c / VehicleMarker.js
Created February 18, 2022 07:51 — forked from zhenguet/data.js
Journey
import React, {memo, useEffect, useState} from 'react';
import {Animated, Platform, StyleSheet} from 'react-native';
import {AnimatedRegion, Marker} from 'react-native-maps';
import {Car} from '../../../../../Assets/Images';
function VehicleMarker({
data,
tripIndex,
initLatDelta,
initLongDelta,

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
@anhtuank7c
anhtuank7c / BroadcastReceiver.kt
Created November 16, 2020 03:24 — forked from afollestad/BroadcastReceiver.kt
A Lifecycle components aware BroadcastReceiver DSL (Kotlin)
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import androidx.lifecycle.Lifecycle.Event.ON_START
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import android.content.BroadcastReceiver as StockReceiver