Skip to content

Instantly share code, notes, and snippets.

View anhdiepmmk's full-sized avatar

PHẠM NGỌC ĐIỆP anhdiepmmk

View GitHub Profile
@anhdiepmmk
anhdiepmmk / App.tsx
Last active January 1, 2023 11:06
reactjs typescript todo list
import { useState, useRef, KeyboardEvent, useEffect } from 'react'
const TODO_KEY = 'todos'
function App() {
const inputRef = useRef<HTMLInputElement>(null)
const [todos, setTodos] = useState<string[]>(() => {
const todoStr: string | null = localStorage.getItem(TODO_KEY)
@anhdiepmmk
anhdiepmmk / calculator.js
Last active August 20, 2022 03:16
simple calculator
function combine(a, b, operator) {
if (operator === 'x') {
return a * b;
}
if (operator === '/') {
return a / b;
}
if (operator === '+') {
return a + b;
}
const _ = require("lodash");
const fs = require("fs");
const teams = [
{ name: "Phap", weight: 5, rank: 5 },
{ name: "Duc", weight: 3, rank: 5 },
{ name: "Bo dao nha", weight: 2, rank: 5 },
];
const list = _.chain(teams)
#!/bin/bash
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_SESSION_TOKEN="..."
should_terminate_ec2_instance=no
sleep_after_terminate_ec2_instance=30s
usage() {
echo "Usage: ./update-private-dns.sh --terminate-ec2 no --sleep 40s --service a-alias"
@anhdiepmmk
anhdiepmmk / gist:31e3d23e4a9274c7f293adc2d7459184
Last active July 1, 2022 06:57
Longest Consecutive Subsequence
/*
Given an unsorted array of integersarr, return the length of the longest consecutive elements sequence.
You must write an algorithm that runs in O(n) time.
Example 1:
Input:arr = [100,4,200,1,3,2]
@anhdiepmmk
anhdiepmmk / config
Last active June 4, 2022 14:24
i3 configuration file
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
@anhdiepmmk
anhdiepmmk / Dockerfile
Created May 23, 2022 13:36 — forked from BretFisher/Dockerfile
WIP sample Laravel php_fpm plus nginx plus supervisor Docker setup with npm, composer, bower, and more
FROM yourdockername/base-php-nginx:latest AS build
# BUILD STAGE
# the primary reason we have two build stages is so SSH key of private repo's will never
# be in final image
# COPY IN BUILD SSH KEY
# It won't be copied to final image
# add this build arg to compose file
ARG BUILDKEY
RUN if [ -z "$BUILDKEY" ]; then echo "BUILDKEY SSH NOT SET - ERROR"; exit 1; else : ; fi
@anhdiepmmk
anhdiepmmk / rbac.txt
Last active May 21, 2022 06:09
rbac model
verb:
- create
- update
- delete
- read
...
subject:
- user
- listing
@anhdiepmmk
anhdiepmmk / tmux.conf
Created May 15, 2022 17:02 — forked from rajanand02/tmux.conf
Tmux configurations with status bar theme
# set prefix to control-f
set -g prefix C-f
#unbind system defined prefix
unbind C-b
# helps in faster key repetition
set -sg escape-time 0
# start session number from 1 rather than 0
import * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
// create ns omg
const ns = new k8s.core.v1.Namespace("omg", {
metadata: {
name: "omg",
},
});