🔗
Table of contents
- Types should start with T:
const express = require("express"); | |
const bodyParser = require("body-parser"); | |
const app = express(); | |
const port = 3000; | |
app.use(bodyParser()); | |
const USER_EMAIL = "[email protected]"; | |
const USER_PASSWORD = "123"; |
module.exports = { | |
meta: { | |
type: "suggestion", | |
docs: { | |
description: "Enforce allowed child types for custom components", | |
category: "Best Practices", | |
recommended: true, | |
}, | |
}, | |
create(context) { |
export const interceptor = async () => { | |
const { fetch: originalFetch } = window; | |
window.fetch = async (...args) => { | |
let [resource, config] = args; | |
const URLcutOff = "https://myapi.com"; | |
const trailing = resource.slice(URLcutOff.length); | |
console.log(trailing); | |
if (trailing.startsWith("/posts")) { | |
resource = `https://myapi.com`; | |
} |
import { ImageResponse } from '@vercel/og'; | |
import { NextRequest } from 'next/server'; | |
export const config = { | |
runtime: 'edge', | |
}; | |
const padZero = (str: string, len = 2) => { | |
const zeros = new Array(len).join('0'); | |
return (zeros + str).slice(-len); |
function serverObjectsSanitizer<T>(input: T, ignoreList: string[]): T { | |
if (Array.isArray(input)) | |
return input.map((i) => | |
serverObjectsSanitizer(i, ignoreList) | |
) as unknown as T; | |
if (typeof input == 'object' && input != null) | |
return Object.keys(input).reduce((t, c) => { | |
const before = input[c]; | |
if (ignoreList.indexOf(c) > -1) { | |
delete t[c]; |
function isValidIranianNationalCode(input) { | |
if (!/^\d{10}$/.test(input)) | |
return false; | |
var check = parseInt(input[9]); | |
var sum = 0; | |
var i; | |
for (i = 0; i < 9; ++i) { | |
sum += parseInt(input[i]) * (10 - i); | |
} |
# Install-Module PANSIES -AllowClobber | |
# Install-Module PowerLine | |
# lets set the powerline in this profile | |
Import-Module PowerLine | |
# aux variables | |
$ERRORS_COUNT = 0 | |
$ERROR_EMOJI = "😖", "😵", "🥴", "😭", "😱", "😡", "🤬", "🙃", "🤔", "🙄", ` | |
"🥺", "😫", "💀", "💩", "😰" |
import axios from 'axios'; | |
import {useCallback, useEffect, useState} from 'react'; | |
const useApi = (url, method, data = {}, options = {}) => { | |
const [response, setResponse] = useState(null); | |
const [loading, setLoading] = useState(true); | |
const fetch = useCallback(async () => { | |
const req = await axios({url, method, data, ...options}); |
import axios from 'axios'; | |
import React from 'react'; | |
const useTable = (url, initialParams) => { | |
const [data, setData] = React.useState([]); | |
const [loading, setLoading] = React.useState(false); | |
const [filters, setFilters] = React.useState({}); | |
const [pagination, setPagination] = React.useState({ | |
pageSizeOptions: ['5', '10', '20', '30', '100'], | |
defaultPageSize: 5, |