Skip to content

Instantly share code, notes, and snippets.

View amitozdeol's full-sized avatar
🐢
Focusing

Amitoz Deol amitozdeol

🐢
Focusing
View GitHub Profile
@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 / 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 / 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]
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,