Skip to content

Instantly share code, notes, and snippets.

Working from home

Cory Robinson crobinson42

Working from home
  • American Software
  • Northwest USA
View GitHub Profile
crobinson42 / pubsub.ts
Last active Jan 23, 2022 — forked from sidola/pubsub.ts
Basic typesafe pub-sub implementation in Typescript
View pubsub.ts
* Defines the function type of the publish function.
* Extracts the keys from `E` as valid event types, and the matching
* property as the payload.
type PubTypeFn<E> = <Key extends string & keyof E>(
event: Key,
fn: (message: E[Key]) => void
) => void
View ExtendedDataStore.js
const { DataStore } = require('js-data')
class ExtendedDataStore extends DataStore {
constructor(props) {
if (props.extends)
Object.assign(this, props.extends)
crobinson42 / 1.txt
Created Nov 20, 2019
Blog SEO rewrites
View 1.txt
Selling security guard services is admittedly not the sexiest of jobs, but with the right attitude and motivation you can do well both professionally and financially. In order to be great at security guard sales, or sales in general, it requires extensive reading and even more practice. One of the first books that I read and refer back to fairly regularly is The 25 Most Common Sales Mistakes and How to Avoid Them by Stephan Schiffman. Stephan is a Certified Management Consultant who has trained and consulted with corporations such as IBM, Motorola, and Cigna. He has trained over 500,000 professionals across 9,000+ companies. Of the 25 most common mistakes outlined in his book, there are 10 that are essential to anyone involved in security guard sales. I have taken the liberty of summarizing those 10 below.
Mastering Security Guard Sales
Security guard service is one of the most competitive industries that exists (if it isn’t it, sure does feel like it) and losing a sale can be the result of being a pen
crobinson42 / mongo-to-kafka.js
Last active Oct 11, 2019
Watch mongodb and publish to kafka
View mongo-to-kafka.js
NOTE: this is a naive first attempt at tailing mongo collections to publish kafka messages
and removed module imports and other stuff for brevity....
function normalizeMongoDocument(document) {
// convert "_id" to "id"
const normalized = { id: document._id, ...document }
delete normalized._id
crobinson42 / Example.jsx
Created Jul 8, 2019
JS-Data React Hook useStoreQuery(mapperName, query)
View Example.jsx
import React from 'react'
import useStoreQuery from './useStoreQuery'
const ActiveUsers = ({ storeQuery, storeQueryLoading }) => {
const { users, loading } = useStoreQuery('users', { where: { active: true } })
return (
<div>{loading ? 'Loading...' : `${users.length} active users found`}</div>
View js-data-react.jsx
/* eslint-disable react/no-multi-comp, react/prop-types */
import React from 'react'
import hoistNonReactStatic from 'hoist-non-react-statics'
import shallowEqual from '../utils/shallowEqual'
function ConnectModelsHOC({ loadingProp, modelName, modelNames }, mapPropsWithModels) {
return WrappedComponent => {
class ConnectModels extends React.Component {
static contextType = ''
crobinson42 / error
Created Mar 27, 2019
kafka-node refreshMetadataError
View error
kafka-node:KafkaClient Connect attempt 1 +0ms
kafka-node:KafkaClient Trying to connect to host: port: 9092 +3ms
kafka-node:KafkaClient kafka-node-client createBroker +1ms
kafka-node:KafkaClient kafka-node-client sending versions request to +902ms
kafka-node:KafkaClient broker socket connected {"host":"","port":"9092"} +3ms
kafka-node:KafkaClient connected to socket, trying to load initial metadata +2ms
kafka-node:KafkaClient missing apiSupport waiting until broker is ready... +1ms
kafka-node:KafkaClient waitUntilReady [BrokerWrapper (connected: true) (ready: false) (idle: false) (needAuthentication: false) (authenticated: false)] +1ms
kafka-node:KafkaClient Received versions response from +69ms
kafka-node:KafkaClient setting api support to {"21":{"min":0,"max":1,"usable":false},"22":{"min":0,"max":1,"usable":false},"23":{"min":0,"max":2,"usable":false},"24":{"min":0,"max":1,"usable":false},"25":{"min":0,"max
crobinson42 / ReactotronConfig.js
Created Dec 31, 2018
Reactotron react-native config - redux implementation locking up up
View ReactotronConfig.js
import Reactotron from 'reactotron-react-native';
import sagaPlugin from 'reactotron-redux-saga';
import { reactotronRedux } from 'reactotron-redux';
import envLocal from './.local.json';
export default () => Reactotron
// your local IP goes in .env.local.json (which is in .gitignore)
.configure({ host: envLocal.ip })
// .use(sagaPlugin())
crobinson42 / index.html
Created Dec 29, 2018
Axios file upload progress indicator
View index.html
<title>Axios Progress Upload</title>
<script src=""></script>
<input id="file" type="file" name="files" multiple="multiple" /><br />
<progress id="progress" max="100" value="0"></progress>
View ExtendedDataStore.js
import { DataStore, Mapper } from 'js-data'
class ExtendedDataStore extends DataStore {
as(name) {
const props = {}
// const original =
const mapper = this.getMapper(name)
const self = this
// if "this" is passed instead of "self" the downstream methods fail without straightforward Error stacktrace