Calculate a “Net Promoter Score” from an array of integers.
$ npm install --save gist:34e4f906939ee1bafc74b82e64d4cc48
# ~/.config/starship.toml | |
format = """ | |
[♥](bold red)\ | |
${custom.git_user}\ | |
${custom.ip}\ | |
$ruby${custom.bundler}\ | |
$golang\ | |
$nodejs${custom.npm}${custom.yarn}\ | |
$terraform\ |
// A "pangram" is a sentence that includes every letter of the alphabet. | |
// Write a function that will return what letters of the alphabet are | |
// missing from a sentence (thus meaning it is not a pangram). | |
// "A quick brown fox jumps over the lazy dog" includes every letter, returning "" | |
// "Lions, and tigers, and bears, oh my!" does not include every letter, returning "cfjkpquvwxz" | |
function findMissingLetters(str) { | |
const alphabet = 'abcdefghijklmnopqrstuvwzyz'; | |
if (str.length) { | |
const reducer = (memo, letter) => { |
#!/bin/bash | |
set -o nounset | |
if [ "$(git status -s | wc -l | bc)" -gt "0" ]; then | |
if [ "$(git diff --cached master -G '"version":' | wc -l | bc)" -eq "0" ]; then | |
echo -e "\033[31m✘\033[0m Aborting commit! \"package.json\" was not updated with a new version." | |
fi | |
fi |
# Add this function to .bashrc or .bash_profile | |
# $ pkg | |
# $ pkg dependencies # (to show only the dpendencies) | |
# Requires `jq` | |
pkg() { | |
if [ -f package.json ]; then | |
cat package.json | jq .$1 | |
else | |
read -p "package.json doesn't exist. Create one? [Y/n] " -n 1 -r | |
if [[ $REPLY =~ ^(Y|y| ) ]] || [[ -z $REPLY ]]; then |
query starredRepositories($repositories: Int = 10, $after: String, $releases: Int = 1) { | |
viewer { | |
starredRepositories(first: $repositories, after: $after, ownedByViewer: false, orderBy: {field: STARRED_AT, direction: DESC}) { | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
edges { | |
cursor | |
starredAt |
const { buildSchema } = require('graphql'); | |
const glob = require('glob-promise'); | |
const { readFile } = require('fs-extra'); | |
const { join } = require('path'); | |
async function stitchSchema(dir) { | |
const files = await glob(dir); | |
const contents = await Promise.all(files.map(file => readFile(file, 'utf8'))); | |
return buildSchema(contents.join('\n\n')); | |
} |
const fetch = require('node-fetch'); | |
const format = require('date-fns/format'); | |
const [ year, month, day ] = format(new Date(), 'YYYY-MM-DD').split('-'); | |
const scoreboard = `http://mlb.mlb.com/gdcross/components/game/mlb/year_${year}/month_${month}/day_${day}/master_scoreboard.json`; | |
fetch(scoreboard).then(res => res.json()).then(json => { | |
console.log(json); | |
}); |
'use strict'; | |
const { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql'); | |
const Query = new GraphQLObjectType({ | |
name: 'Query', | |
description: 'The root type defines how GraphQL operations begin. It is the entry point to constructing GraphQL queries.', | |
fields: () => ({ | |
hello: { | |
type: GraphQLString, |