Skip to content

Instantly share code, notes, and snippets.

View EmilyRosina's full-sized avatar
🦄
Vue Nerd

Aurora Skye EmilyRosina

🦄
Vue Nerd
View GitHub Profile
@EmilyRosina
EmilyRosina / VSCode_ConsoleLogSnippet.json
Created November 21, 2018 11:53
Console.log with eslint-disable-line
{
"Console.log with eslint-disable-line": {
"prefix": "cl",
"body": [
"console.log(``, something) // eslint-disable-line no-console"
]
}
}
@EmilyRosina
EmilyRosina / transformPlugin.js
Last active October 29, 2018 20:18
Vue plugin to add helpers that transform obj from snake_cased keys to camelCased keys and back again.
import _ from 'lodash'
const transform = {
toCamelCase (obj) {
const camelCasedObj = {}
Object.keys(obj).forEach((key) => {
if (_.isPlainObject(obj[key])) camelCasedObj[_.camelCase(key)] = this.toCamelCase(obj[key])
else camelCasedObj[_.camelCase(key)] = obj[key]
})
return camelCasedObj
@EmilyRosina
EmilyRosina / swagger_endpoints.md
Last active October 22, 2018 19:02
Get all endpoints from swagger
const allEndpoints = document.querySelectorAll('.nostyle span')
let endpoints = {}

allEndpoints.forEach(endpoint => {
  if (endpoint.textContent.startsWith('/')) {
    const endpointName = endpoint.textContent.substring(1)
    const params = endpointName.split('/')
    const parent = params[0]
 const restOfName = endpointName.replace(parent, '')

App.vue

  ...
  created () {
    this.$store.commit('setBreakpoint', utils.breakpoint(window.innerWidth))
    window.addEventListener('resize', () => {
      const breakpoint = utils.breakpoint(window.innerWidth)
      if (!this.breakpointIs(breakpoint)) this.$store.commit('setBreakpoint', breakpoint)
    })
  }

in modules/index.js

  import camelCase from 'lodash/camelCase'
  const requireModule = require.context('.', false, /\.js$/)
  const modules = {}
  
  requireModule.keys().forEach(fileName => {
    // Don't register index.js
    if (fileName === './index.js') return
 

in main.js or utils/globalComponents.js

  import Vue from 'vue'
  import upperFirst from 'lodash/upperFirst' // could be vue.filter
  import camelCase from 'lodash/camelCase' // could be vue.filter

  // Require in a **base** component context
  // nb: you can use any prefix you want instead of 'base' below
 const requireComponent = require.context('.', false, /base-[\w-]+\vue$/)
@EmilyRosina
EmilyRosina / setting_up_vue_projects.md
Last active July 6, 2018 11:25
How i like to setup my vue projects

update vue-cli

  vue-cli update -g

create project

  vue init webpack my-project