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 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"; |
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
module.exports = { | |
meta: { | |
type: "suggestion", | |
docs: { | |
description: "Enforce allowed child types for custom components", | |
category: "Best Practices", | |
recommended: true, | |
}, | |
}, | |
create(context) { |
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 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`; | |
} |
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
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); |
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
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]; |
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
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); | |
} |
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
# Install-Module PANSIES -AllowClobber | |
# Install-Module PowerLine | |
# lets set the powerline in this profile | |
Import-Module PowerLine | |
# aux variables | |
$ERRORS_COUNT = 0 | |
$ERROR_EMOJI = "😖", "😵", "🥴", "😭", "😱", "😡", "🤬", "🙃", "🤔", "🙄", ` | |
"🥺", "😫", "💀", "💩", "😰" |
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
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}); |
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
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, |
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
import React from 'react'; | |
import {DatePicker} from 'antd'; | |
import moment from 'moment-jalaali'; | |
export default function PersianDatePicker() { | |
var locale = { | |
"lang": { | |
locale: 'fa_IR', |
NewerOlder