Skip to content

Instantly share code, notes, and snippets.

λ • Geovani de Souza geovanisouza92

Block or report user

Report or block geovanisouza92

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@geovanisouza92
geovanisouza92 / functions.js
Created Apr 17, 2019
You don't need bluebird / async
View functions.js
async function forEachSerial(cb, arr) {
await arr.reduce(async (prevPromise, value) => {
await prevPromise;
return cb(value);
}, Promise.resolve());
}
async function forEachParallel(cb, arr) {
await Promise.all(arr.map(cb));
}
View make.go
package main
import (
"github.com/geovanisouza92/go-tasks"
"github.com/geovanisouza92/go-tasks/vcs/git"
"github.com/geovanisouza92/go-tasks/build/docker"
"github.com/geovanisouza92/go-tasks/deploy/kubernetes"
)
func main() {
@geovanisouza92
geovanisouza92 / main.js
Last active Sep 25, 2018
Async iterator for pagination
View main.js
class Token {
nextRange() {
return `${this._range}-`;
}
feed(response) {
this._range = response.headers.Range;
}
}
@geovanisouza92
geovanisouza92 / cartesian-product.benchmark.js
Created Jul 3, 2018
Cartesian Product algo Benchmark
View cartesian-product.benchmark.js
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite;
const A = [0, 1, 2, 3, 4];
const B = [A, A, A, A, A];
suite
.add('cartesianProduct_gen', function() {
Array.from(cartesianProduct_gen(B));
})
@geovanisouza92
geovanisouza92 / builder.ts
Last active Apr 3, 2019
A builder type where build() only appears after correct initalization
View builder.ts
interface Buildable<T> {
build(): T;
}
type HasSawThickness = { sawThickness: number };
type HasDirection = { direction: "horizontal" | "vertical" };
type HasWidth = { width: number };
type HasHeight = { height: number };
type HasPhase = { phase: number };
View keybase.md

Keybase proof

I hereby claim:

  • I am geovanisouza92 on github.
  • I am geovanisouza92 (https://keybase.io/geovanisouza92) on keybase.
  • I have a public key ASCpolGtmdNixlFQCCB-CbnR2smOlL8WtGUTk7GFb5CMfgo

To claim this, I am signing this object:

@geovanisouza92
geovanisouza92 / README.md
Created Jun 22, 2018
Injeção de módulos com Webpack
View README.md

Uma forma simples de reduzir acoplamento modificando apenas a configuração de build.

Como a configuração é "apenas Javascript", fica fácil manipular, porém é importante tomar cuidado para não cair na situação do "na minha máquina funciona", pois cada ambiente pode gerar um bundle diferente. Testar é sempre importante.

Isso pode ser muito útil para injetar arquivos de configuração, implementação de features específicas (tracing, logging, metrics, error tracking, etc.) e até incluir módulos específicos de um ambiente, como suporte a source-map, por exemplo.

@geovanisouza92
geovanisouza92 / mapping.json
Created Dec 21, 2017
Remover acentos com TS
View mapping.json
{
"À": "A",
"Á": "A",
"Â": "A",
"Ã": "A",
"Ä": "A",
"Å": "A",
"": "A",
"": "A",
"": "A",
@geovanisouza92
geovanisouza92 / strict-functions-causes-errors.ts
Last active Dec 14, 2017
--strictFunctionTypes generates errors with generic functions
View strict-functions-causes-errors.ts
type Direction = keyof IDirectionOptions;
interface IDirectionOptions {
"horizontal": { foo: number; };
"vertical": { bar: string; };
"diagonal": { baz: boolean; };
}
// This structure works
You can’t perform that action at this time.