Skip to content

Instantly share code, notes, and snippets.

View jaredatron's full-sized avatar

Jared Grippe jaredatron

View GitHub Profile
@jaredatron
jaredatron / gists_modeling.sql
Last active May 11, 2019 17:48
Data modeling for gist clone service
CREATE EXTENSION IF NOT EXISTS uuid-ossp;
CREATE TABLE IF NOT EXISTS users (
user_id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
email text UNIQUE,
password_hash text,
username text,
avatar_url text
);
alert('🏂');
alert('🏂');
alert('🏂');
alert('🏂');
@jaredatron
jaredatron / README.md
Last active May 17, 2018 19:45
A subclass of the Spec reporter that prints the details of a test failure as soon as it fails

Customer Mocha Reporter

…that prints the details of the test failure error as soon as a test fails.

Why? I hate having to wait until my long test suite finishes to begin debugging why a test fails.

const doSomething = (uniqueThing) => {
if (doSomething.currentRequest[uniqueThing]) {
return doSomething.currentRequest[uniqueThing]
}
return doSomething.currentRequest[uniqueThing] = require(url, params)
.then(
response => {
delete doSomething.currentRequest
return response
@jaredatron
jaredatron / challenge.js
Created October 4, 2017 17:20
parallel HTTP requests with Promises
const request = require('request-promise')
const getURL = (url) => {
console.log(`GET: ${url}`)
// request the URL as a GET requests
// parse the resonse using JSON.parse
}
const getPosts = () => {
return getURL('https://jsonplaceholder.typicode.com/posts')
#!/usr/bin/env node
const fs = require('fs')
const Path = require('path')
const stateFilePath = Path.resolve(process.env.HOME, '.todo')
const command = process.argv[2]
const input = process.argv.slice(3).join(' ')
const getState = callback => {
const numbers = [5,2,4,3,1]
const sorterA = (a,b) => {
if (a < b) return -1
if (b < a) return 1
return 0
}
const sorterB = (a,b) => {
if (a < b) return 1
@jaredatron
jaredatron / chai.haveDuplicates.js
Created July 10, 2017 21:28
haveDuplicates for chai
/*
expect([1,2,3]).to.not.haveDuplicates()
expect([1,1,2,3]).to.haveDuplicates()
*/
chai.Assertion.addMethod('haveDuplicates', function() {
const array = Array.from(this._obj)
expect(array).to.be.an.instanceof(Array)
### Keybase proof
I hereby claim:
* I am deadlyicon on github.
* I am deadlyicon (https://keybase.io/deadlyicon) on keybase.
* I have a public key ASCk6Mt98T-7ihYOEO3DjHFJRi7Irby6eTQ_92CH-YcCYAo
To claim this, I am signing this object: