Skip to content

Instantly share code, notes, and snippets.

View danilogila's full-sized avatar

Danilo Gila de Santana danilogila

View GitHub Profile
@Chavao
Chavao / foobar.py
Created September 24, 2013 17:43
Criando uma "interface" em Python
class Usuario(object):
def nome(self):
raise NotImplementedError
def idade(self):
raise NotImplementedError
class Jose(Usuario):
def nome(self):
return 'Jose'
@bschwartz757
bschwartz757 / async.js
Last active November 15, 2023 03:23
Async/await function to fetch data from multiple URLs in parallel
/* Client side, works in Chrome 55 and Firefox 52 without transpilation */
//https://blogs.msdn.microsoft.com/typescript/2016/11/08/typescript-2-1-rc-better-inference-async-functions-and-more/
async function fetchURLs() {
try {
// Promise.all() lets us coalesce multiple promises into a single super-promise
var data = await Promise.all([
/* Alternatively store each in an array */
// var [x, y, z] = await Promise.all([
// parse results as json; fetch data response has several reader methods available:
//.arrayBuffer()
@danilosilvadev
danilosilvadev / ES2015In20Minutes.js
Last active June 7, 2021 15:25
A quick guide to reference the ES06
//This gist is a fast reference to ES06 to whose already knows es05.
//I'm trying to use a different approach: first the example and after the explanation.
//Lesson 1: Template literals
console.log(`hello ${firstname},
how are you?`);
//Template literals are string literals with support for interpolation(using ${variable}) and multiple lines.
@mauricedb
mauricedb / Subject under test
Last active December 7, 2023 14:46
Testing stateful React hooks
import { useState } from 'react';
export function useCounter(initial = 0) {
const [count, setCount] = useState(initial);
return [count, () => setCount(count + 1)];
}