Skip to content

Instantly share code, notes, and snippets.

View amitozdeol's full-sized avatar
🐢
Focusing

Amitoz Deol amitozdeol

🐢
Focusing
View GitHub Profile
function mockFetch(config: { data?: any; headers?: any; json?: boolean; blob?: boolean; text?: boolean | string; status?: any; statusText?: string; error?: object | string; delay?: boolean }) {
const { data, headers, json = false, blob = false, text = false, status = 200, statusText = 'Success', error = '', delay = false } = config;
if (status >= 400) {
return jest.fn().mockImplementation(() => Promise.reject(error));
}
const local_headers = { 'Content-type': 'application/json' };
const res = new window.Response(data, {
status,
statusText,
headers: headers && Object.keys(headers).length === 0 ? local_headers : headers,
@amitozdeol
amitozdeol / Mixin.ts
Last active May 27, 2020 14:00
Use multiple mixins in Vue typescript component
import { VueConstructor } from 'vue/types/umd';
//To use just extend with mixin variable
export default (Vue as VueConstructor<
Vue &
InstanceType<typeof mixin1> &
InstanceType<typeof mixin2>
>).extend({
mixins: [mixin1, mixin2]
@amitozdeol
amitozdeol / npm.md
Last active April 26, 2020 12:07
NPM advance commands
  1. Use npx instead of npm
    1. Instead of using node ./node_modules/typescript/bin/tsc use npx tsc
  2. Pass parameter in npm
    1. If we have a script called tsc to run typescript, tsc --build --clean --> npm run tsc -- --build --clean
  3. Shortcut scripts
    1. npm test --> npm run test
    2. npm start --> npm run start
    3. npm stop --> npm run stop
  4. Pre/Post script hooks - NPM have pre and post scripts that run before and after a script is run
  5. If we have 3 script in package.json "preecho": "echo pre", "echo": "echo now" "postecho": "echo post", it will run all 3 scripts when run --> npm run echo
@amitozdeol
amitozdeol / m-p.css
Created November 3, 2019 23:08
Margin and padding classes from bootstrap 4
/* Margin and Padding */
.m-0 {
margin: 0!important
}
.mt-0,.my-0 {
margin-top: 0!important
}
.mr-0,.mx-0 {
@amitozdeol
amitozdeol / Elements.md
Last active April 22, 2019 14:52
10 rarely used HTML elements

blockquote - effectively all browsers (since IE6+, Firefox 2+, Chrome 1+ etc)

output - all (as far as w3schools goes)

picture - all except for IE11, Blackberry browser, IE Mobile and Opera Mini

progress - all ("iOS Safari does not support "indeterminate" elements.")

meter - all except for IE and IE Mobile

@amitozdeol
amitozdeol / gist:b8c723811f106e6eea577572e19ba786
Last active October 4, 2019 16:01
Change PHP version in homestead

Update the default php version to whatever version of php in homestead box

sudo update-alternatives --config php

@amitozdeol
amitozdeol / cookie.js
Created December 27, 2018 16:24 — forked from bronson/cookie.js
Read and write cookies from javascript. Small and simple.
@amitozdeol
amitozdeol / ValetSwitchPHP.md
Created December 21, 2018 15:42 — forked from bgarrant/ValetSwitchPHP.md
How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

Valet switch PHP version with these commands

Install PHP 5.6 and switch Valet to PHP 5.6

valet stop
brew unlink php71
brew install php56
brew install php56-mcrypt
@amitozdeol
amitozdeol / normalize.css
Created October 15, 2018 19:51
Normalize css file
/*! minireset.css v0.0.3 | MIT License | github.com/jgthms/minireset.css */
html,
body,
p,
ol,
ul,
li,
dl,
dt,
dd,
@amitozdeol
amitozdeol / SystemFont.css
Last active August 30, 2018 17:40
System font
div{
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}