Skip to content

Instantly share code, notes, and snippets.

View iamdey's full-sized avatar

David Epely iamdey

View GitHub Profile
@iamdey
iamdey / README.md
Last active October 2, 2018 17:35
Promise vs Async
@iamdey
iamdey / createMessage.js
Created June 14, 2018 10:12
typing w/ flow
// @flow
import { createMessage as createMessageBase, requestMessage, addToCollection } from '../../../store/modules/message';
import { tryCatchAxiosAction } from '../../../services/api-client';
/* ::
type Message = {
message_id: string
}
*/
@iamdey
iamdey / minikube_installation.md
Created May 16, 2018 09:20
Caliopen minikube installation

Install dev env using minikube

Pre-requisites

WARNING

@iamdey
iamdey / Foo.jsx
Last active April 28, 2021 17:20
The pyramid of doom of the Render Prop react pattern
import React, { Component } from 'react'
import PropTypes from 'prop-types'
// ...
class Foo extends Component {
createHandleSearchChange = (tags) => terms =>
this.setState({ foundTags: whateverFindAlgo(tags, terms)})
handleAddTag = (updateEntityTags, entity, tag) => {
updateEntityTags(entity, [...entity.tags, tag])
@iamdey
iamdey / tab.js
Created November 24, 2017 08:31
currentab
import { createSelector } from 'reselect';
import { connect } from 'react-redux';
import { currentTabSelector } from '../store/selectors/tab';
const mapStateToProps = createSelector(
[currentTabSelector],
currentTab => ({
currentTab,
})
);
@iamdey
iamdey / favorite-address.js
Created September 7, 2017 08:16
Caliopen favorite address
favoriteAddressFilter = (addresses, searchTerms) => addresses.reduce((acc, address) => {
if (!acc) {
return address;
}
if (address.startsWith(searchTerms) && !acc.startsWith(searchTerms)) {
return address;
}
if (!acc.is_primary && address.is_primary === true) {
@iamdey
iamdey / caliopen-restart-full.sh
Created September 6, 2017 13:11
Caliopen drop data & restart full
#!/bin/bash
set +e
set -v
docker-compose stop
docker-compose rm
docker volume rm devtools_db devtools_index devtools_store
docker-compose up -d redis cassandra elasticsearch
sleep 20
@iamdey
iamdey / my-middleware.spec.js
Created August 16, 2017 12:54
how to unit test with jest a redux middleware with promises
// unit test of redux middleware w/ jest
import configureStore from './configure-store';
const middleware = store => next => (action) => {
if (action.type === 'FOO') {
Promise.resolve({ type: 'FOO_SUCCESS', payload: {} }).then(act => store.dispatch(act);
}
return next(action);
package http_middleware
import (
"encoding/base64"
"encoding/json"
"gopkg.in/gin-gonic/gin.v1"
"gopkg.in/redis.v5"
"net/http"
"strconv"
"strings"