This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { isObject, isFunction } = require('lodash') | |
const { cond, identity, T } = require('ramda') | |
const makeDescriptor = cond([ | |
[isFunction, value => ({ get: value })], | |
[isObject, identity], | |
[T, value => ({ get: () => value })] | |
]) | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Joi = require('joi') | |
const ensureJoiSchema = schema => (req, res, next) => { | |
Joi.validate(req.body, schema, (err, value) => { | |
if (err) { | |
res.json(err, 400) | |
next(false) | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dic = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | |
const randomInt = (max = 1000, min = 0) => Math.floor(Math.random() * (max - min)) + min | |
const randomString = () => dic.charAt(randomInt(dic.length -1, 0)) | |
const makeArray = (length, cb) => Array.from({ length }, cb) | |
const makeArrayOfStrings = length => makeArray(length, randomString) | |
const joiArr = lists => lists | |
.reduce((acc, arr) => { | |
return `${acc}${arr.join('')}` | |
}, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import c3 from 'c3' | |
import { debounce, cloneDeep, defaultsDeep } from 'lodash' | |
export default { | |
name: 'c3-chart', | |
props: { | |
config: { | |
type: Object, | |
default: () => ({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
["env", { | |
"modules": false, | |
"targets": { | |
"browsers": "last 2 versions" | |
} | |
}], | |
"stage-2" | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parseResponse = ({ data }) => { | |
if (data.error === true) { | |
return Promise.reject(data) | |
} | |
return data | |
} | |
const http = axios.create({ }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { deburr, sortBy } from 'lodash' | |
const sanitizeAndLower = value => deburr(value).toLowerCase() | |
// | |
const sortByString = (list, key) => sortBy(list, x => sanitizeAndLower(x[key])) | |
const sortByName = list => sortByString(list, 'name') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xinput list --short | grep Logitech | awk '{print $5}' | cut -f2 -d"=" | xargs -I id xinput set-prop id "Device Accel Constant Deceleration" 0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Vue => { | |
Vue.mixin({ | |
created () { | |
const { title } = this.$options | |
if (title !== undefined) { | |
this.$title = title | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { identity } from 'lodash' | |
import waith from './waith' | |
export default (action, repetitions, timeToWaith = 3000) => { | |
const onError = counter => () => { | |
if (counter < repetitions) { | |
return run(counter + 1) | |
} | |
return Promise.reject(new Error('TRIES_FAILURE')) |