This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Small request wrapper for XMLHttpRequest | |
* with an API similar to fetch. | |
* | |
* @author Gabe M. | |
* @param {string} url - Resource Url for Request | |
* @param {Object} config | |
* @param {string} [config.method=GET] - REST request method | |
*/ | |
function request(url, { method = 'GET' } = {}) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SafeURLSearchParams extends URLSearchParams { | |
static isGarbageBrowser = (() => { | |
try { | |
new URLSearchParams(new URLSearchParams('a=a')); | |
return false; | |
} catch (e) { | |
return true; | |
} | |
})() | |
constructor(init) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
) | |
func main() { | |
go func() { | |
http.ListenAndServe(":8001", &fooHandler{}) | |
}() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Usage: | |
* import package from './package.json' | |
* | |
* externals(package) | |
*/ | |
function externals(pkg) { | |
return Object.keys(pkg).reduce((accumulator, key) => { | |
if (key.match(/dependencies/i)) { | |
const value = pkg[key]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetchImage from 'https://gist.githubusercontent.com/gabemeola/27e8fd9148f9ae7541d88d54d87f5113/raw/97138b8039f3b598c41832ef4bfdd4e48bcb3ab6/fetchImage.js' | |
const noop = () => {} | |
function removeUrlProtocol(url) { | |
// Split the image to not include protocol | |
const srcSplit = url.split(':'); | |
// Use the second part of the protocol string | |
// split, if it exists. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fetches image and returns promise after fetch. | |
* | |
* @param {string} imageUrl - Image SRC to fetch | |
* @return {Promise} Returns promise of imageUrl that was successful | |
*/ | |
export default function fetchImage(imageUrl) { | |
return new Promise((resolve, reject) => { | |
if (imageUrl == null) { | |
reject('Image is null or undefined', imageUrl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a reducer with generic reducer logic handle for you. | |
* For any cases not matched from an `action.type`, the passed state is returned. | |
* | |
* @author Gabe M. | |
* @param {string} name - Name of the Reducer. Redux will use this for store and serialization | |
* @param {Object} initialState - Initial State Object | |
* @param {Object} cases - Cases is an object with describe your mutations. | |
* Key is a matching action.type from a dispatched action. | |
* Value is a function that accepts state, and action. This should return new non mutated state. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple Que using linked lists. | |
* Pushed value can be anything. | |
*/ | |
class Queue { | |
constructor() { | |
this.first = null; | |
this.last = null; | |
this.length = 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const PORT = process.env.PORT || 8080 | |
http.createServer((request, response) => { | |
response.setHeader('Content-Type', 'text/html; charset=UTF-8'); | |
response.setHeader('Transfer-Encoding', 'chunked'); | |
response.write(( | |
'<!DOCTYPE html>' + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import { Loading } from 'components'; | |
export default class Enabler extends Component { | |
static propTypes = { | |
children: PropTypes.node.isRequired, | |
/** | |
* Bootstrap function to run. |