Skip to content

Instantly share code, notes, and snippets.

@rcdexta
rcdexta / Pollable.js
Created August 12, 2018 08:02
Pollable HOC
import React from 'react'
const Pollable = (intervalDurationInSeconds = 60) => {
return Component =>
class extends React.Component {
componentDidMount() {
this.startPolling()
}
@rcdexta
rcdexta / BitcoinTicker.js
Created August 12, 2018 08:34
BitcoinTicker
import React, { Component } from "react";
import Pollable from "@bit/rcdexta.hoc.components.pollable";
class BitcoinTicker extends Component {
state = { value: null, lastUpdated: null };
componentDidMount() {
this.props.onInterval(this.refresh);
}
PUT http://localhost:9200/crm_app
{
"settings": {
"index": {
"analysis": {
"filter": {},
"analyzer": {
"analyzer_keyword": {
"tokenizer": "keyword",
"filter": "lowercase"
fullName shortCode createdDate
Rachel Karen Green RKG10 2018-10-10
Monica Eustace Geller MEG52 2018-01-12
Ross Eustace Geller REG12 2018-02-21
Chandler Muriel Bing CMB14 2018-02-21
Phoebe Buffay PBF01 2018-04-12
Joey Francis Tribbiani JFT99 2018-05-15
POST http://localhost:9200/crm_app/customers
{
"fullName": "Rachel Karen Green",
"shortCode": "RKG10",
"createdDate": "2018-10-10"
}
POST http://localhost:9200/crm_app/customers/_search
{
"query": {
"match": {
"fullName": "geller"
}
},
"sort": ["_score", {"createdDate": "desc"}]
}
POST http://localhost:9200/crm_app/customers/_search
{
"query": {
"match": {
"fullName": "geller"
}
}
POST http://localhost:9200/crm_app/customers/_search
{
"query": {
"multi_match": {
"query": "CMB14",
"fields": ["fullName", "shortCode"]
}
},
"sort": ["_score", {"createdDate": "desc"}]
}
import React from 'react'
import ReactDOM from 'react-dom'
import Autosuggest from 'react-autosuggest'
import axios from 'axios'
import { debounce } from 'throttle-debounce'
import './styles.css'
class AutoComplete extends React.Component {
state = {
@rcdexta
rcdexta / TodoListItem.jsx
Created October 9, 2018 00:28
TodoListItem
class TodoListItem extends React.Component {
static propTypes = {
item: PropTypes.object,
removeItem: PropTypes.func,
markTodoDone: PropTypes.func
}
onClickClose = () => {
const {index, removeItem} = this.props;