Skip to content

Instantly share code, notes, and snippets.

View loganpowell's full-sized avatar

Logan Powell loganpowell

  • Metro DC
View GitHub Profile
@loganpowell
loganpowell / mediumUsersFollowedByCount.js
Created January 11, 2018 19:06 — forked from newhouse/mediumUsersFollowedByCount.js
Medium API: get number of followers for User
/**
* Example of how to get the number of followers for a Medium.com User.
*
*
* Related links:
* https://github.com/Medium/medium-api-docs/issues/30#issuecomment-227911763
* https://github.com/Medium/medium-api-docs/issues/73
*/
// LODASH
@loganpowell
loganpowell / NavigationPrompt.jsx
Last active January 24, 2018 23:08 — forked from bummzack/NavigationPrompt.jsx
A replacement component for the react-router `Prompt`.
// from: https://github.com/ReactTraining/react-router/issues/4635#issuecomment-297828995
import React from 'react';
import {withRouter} from 'react-router-dom';
import PropTypes from 'prop-types';
/**
* A replacement component for the react-router `Prompt`.
* Allows for more flexible dialogs.
*
@loganpowell
loganpowell / gist:9683858b9bb6b4eee777c62b12fd9b0e
Created January 25, 2018 15:46 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@loganpowell
loganpowell / destructuring.js
Created January 26, 2018 16:37 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@loganpowell
loganpowell / Event-stream based GraphQL subscriptions.md
Created February 3, 2018 05: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.

@loganpowell
loganpowell / UCC_design_introduction.md
Created February 13, 2018 20:43 — forked from xareelee/UCC_design_introduction.md
A better async/reactive function design in JS (or any other languages) — the Universal Currying Callback (UCC) Design

A better async/reactive function design in JS (or any other languages) — the Universal Currying Callback (UCC) Design

For the principle "Don't call us, we'll call you", the modern function design uses callbacks, Promise, or monad/stream-based techniques (e.g. Rx) to let you subscribe the async results.

The following is a usual JS function implementation using the callback for async:

function register(username, password, email, callback) {
 // processing async work
(ns sunil.curry)
(defn partial+
"Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
differs from the core version in that it works on just one argument."
{:added "1.0"}
([f] f)
([f arg1]
@loganpowell
loganpowell / curry.clj
Created April 7, 2018 23:28 — forked from sunilnandihalli/curry.clj
a macro to create fixed-arity curryable function in clojure
(defmacro def-curry-fn [name args & body]
{:pre [(not-any? #{'&} args)]}
(if (empty? args)
`(defn ~name ~args ~@body)
(let [rec-funcs (reduce (fn [l v]
`(letfn [(helper#
([] helper#)
([x#] (let [~v x#] ~l))
([x# & rest#] (let [~v x#]
(apply (helper# x#) rest#))))]
@loganpowell
loganpowell / BankItem-v1.js
Last active October 16, 2018 19:03 — forked from puppybits/BankItem-v0.js
ClojureScript & React sample code
/* next add the state to ask security questions */
render: function(){
// Now add the security challenge state
var item = null;
switch(this.state.bankState){
case "CONNECTED":
break;
case "SECURITY":
// create a new element to show questions and get answers
const R = require('ramda')
const fetch = require('node-fetch')
const fetchJson = (f) => f.then(res => res.json())
const prepareGithubRequest = R.curry((accessToken, path) => fetchJson(fetch(`https://api.github.com/${path}?access_token=${accessToken}`)))
const fetchFromGithub = prepareGithubRequest(ACCESS_TOKEN)
const getReposFromOrg = org => fetchFromGithub(`orgs/${org}/repos`)
const getPopularRepos = R.compose(R.reverse, R.sortBy(R.prop('stargazers_count')), R.project(['name', 'stargazers_count', 'language']))