Skip to content

Instantly share code, notes, and snippets.

View ndabAP's full-sized avatar
🔭

Julian Claus ndabAP

🔭
View GitHub Profile
@ndabAP
ndabAP / User.vue
Created November 3, 2017 08:51
Decorators in Vue.js
<template>
<div>
<!-- User form -->
</div>
</template>
<script>
import User from 'src/decorators/UserDecorator'
export default {
@ndabAP
ndabAP / random.js
Last active June 26, 2018 07:17
Random alphabetical string with JavaScript
/**
* @see {@url https://stackoverflow.com/questions/30452263/is-there-a-mechanism-to-loop-x-times-in-es6-ecmascript-6-without-mutable-varia#answer-30452949}
*/
const times = x => f => {
if (x > 0) {
f()
times (x - 1) (f)
}
}
@ndabAP
ndabAP / app.js
Created October 24, 2017 14:16
Creating async functions in JavaScript
const a = () => {
return new Promise(resolve => {
console.log('a')
resolve(1)
})
}
const b = () => {
return new Promise(resolve => {
console.log('b')
@ndabAP
ndabAP / test.spec.js
Last active April 25, 2019 11:43
Mock computed property of Vue.js mixin
import Vue from 'vue'
import 'babel-polyfill'
import Component from '~/components/Component'
import {
mount
} from 'vue-test-utils'
import sinon from 'sinon'
import {
assert
} from 'chai'
@ndabAP
ndabAP / main.js
Last active August 3, 2017 10:08
Load mobile/desktop version of your Vue.js application based on browser width
// main.js is your Webpack entry point. "bootstrap.desktop" and "bootstrap.mobile" load dependencies based on the browser width
/**
* @see {@link https://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code#1038781}
*/
const browserWidth = Math.max(
document.body.scrollWidth,
document.documentElement.scrollWidth,
document.body.offsetWidth,
document.documentElement.offsetWidth,
@ndabAP
ndabAP / SomeController.js
Last active June 28, 2017 04:52
Use nested services instead of helpers within Sails.js 1.0
// api/controllers/SomeController.js
module.exports = {
/**
* @param req
* @param res
*/
create: (req, res) => {
let love = sails.services.SomeService.getLove()