Skip to content

Instantly share code, notes, and snippets.

set verdaccio as npm registry:

npm set registry http://localhost:4873/

what is my curent npm registry(your terminal must not be open in a .npmrc folder)

 npm config get  registry

how to return to normal npm registry?

@shahab65
shahab65 / git.md
Last active November 15, 2020 20:45

whatching our global git setting in default editor:

git config --global -e

setting default editor:

git config --global diff.tool vscode

setting end of line:

@shahab65
shahab65 / handy.md
Last active November 22, 2020 20:20
import { useTranslation } from "react-i18next";
  const { t } = useTranslation();
{t("Prepaid")}

import { makeStyles } from "@material-ui/core/styles";
import { createUseStyles } from "react-jss";

function with if in styled components

const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
  ${() => {
    let a = 1 + 2 + 3 + 4;
    let b = a / 2;
 if (b < 6) {
@shahab65
shahab65 / ts.md
Last active October 4, 2020 13:46

ref

const divRef = React.useRef<HTMLDivElement>(null);
const myRef = React.useRef<HTMLElement | null>(null)

call back

interface Events {
  on(eventName: string, callback: () => void):void;

how to put element in vertical center of parent?

<div class={"parent"}>
  ...
  <div class={"child"}>
    ...
  </div>
</div>

vertical center:

function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max-min)) + min
  }

If we have multiple promises we could use Promise.all with await

async function asyncFunc() {
  const response = await Promise.all([
    axios.get("/some_url_endpoint"),
    axios.get("/some_url_endpoint")
  ]);
  ...
}
//import {Field, Form, Formik} from "formik";
// import * as Yup from "yup";

      <Formik
        enableReinitialize
        initialValues={calculatedFormInitialValues}
        validate={values => {
            let errors = {};
 if (values.responsible_user === "" &amp;&amp; values.responsible_department === "") {