Skip to content

Instantly share code, notes, and snippets.

View wehrhaus's full-sized avatar

Justin Wehrman wehrhaus

  • ['WehrHaus', 'EquipmentShare']
  • Kansas City, MO
View GitHub Profile
@wehrhaus
wehrhaus / Event-stream based GraphQL subscriptions.md
Created November 23, 2020 22:07 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@wehrhaus
wehrhaus / addBinary.js
Created June 22, 2018 15:45
Return binary of sum of numbers
const addBinary = (...n) => n.reduce((acc, cur) => acc + cur).toString(2);
@wehrhaus
wehrhaus / multiply.mul.js
Last active July 18, 2018 01:58
mul function for multiplication of numbers
const multiply = (...n) => n.map(n => +n).reduce((acc, cur) => acc * cur);
@wehrhaus
wehrhaus / createRange.js
Created June 12, 2018 17:19
Create a range of numbers
function* range(start, end) {
yield start;
if (start === end) return;
yield* range(start + 1, end);
}
const createRange = (a, b) => [...range(a, b)];
// Example Usage: Create array of lowercase alphabet
const alphabet = createRange(97, 122).map(k => String.fromCharCode(k));
@wehrhaus
wehrhaus / request-pool.js
Created May 25, 2018 15:46
Request Pool using Angular
'use strict';
import BaseCollection from './data/collections/BaseCollection';
import * as _ from 'lodash';
RequestPool.$inject = ['$q'];
export default function RequestPool($q) {
function RequestPool(cap) {
this.cap = cap;
@wehrhaus
wehrhaus / index.js
Last active June 6, 2018 04:21
Perl Script for Transforming JSON
#!/usr/bin/env node
console.log(
`
FILENAME: transform-json.pl
#!/usr/bin/perl
#
# Takes a list of environment variables and applies
# - the values to the json files matching keys
@wehrhaus
wehrhaus / createStore.js
Last active May 18, 2017 14:33
createStore
const createStore = (reducer) => {
let state;
let listeners = [];
const getState = () => state;
const dispatch = (action) => {
state = reducer(state, action);
listeners.forEach((listener) => listener());
};
@wehrhaus
wehrhaus / .eslintrc.js
Created April 14, 2016 14:39
ES5 Linting
module.exports = {
"env": {
"browser": true
},
"extends": "eslint:recommended",
"globals": {
"angular": true,
"console": true,
"Core": true
},
@wehrhaus
wehrhaus / gist:f4fef8d188301cc07a20
Created January 20, 2016 17:32
Directive Example using setValidation
(function() {
'use strict';
angular
.module('jpmTool.components')
.directive('datePicker', datePicker);
function datePicker() {
return {
scope: {
@wehrhaus
wehrhaus / Preferences.sublime-settings
Last active November 14, 2016 16:37
Sublime Text Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"color_scheme": "Packages/User/SublimeLinter/Material-Theme-OceanicNext (SL).tmTheme",
"default_line_ending": "unix",
"font_face": "Hack",
"font_size": 10,
"highlight_line": true,