Skip to content

Instantly share code, notes, and snippets.

View matthewblewitt's full-sized avatar

Matt Blewitt matthewblewitt

View GitHub Profile
@matthewblewitt
matthewblewitt / npm-checklist.md
Created November 29, 2018 12:00
npm checklist
  1. Always use latest npm via npm install -g npm@latest
  2. Make distinction between dependencies and devDependencies
  3. Use reproducible builds via npm ci (requires lockfiles on all projects)
  4. Exclude devDependencies from production builds using npm ci --production
  5. Regularly review npm audit reports and make production issues a release blocker
const thing = (obj && obj.thing && obj.thing.stuff) || '';
@matthewblewitt
matthewblewitt / find-duplicates-in-array.js
Last active April 24, 2019 14:22
Find duplicates in a array with array filter method
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const fibonacci = [0, 1, 1, 2, 3, 5, 8, 13];
const duplicates = numbers.filter(number => fibonacci.indexOf(number) !== -1);
console.log(duplicates); // [1, 2, 3, 5, 8]
@matthewblewitt
matthewblewitt / attach-to-node-docker.js
Created April 26, 2019 08:29
VS-CODE attache to node docker
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Docker",
"port": 5100,
"address": "localhost",
"restart": true,
@matthewblewitt
matthewblewitt / deep-clone-js-object.js
Created April 26, 2019 10:46
Deep clone JS object
const obj = {
prop: 'val'
};
const clone = JSON.parse(JSON.stringify(obj));

// Test

@matthewblewitt
matthewblewitt / vue-notes.md
Last active June 11, 2019 18:18
Vue notes

Directives

  • v-bind/:: Pass data from vue instance to html
  • v-on/@: Listen for DOM events e.g. v-on:click="doSomething"
  • v-once: Only render once
  • v-html: Output raw html

We cannot use {{}} syntax inside a html element, use a directive instead e.g:

<a v-bind:href="link">My Link</a>
@matthewblewitt
matthewblewitt / vue-util.js
Last active August 20, 2019 10:15
Vue util cheat sheet
import { mount, createLocalVue } from "vue-test-utils";
import { actions, mutations } from "~/test/mocks/store-actions-mutations.mock";
import Component from "~/pages/index.vue";
import Vuex from "vuex";
const localVue = createLocalVue();
localVue.use(Vuex);
const store = new Vuex.Store({ state, mutations, actions });
const cmp = mount(Component, {
store,
@matthewblewitt
matthewblewitt / style.css
Created September 5, 2019 07:30
CSS Outline
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
* * * * * * * { background-color: rgba(255,0,0,.2); }
* * * * * * * * { background-color: rgba(0,255,0,.2); }
* * * * * * * * * { background-color: rgba(0,0,255,.2); }
@matthewblewitt
matthewblewitt / .eslintrc.js
Created December 3, 2019 11:39
Vue CLI + ESLint + Prettier + Fix on save
module.exports = {
root: true,
env: {
node: true
},
extends: [
"plugin:vue/recommended",
"eslint:recommended",
"prettier/vue",
"plugin:prettier/recommended"