Skip to content

Instantly share code, notes, and snippets.

View carlosvega20's full-sized avatar

Carlos Vega carlosvega20

  • San Francisco, CA
View GitHub Profile
@carlosvega20
carlosvega20 / Counter.js
Last active November 1, 2016 14:15 — forked from gaearon/Counter.js
import React, { Component } from 'react';
const counter = (state = { value: 0 }, action) => {
switch (action.type) {
case 'INCREMENT':
return { value: state.value + 1 };
case 'DECREMENT':
return { value: state.value - 1 };
default:
return state;
@carlosvega20
carlosvega20 / slim-redux.js
Created December 11, 2015 06:17 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@carlosvega20
carlosvega20 / .js
Created September 24, 2015 21:56 — forked from hzhu/.js
Data Transformation
var x = [ {node: "ip2", app: "dbsyncer", containerId: "1234"},
{node: "ip2", app: "logforwa", containerId: "3423"},
{node: "ip4", app: "dbsyncer", containerId: "2213"},
{node: "ip4", app: "logforwa", containerId: "3434"} ]
var newObj = {};
x.forEach(function (item) {
newObj[item.node] = newObj[item.node] || [];