Skip to content

Instantly share code, notes, and snippets.

View adam8810's full-sized avatar

Adam Booth adam8810

  • Oklahoma City
View GitHub Profile
@adam8810
adam8810 / promiseAll.js
Created February 16, 2022 18:36
Task: Rewrite promise.all demonstrating knowledge of asynchronous behavior.
/* Promise.all Implementation
Takes an ordered array of functions that return promises. Returns an ordered array
of the results of all promises only after all promises have completed.
If, at any point, one promise is rejected it will reject with that error.
*/
function promiseAll (promises) {
return new Promise(async (resolve, reject) => {
const indexedPromises = promises.reduce((ps, p, idx) => ({ ...ps, [idx]: p}), {});
@adam8810
adam8810 / getJwt
Created April 19, 2018 15:26
Copies a new JWT token to your clipboard
#!/bin/bash
CLIENT_ID= # Add client id
CLIENT_SECRET= # Add client secret
AUTH_TOKEN_URL= # Add token url
AUDIENCE= # Add audience
curl --silent --request POST \
--url $AUTH_TOKEN_URL \
--header 'content-type: application/json' \
--data "{\"client_id\":\"$CLIENT_ID\",\"client_secret\":\"$CLIENT_SECRET\",\"audience\":\"$AUDIENCE\",\"grant_type\":\"client_credentials\"}" 2>&1 | \
grep -Eoi 'ey([^"]+)' | \
@adam8810
adam8810 / clear-files.js
Created June 22, 2017 22:35
Clear files from channel
var
Slack = require('slack-node'),
T = require ('data.task'),
R = require ('ramda'),
M = require ('control.monads'),
logI = function (x) { console.log (x); return x; },
id = function (x) { return x; },
konst = R.curry (function (a, b) { return a; }),
du = function (M) { return function () { return R.apply (R.pipe, arguments)(M.of ({})); }; },
bind = function (a) { return R.chain (konst (a)); },

Style Guide

Type Signatures

 (a -> b) -> b -> a

Composition

 du (T) ( bind  (getSpace ('./outer_space.json'))

, map (processSpaces)

@adam8810
adam8810 / 0_reuse_code.js
Last active August 31, 2015 13:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adam8810
adam8810 / npm-g
Last active August 29, 2015 14:27
Adam's Global NPM packages
npm install -g speed-test gulp nodemon yo
@adam8810
adam8810 / logging.js
Last active February 1, 2025 00:36
A simple node module that makes console.log/error/warn/debug statements log through winston (simply include at the beginning of your app)
'use strict';
var util = require('util'),
winston = require('winston'),
logger = new winston.Logger(),
production = (process.env.NODE_ENV || '').toLowerCase() === 'production';
module.exports = {
middleware: function(req, res, next){
console.info(req.method, req.url, res.statusCode);
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-scroll-header-panel/core-scroll-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
@adam8810
adam8810 / gist:6259898
Last active December 21, 2015 05:49
DB vs ORM
$query = DB::select(DB::expr('person.homeid, home.addressid, person.personid, person.firstName, person.middleName, person.lastName, person.gender, person.maritalStatus, person.birth'))
->from(DB::expr('home, person'))
->where(DB::expr('home.homeid'), DB::expr('person.homeid'))
->and_where(DB::expr('person.homeid'), $homeid);
$people = Person::query()
->related('homes')
->get();
// list people's addresses