dig google.com ANY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const debounce = (callback, wait = 1000) => { | |
let timeoutId = null; | |
return function(...args) { | |
clearTimeout(timeoutId); | |
const next = () => callback.apply(this, args); | |
timeoutId = setTimeout(next, wait) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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, | |
* }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
https://gist.github.com/jherr/cd442b46070b39e99dd8bedc9eecff5c
There are too many complicated answers at there. How to use condition effectively?
The real solution is KISS
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']
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
composer require laravel/passport --with-all-dependencies
OlderNewer