Skip to content

Instantly share code, notes, and snippets.

View highercomve's full-sized avatar
🏠
Working from home for Pantacor 👍

Sergio Marin highercomve

🏠
Working from home for Pantacor 👍
View GitHub Profile
import React from 'react'
import useValidatedForm from 'react-valida-hook'
const initialState = {
firstName: '',
lastName: '',
email: ''
}
const validations = [
import React from 'react'
import useValidatedForm from 'react-valida-hook'
const initialState = {
firstName: '',
lastName: '',
email: ''
}
const validations = [
@highercomve
highercomve / hook.js
Last active February 14, 2019 14:51
Creating Form validations with hooks
export default function useValidatedForm (fields = {}, descriptors = [], validators = ValidaJS.validators) {
const initialErrorsObj = emptyErrorFactory(fields)
const initialState = stateFactory(fields)
const [state, setState] = useState(initialState)
const [validation, setValidation] = useState({ valid: true, errors: initialErrorsObj })
const rulesBy = rulesByNameFactory(descriptors, validators)
const form = formDataFactory(state, setState, setValidation, validation, rulesBy)
const getData = () => getDataFromState(state)
const setData = (data) => setState(stateFactory(data))
import _chain from 'pipeable'
function WorkerWrapper () {
var poster = function (data) {
importScripts(data.funcFileUrl)
data.params.length = Object.keys(data.params).length
postMessage(workerCallBack.apply(null, Array.from(data.params)))
}
onmessage = function (e) {
poster(e.data)
// this file is not scope. You must use it inside a anonymus function and save in windows RandomList and RandomList2 or export those
function createWeightedList (list, weight) {
var weighed_list = [];
for (var i = 0; i < weight.length; i++) {
var multiples = weight[i] * 100;
for (var j = 0; j < multiples; j++) {
weighed_list.push(list[i]);
}
}

I am deploying with this IAM using Codeship and Circle CI to Elastic Beanstalk. I had a lot of trouble with this config. I talked to the aws support for about 6 hours until this worked properly, so, I guess it is worth to share.

UPDATE: In the end, I have to use the AWSElasticBeanstalkFullAccess policy. My custom policy keep breaking every week with some new added permission or some EB internal change. Anyway, the IAM I was using is below.

This works for me with CircleCI and EB Cli.

{
    "Version": "2012-10-17",
    "Statement": [
        {
@highercomve
highercomve / docker-compose-daemon.sh
Created October 10, 2016 16:14 — forked from domachine/docker-compose-daemon.sh
run docker-compose in daemon mode and attach to web container
docker-compose up -d
docker attach myapp_web_1
@highercomve
highercomve / object_resolve.js
Last active March 11, 2019 20:37
Object path resolution even thought some part get undefined
function resolve (obj, path, defaultReturn) {
return path.split('.').reduce(function(prev, curr) {
return prev && prev.hasOwnProperty(curr) ? prev[curr] : defaultReturn
}, obj)
}

A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road.

Array A contains only 0s and/or 1s:

0 represents a car traveling east, 1 represents a car traveling west. The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P < Q < N, is passing when P is traveling to the east and Q is traveling to the west.

For example, consider array A such that:

@highercomve
highercomve / base_gateway_api.rb
Created May 5, 2016 03:38
Ruby example files
module Gateways
class Base
class << self
def find_all_and_update
raise NotImplementedError
end
def create
raise NotImplementedError
end