Skip to content

Instantly share code, notes, and snippets.

View brunoluiz's full-sized avatar
🤌

Bruno Luiz Silva brunoluiz

🤌
View GitHub Profile
@brunoluiz
brunoluiz / local-store.js
Created January 9, 2018 01:11
local-store.js
export const getState = (key) => {
try {
const state = window.localStorage.getItem('state')
const data = (state)
? JSON.parse(state)
: undefined
if (!data) return undefined
@brunoluiz
brunoluiz / .env.development
Last active November 28, 2017 23:44
medium-botframework-part1-echobot-app
NODE_ENV=development
PORT=80
APP_ID=
APP_SECRET=
@brunoluiz
brunoluiz / Dockerfile
Created November 28, 2017 22:06
medium-botframework-part1-dockerconfigs
FROM node:8.4.0
# Default NODE_ENV should be production (but it can be overwritten by a parameter)
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
# Default port should be 80 (but it can be overwritten by a parameter)
ARG PORT=80
ENV PORT $PORT
EXPOSE $PORT
@brunoluiz
brunoluiz / Freight with Macroregion tests (simple scenarios).md
Last active November 18, 2017 02:08
Freight with Macroregion tests (simple scenarios)

Freight with Macroregion tests (simple scenarios)

The following freight request was in two test cases with different zipcodes. The items BRUNO-SKU-SP-3 and BRUNO-SKU-SP-4 were created at location 0098 (SP).

{
        "destinationZipcode": "{{ zipcode }}",
        "clientId": "centauro",
        "channelId": "site",
        "groups": {
@brunoluiz
brunoluiz / deploy.sh
Last active May 10, 2018 19:58
Inventory deploy
cd ~/git/newoffers-infra/ansible
git checkout master
git pull --all
source .venv-ansible2/bin/activate
# Set the version here
VERSION=chub-1859.001
@brunoluiz
brunoluiz / joi-from-doc.js
Last active August 24, 2017 03:58
joi-from-doc.js
const Joi = require('joi')
const schema = Joi.object().keys({
a: Joi.any()
.valid('x')
.when('b', {
is: 5,
then: Joi.valid('y'),
otherwise: Joi.valid('z')
}),
const Joi = require('joi')
module.exports = Joi.extend({
name: 'object',
base: Joi.object().keys({
extensionAttributes: Joi.object(),
updatedAt: Joi.date().default(Date.now)
})
})
const Joi = require('joi')
const ukzip = /^[A-Z]{1,2}[0-9]{1,2}[A-Z]{0,1} ?[0-9][A-Z]{2}$/i
module.exports = Joi.extend({
name: 'number',
base: Joi.number().strict()
}, {
name: 'zipcode',
base: Joi.regex(ukzip).description('UK Zipcode')
module.exports = {
email: Joi.string().email(),
title: Joi.string(),
content: Joi.binary(),
tags: vogels.types.stringSet(),
}
// rating.js
const mongoose = require('mongoose')
const joigoose = require('joigoose')(mongoose)
// Require the 'ratings' schema
const schema = require('./rating-schema')
// Convert joi to mongoose schema
const mongooseSchema = joigoose.convert(schema);