Skip to content

Instantly share code, notes, and snippets.

View eirikb's full-sized avatar

Eirik Brandtzæg eirikb

  • Softeria AS
  • Ålesund, Norway
View GitHub Profile
@eirikb
eirikb / store.js
Created January 6, 2019 11:30
Auto Vuex mutations
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
function teenageAutoMutateTurtles(...props) {
return props.reduce((o, p) => (o[`set${p[0].toUpperCase()}${p.slice(1)}`] = (s, v) => s[p] = v) && o, {});
}
export default new Vuex.Store({
@eirikb
eirikb / 0-PXE-VDI-LTSP.md
Last active May 18, 2018 07:11
Host VDI / VMDK (VirtualBox images) directly over PXE (Network boot).

PXE Boot VDI/VMDK over network

This is an example script of how to host VDI / VMDK (VirtualBox images) directly over PXE (Network boot).  
Example relies on LTSP.  

Client

Can be any distro, but requires ltsp-client-core, example with Debian:

sudo apt-get -y install ltsp-client-core

@eirikb
eirikb / .sassrc.js
Created March 15, 2018 09:24
Demo of parcel + scss
const path = require('path');
const cwd = process.cwd();
module.exports = {
"includePaths": [
path.resolve(cwd, 'node_modules'),
path.resolve(cwd, 'src')
]
};
@eirikb
eirikb / Dockerfile
Created August 3, 2017 13:25
Arch Linux AUR in Docker
FROM base/archlinux
RUN pacman -Syu
RUN pacman -S --noconfirm git base-devel
WORKDIR /build
RUN useradd -d /build build-user
RUN echo "build-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN chown -R build-user /build
@eirikb
eirikb / load-vue-components-from-folder.js
Created May 24, 2017 19:24
Load all Vue components from a given folder, no need for an "index.js"-file
const req = require.context('./components/', true, /\.(js|vue)$/i);
req.keys().map(key => {
const name = key.match(/\w+/)[0];
return Vue.component(name, req(key))
});
@eirikb
eirikb / mdl-vue.js
Last active May 24, 2017 19:48
Add MDL to all elements with "mdl-js"-class in Vue
import 'material-design-lite'
Vue.mixin({
mounted() {
if (!this.$el || !this.$el.querySelectorAll) return;
componentHandler.upgradeElement(this.$el);
for (const el of this.$el.querySelectorAll('[class*=mdl-js-]')) {
if (!el.dataset.upgraded) {
componentHandler.upgradeElement(el);
@eirikb
eirikb / main.js
Created April 26, 2017 11:42
MDL in Vue2 hack
import Vue from 'vue';
import 'material-design-lite';
Vue.mixin({
mounted() {
for (const el of this.$el.querySelectorAll('[class*=mdl-js-]')) {
if (!el.dataset.upgraded) {
componentHandler.upgradeElement(el);
}
}
@eirikb
eirikb / Chart.vue
Created April 26, 2017 10:04
Chart.js in Vue2
<template>
<canvas ref="chart"></canvas>
</template>
<script>
import chart from 'chart.js'
export default {
props: ['options', 'data'],
@eirikb
eirikb / App.vue
Last active January 10, 2019 19:26
Add MDL to Vue
<style lang="scss">
@import "~material-design-lite/material.css";
</style>
@eirikb
eirikb / readme.md
Last active August 9, 2016 18:57
vuetwo demo
npm i
npm start

Result:
Result