Skip to content

Instantly share code, notes, and snippets.

What to use

  • Test runner: ava
  • React components testing: enzyme
  • Endpoint testing: express + supertest
  • Mocking framework: sinon
  • External dependencies mocking: proxyquire

Test cases

all the following examples are using ava syntax, but they may be easily adapted to mocha or tape as well

@brigand
brigand / nickname.md
Created March 9, 2016 07:45
Freenode Setting Up Your Nickname

What is the recommended way to set up my IRC nickname?

Please follow these steps to set up your nick and configure your client. Check off each step to make sure it's been done:

Select a permanent, master nickname. If the nickname you want is registered but has expired, just ask a staffer and in most cases, we will be happy to drop it for you.

Please avoid using the name of a community project or trademarked entity, to avoid conflicts. Write down your password and be sure to keep the sheet of paper in a safe place.

Register your IRC nick:

@fmasanori
fmasanori / propublica.py
Last active February 2, 2020 05:59
propublica.py
from urllib.request import Request, urlopen
import json
url = "https://api.propublica.org/campaign-finance/v1/2016/president/totals.json"
q = Request(url)
q.add_header('X-API-Key', 'n8QLPm4lNS2Mfak1bam5X7HlevBAOSoF9epQkX0m')
data = urlopen(q).read()
data = json.loads(data.decode('utf-8'))
@bburky
bburky / lanyrd.py
Created December 12, 2015 01:08
Scrape a list of all conference talk PDFs from Lanyrd.com
#!/usr/bin/env python3
'''Scrape a list of all conference talk PDFs from Lanyrd.com
Usage: ./lanyrd.py > talks.json
This script searches Lanyrd for all talks with PDF slides and extracts the data
into nicely formatted JSON.
'''
import sys
@paulirish
paulirish / what-forces-layout.md
Last active July 27, 2024 18:06
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@robertsdionne
robertsdionne / deepdream-install.md
Last active February 15, 2021 16:07
Deepdream installation
#!/usr/bin/env bash

# Assuming OS X Yosemite 10.10.4

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install
@fmasanori
fmasanori / Copa2014all.py
Created July 1, 2015 17:58
Copa 2014 todas as obras
import urllib.request
url = 'http://www.portaltransparencia.gov.br/copa2014/api/rest/empreendimento'
resp = urllib.request.urlopen(url).read().decode('utf-8')
total = 0
j = 0
while True:
abre = '<valorTotalPrevisto>'
fecha = '</valorTotalPrevisto>'
j = resp.find(abre, j)
if j == -1:
@fmasanori
fmasanori / QEduAvancada.py
Created June 28, 2015 15:57
QEdu Exemplo de Busca Avançada: escolas, em funcionamento, sem energia, água e esgoto
import urllib.request
import json
url = 'http://educacao.dadosabertosbr.com/api/escolas/buscaavancada?situacaoFuncionamento=1&energiaInexistente=on&aguaInexistente=on&esgotoInexistente=on'
resp = urllib.request.urlopen(url).read()
resp = json.loads(resp.decode('utf-8'))
print ('Número de Escolas em funcionamento sem energia, água e esgoto:', resp[0])
for x in resp[1]:
print (x['nome'], x['cod'])
print (x['cidade'], x['estado'], x['regiao'])
print ()
if (!Object.delegate) {
Object.delegate = function $delegate$(delgObj,obj) {
if (!obj) obj = {};
if (Object.setPrototypeOf) return Object.setPrototypeOf(obj,delgObj);
return Object.assign(Object.create(delgObj),obj);
}
}