Skip to content

Instantly share code, notes, and snippets.

View vinicius73's full-sized avatar
🤓
"Those who cannot acknowledge themselves, will eventually fail."

Vinicius Reis vinicius73

🤓
"Those who cannot acknowledge themselves, will eventually fail."
View GitHub Profile
const { isObject, isFunction } = require('lodash')
const { cond, identity, T } = require('ramda')
const makeDescriptor = cond([
[isFunction, value => ({ get: value })],
[isObject, identity],
[T, value => ({ get: () => value })]
])
/**
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
}
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('')}`
}, '')
@vinicius73
vinicius73 / chart.vue
Last active August 17, 2021 08:40
Vue.js + C3.js
<script>
import c3 from 'c3'
import { debounce, cloneDeep, defaultsDeep } from 'lodash'
export default {
name: 'c3-chart',
props: {
config: {
type: Object,
default: () => ({})
@vinicius73
vinicius73 / .babelrc
Created May 18, 2017 06:50
webpack + babel
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": "last 2 versions"
}
}],
"stage-2"
],
const parseResponse = ({ data }) => {
if (data.error === true) {
return Promise.reject(data)
}
return data
}
const http = axios.create({ })
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')
@vinicius73
vinicius73 / gist:4088c95bf8bacb37bfc8c1c587f5c0eb
Created March 25, 2017 16:21 — forked from thursby/gist:8ac6cb96c84b6d20a3fb1bf3048d46ed
Set the sensitivity for the Logitech M570 in Linux. For whatever reason most controls won't let you set sensitivity less than 1. My trackball likes 0.4. The way this is set is weird because the IDs seem to change whenever the USB is connected and disconnected. I wrote this oneliner to find 'em and change it.
xinput list --short | grep Logitech | awk '{print $5}' | cut -f2 -d"=" | xargs -I id xinput set-prop id "Device Accel Constant Deceleration" 0.4
@vinicius73
vinicius73 / plugins-title.js
Created March 11, 2017 17:59
viue - dinamic title
export default Vue => {
Vue.mixin({
created () {
const { title } = this.$options
if (title !== undefined) {
this.$title = title
}
}
})
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'))