This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Token { | |
nextRange() { | |
return `${this._range}-`; | |
} | |
feed(response) { | |
this._range = response.headers.Range; | |
} | |
} |
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"À": "A", | |
"Á": "A", | |
"Â": "A", | |
"Ã": "A", | |
"Ä": "A", | |
"Å": "A", | |
"Ấ": "A", | |
"Ắ": "A", | |
"Ẳ": "A", |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// isso indica que a função "fn" pode ser invocada com uma lista de objetos que | |
// tenham, pelo menos, um atributo "id" do tipo number, e que o retorno vai ser | |
// uma lista de números | |
function fn<T extends { id: number }>(items: T[]): number[]; | |
// isso indica que a função "fn" pode ser invocada com uma lista de "qualquer | |
// coisa" e que o segundo parâmetro deve ser o nome de um atributo presente em | |
// todos os itens da lista, e que o retorno vai ser uma lista com valores dos | |
// tipos de cada atributo encontrado na lista | |
function fn<T, K extends keyof T>(items: T[], idProp: K): T[K][]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Direction = keyof IDirectionOptions; | |
interface IDirectionOptions { | |
"horizontal": { foo: number; }; | |
"vertical": { bar: string; }; | |
"diagonal": { baz: boolean; }; | |
} | |
// This structure works |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Aqui você define uma enumeração de valores: ela não é constante, vc define | |
// valores estruturais (não tipos) que são aceitos | |
type WillyWonkaElevatorDirection = "horizontal" | |
| "vertical" | |
// | "diagonal" // Descomente isso | |
; | |
// Aqui você pode usar esse novo tipo | |
function handleDirection(direction: WillyWonkaElevatorDirection) { | |
switch (direction) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const used = process.memoryUsage(); | |
for (let key in used) { | |
console.log(`${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`); | |
} |