Skip to content

Instantly share code, notes, and snippets.

Jared Grippe deadlyicon

View GitHub Profile
@deadlyicon
deadlyicon / README.md
Last active May 17, 2018
A subclass of the Spec reporter that prints the details of a test failure as soon as it fails
View README.md

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.

View cachedRequest.js
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
@deadlyicon
deadlyicon / challenge.js
Created Oct 4, 2017
parallel HTTP requests with Promises
View challenge.js
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')
View livetodolist.js
#!/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 => {
View sorting.js
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
View chai.haveDuplicates.js
/*
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)
View gist:421bf439b9645f924472d24dc28d74bd
### 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:
View .gitignore
# Numerous always-ignore extensions
*.diff
*.err
*.log
*.orig
*.rej
*.swo
*.swp
*.vi
*.zip
View HangManGame.js
class HangManGame extends Component {
constructor(props){
super(props)
this.state = {
guesses: []
}
}
gameLogic(){
You can’t perform that action at this time.