Skip to content

Instantly share code, notes, and snippets.

View cristijora's full-sized avatar

Cristi Jora cristijora

View GitHub Profile
const fs = require('fs')
const path = require('path')
const data = fs.readFileSync(path.join(__dirname, 'input.txt'), 'utf-8')
const rows = data.split('\n').filter(r => r !== '')
const matrix = rows.map(row => {
return row.split('').map(cell => {
if (cell === '.') {
return '.'
}
import Vue from 'vue'
new Vue({
el: '#app',
data(){
return {
vueMessage: 'Message from Vue'
}
}
})
@cristijora
cristijora / collapse.js
Created August 26, 2019 09:49
Collapse menus Vue Paper Dashboard PRO
// SidebarPlugin/index.js
const SidebarStore = {
// other code,
linksStore: [],
addSidebarLink(link) {
this.linksStore.push(link)
},
removeSidebarLink(link) {
const index = this.sidebarLinks.indexOf(link)
this.linksStore.splice(index, 1)
@cristijora
cristijora / Dropdown.vue
Last active July 11, 2019 19:09
Dropdown parent access
// Dropdown.vue (parent)
<template>
<div>
<button @click="showMenu = !showMenu">Click me</button>
<dropdown-menu v-if="showMenu" :items="items"></dropdown-menu>
</div>
<template>
<script>
export default {
@cristijora
cristijora / Product.vue
Last active July 11, 2019 19:07
Mutate nested props
<template>
<div class="hello">
<div>Name: {{product.name}}</div>
<div>Price: {{product.price}}</div>
<div>Stock: {{product.stock}}</div>
<button @click="addToCart" :disabled="product.stock <= 0">Add to card</button>
</div>
</template>
<template>
<div>
<input placeholder="Email" type="email" v-model="form.email"/>
<input placeholder="Name" v-model="form.name"/>
<button @click="onSave">Save</button>
<button @click="onCancel">Save</button>
</div>
</template>
<script>
export default {
// Parent
<template>
<div>
<span> Email {{user.email}}</span>
<span> Name {{user.name}}</span>
<user-form :user="user" @submit="updateUser"/>
</div>
</template>
<script>
// Dropdown.vue (parent)
<template>
<div>
<button @click="showMenu = !showMenu">Click me</button>
<dropdown-menu v-if="showMenu" :items="items" @select-option="onOptionSelected"></dropdown-menu>
</div>
<template>
<script>
export default {
// Dropdown.vue (parent)
<template>
<div>
<button @click="showMenu = !showMenu">Click me</button>
<transition name="fade">
<dropdown-menu v-if="showMenu" :items="items"></dropdown-menu>
</dropdown-menu>
</div>
<template>
@cristijora
cristijora / Product2.vue
Last active July 11, 2019 15:55
Mutating props
<template>
<Product :product="product" @add-to-cart="addProductToCart(product)"></Product>
</template>
<script>
import Product from "./components/Product";
export default {
name: "App",
components: {