Skip to content

Instantly share code, notes, and snippets.

View milantarami's full-sized avatar
💭
building apps.

Milan Tarami milantarami

💭
building apps.
View GitHub Profile
@milantarami
milantarami / schema.js
Created November 18, 2022 12:07 — forked from JoaoCnh/schema.js
Yup conditional validation
Yup.object().shape({
email: Yup.string().email('Invalid email address').required('Email is required!'),
username: Yup.string().required('This man needs a username').when('email', (email, schema) => {
if (email === 'foobar@example.com') { return schema.min(10); }
return schema;
}),
});
@milantarami
milantarami / laraws_nginx.md
Created September 18, 2022 18:38 — forked from ErxrilOwl/laraws_nginx.md
Deploy Laravel on AWS EC2 Ubuntu (nginx)
@milantarami
milantarami / avatar.js
Created September 1, 2022 04:58 — forked from gauravsoti1/avatar.js
Styling Material Ui's Avatar for a project to have different size which adjusts according to screen sizes. Also, gutter spacing on left and right. Libraries: React, material ui, styled-components
import React from "react";
import styled, { css } from "styled-components";
import { Avatar } from "@material-ui/core";
// -------------------------- Defining all the css sizes ------------------------
export const SmallestSizeCSS = css`
width: 30px;
height: 30px;
${props => props.theme.breakpoints.up("lg")} {
@milantarami
milantarami / .php-cs-fixer.dist.php
Created June 18, 2022 05:16 — forked from tabacitu/.php-cs-fixer.dist.php
PHP-CS-Fixer Configuration File for the Laravel Code Style
<?php
/**
-----------------------------------------------------
Enforce the Laravel Code Style using PHP CS Fixer 3.x
-----------------------------------------------------
Credits go to Laravel Shift & Andreas Elia.
https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@milantarami
milantarami / localStorageHelpers.js
Created February 24, 2021 08:51 — forked from scrubmx/localStorage.js
Helper functions for localStorage
if( typeof(Storage) === 'undefined' ) {
// Sorry! No Web Storage support...
}
/**
* Check if key exists in local storage
* @param string key
* @return boolean
*/
function localStorageHas (key) {
@milantarami
milantarami / axios.refresh_token.1.js
Created February 24, 2021 06:43 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@milantarami
milantarami / yup-with-final-form.js
Last active November 3, 2022 09:33 — forked from manzoorwanijk/yup-with-final-form.js
How to properly use yup validation schema with (React) Final Form?
import * as yup from 'yup';
import { setIn } from 'final-form';
const validationSchema = yup.object({
email: yup.string().email(),
shipping: yup.object({
name: yup.string(),
phone: yup.object({
code: yup.string().matches(/^\+\d+$/i),
number: yup.number().max(10),
@milantarami
milantarami / domIsReady.js
Created April 1, 2019 11:28 — forked from devbyray/domIsReady.js
Vanilla JavaScript Document Ready (Cross-Browser)
var domIsReady = (function(domIsReady) {
var isBrowserIeOrNot = function() {
return (!document.attachEvent || typeof document.attachEvent === "undefined" ? 'not-ie' : 'ie');
}
domIsReady = function(callback) {
if(callback && typeof callback === 'function'){
if(isBrowserIeOrNot() !== 'ie') {
document.addEventListener("DOMContentLoaded", function() {
return callback();
@milantarami
milantarami / meta-tags.md
Created March 26, 2019 02:40 — forked from prayas-sapkota/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>