Skip to content

Instantly share code, notes, and snippets.

View theaungmyatmoe's full-sized avatar
🐙
Real life doesn’t always follow the prim and proper science of a CS classroom.

Aung Myat Moe theaungmyatmoe

🐙
Real life doesn’t always follow the prim and proper science of a CS classroom.
View GitHub Profile
@theaungmyatmoe
theaungmyatmoe / dig.md
Last active March 12, 2021 12:01
Get all sub-domain list via `dig` command.

Find all sub-domain via dig command in Linux.

dig google.com ANY
@theaungmyatmoe
theaungmyatmoe / lifo.js
Last active June 22, 2021 13:23
Last In Fast Out Algorithm (Stack Memory)
// stack memory
let stack = [];
// top pointer
let top = 0;
// maximum length of stack
let max_length = 5;
// insert data to the stack
const push = (element) => {
// check the stack is full or no5
@theaungmyatmoe
theaungmyatmoe / debouncing.js
Last active October 9, 2021 18:55
Denouncing in JavaScript
const debounce = (callback, wait = 1000) => {
let timeoutId = null;
return function(...args) {
clearTimeout(timeoutId);
const next = () => callback.apply(this, args);
timeoutId = setTimeout(next, wait)
}
}
@theaungmyatmoe
theaungmyatmoe / useFetchApi.js
Created May 28, 2022 07:11
Using custom hook/composable to fetch data in nuxt3
/**
* It takes a URL and options, and returns a response object
* @param url - The URL to fetch.
* @param [options] - The options object that will be passed to the fetch function.
* @returns The return value of the useFetch hook.
*/
import {useFetch, useRuntimeConfig} from "nuxt/app";
export default function useFetchApi(url, options = {}) {
const config = useRuntimeConfig();
@theaungmyatmoe
theaungmyatmoe / useBaseFetch.js
Created May 28, 2022 13:20
Customization the $fetch hook to the easy to use hook that can use multiple http verbs
/**
* It's a wrapper around the `$fetch` function that allows you to pass in a URL and options object
* @param url {string} - The url to fetch
* @param [options] - {
* @example <caption> Example of useBaseFetch() in Nuxt app </caption>
* // returns response
* const response = await $fetch('/api/products', {
* method: 'POST',
* body: data,
* })
@theaungmyatmoe
theaungmyatmoe / Environment.js
Created August 20, 2022 18:38
Wuttyi Lang LL parsing
export default class Environment {
// create a variable environment (table of environment)
constructor(record = {}) {
this.record = record;
}
// set the variable to the env with the given name and value
define(name, value) {
this.record[name] = value;
@theaungmyatmoe
theaungmyatmoe / fn_overloading_solution.md
Created January 14, 2023 22:02
Typescript function overloading solution

Making immutable type with const in ts-v5

Playground Link

const makeRoles = <const T extends {role:string, flages:any}>(roles: T[]) => {
    return {
        findFlags<TRole extends T['role']>(roleToFind:TRole){
                return roles.find(role => role.role === roleToFind)?.flages as Extract<T, {role:TRole}>['flages']
@theaungmyatmoe
theaungmyatmoe / jwtRS256.sh
Created January 28, 2023 14:05 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@theaungmyatmoe
theaungmyatmoe / README.md
Created May 28, 2023 17:10
Fixing laravel passport deps issues
composer require laravel/passport --with-all-dependencies