Skip to content

Instantly share code, notes, and snippets.

View kai-phan's full-sized avatar
👋
Hi there!

Vinh Quy Phan kai-phan

👋
Hi there!
View GitHub Profile
@kai-phan
kai-phan / router.config.tsx
Last active July 19, 2023 12:33
Type safe useNavigate hook for React router 6.x
import {
Outlet,
createBrowserRouter,
useNavigate,
NavigateOptions,
} from 'react-router-dom';
const routeObjects = [
{
path: '/',
@kai-phan
kai-phan / index.ts
Last active October 7, 2023 12:52
Assign a local variable in a type-level expression!
type Fn<I> = SuperHeavyComputation<I> extends infer Result
// ^ 🤯 ^
? [Result, Result, Result]
: never; // this branch can never be reached
// We can use infer directly after extends.
// This will have the effect of assigning the result of SuperHeavyComputation<I> to a variable.
// The downside is that we need to declare an "else" code branch even though we know it will never be reached because any type is assignable to infer Result.
@kai-phan
kai-phan / main.yaml
Created December 10, 2023 05:41
Github Action work flow static site with Vite and AWS
name: Vite with AWS
on:
push:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
@kai-phan
kai-phan / gist.md
Created April 11, 2024 08:50 — forked from ArcRanges/gist.md
aws-ec2-nextjs

Instructions to properly set up a production-ready NextJS App with AWS

This is a summary of how to start your own NextJS app, create the repo on Github, upload later in an AWS EC2 Instance and automate the process with AWS Codebuild, CodeDeploy, & CodePipeline.

After following these instructions you should be able to:

  • Create a NextJS App
  • Create an AWS EC2 instance
  • Be able to SSH to an EC2 instance
  • Prepare the instance as a Node environment
  • Configure Nginx service for proper routing
  • Configure domain and add SSL
@kai-phan
kai-phan / default
Created October 2, 2024 17:41 — forked from dtomasi/default
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}

Run a local HTTP server with Docker 🐳

Serve your static website from localhost using Docker and Nginx.

By @arrested-developer

Why Docker?

Do you know the famous phrase "it works on my machine"?

@kai-phan
kai-phan / Experimental Docker structure.md
Created October 25, 2024 13:13 — forked from shinsenter/Experimental Docker structure.md
Docker structure for deploying to multiple environments

Beginning

There are many approaches to implementing a reuse of a common preset for Docker services for multiple environments, such as production and local environments.

This makes it possible to ensure the highest consistency for different environments with the same code-base. Implementing reuse of docker compose options also makes it easier to manage them.

I found on github a project called serversideup/spin. They took an approach using a feature called Docker overrides, to change some properties of common services for different environments.

After reading through their documentation, I realized that there are a few real-life cases where this project can not implement (or is difficult to archive).

@kai-phan
kai-phan / LinuxNetworkCommand.md
Created November 2, 2024 18:22 — forked from royki/LinuxNetworkCommand.md
Linux Network Command

Linux Network Command

  1. ifconfig - ifconfig (interface configurator) command is use to initialize an interface, assign IP Address to interface and enable or disable interface on demand. With this command you can view IP Address and Hardware / MAC address assign to interface and also MTU (Maximum transmission unit) size.
    • interface name
    • mask
    • loopback address
  • ifconfig -a
    • ifconfig with interface (eth0) command only shows specific interface details like IP Address, MAC Address etc. with -a options will display all available interface details if it is disable also.
  • ifconfig -v
  • ifconfig -s
@kai-phan
kai-phan / linux_networking.sh
Created November 2, 2024 18:23 — forked from cmccormack/linux_networking.sh
Linux Networking Commands
# View device IP Address(es)
ip -o address show [interface] | awk '{print $4}' # Prints the IP address(es) of a single interface
ip address # Displays all interfaces
ifconfig # (deprecated)
hostname -I # Displays only IP addresses
# DNS name and resolution
host
dig
/etc/hosts # Add manual DNS record to hostname mappings (normally checked before configured DNS server(s))
@kai-phan
kai-phan / linux_network_commands.md
Created November 2, 2024 18:25 — forked from mnishiguchi/linux_network_commands.md
Linux - Network commands

Linux - Network commands

Routing tables

  • Servers maintain routing tables containing the addresses of each node in the network.
  • The IP Routing protocols enable routers to build up a forwarding table that correlates final destinations with the next hop addresses.

Common utilities