Skip to content

Instantly share code, notes, and snippets.

View vinicius73's full-sized avatar
🤓
"Those who cannot acknowledge themselves, will eventually fail."

Vinicius Reis vinicius73

🤓
"Those who cannot acknowledge themselves, will eventually fail."
View GitHub Profile
@vinicius73
vinicius73 / plugins-title.js
Created March 11, 2017 17:59
viue - dinamic title
export default Vue => {
Vue.mixin({
created () {
const { title } = this.$options
if (title !== undefined) {
this.$title = title
}
}
})
import { identity } from 'lodash'
import waith from './waith'
export default (action, repetitions, timeToWaith = 3000) => {
const onError = counter => () => {
if (counter < repetitions) {
return run(counter + 1)
}
return Promise.reject(new Error('TRIES_FAILURE'))
@vinicius73
vinicius73 / problema.md
Last active December 14, 2017 19:36
Um exercício simples com js

Default true

Existem 3 entradas possiveis

  • true
  • false
  • undefined

as saídas serão:

  • undefinded => true
@vinicius73
vinicius73 / var-let-const.md
Last active September 30, 2019 13:52
var, let e const no JavaScript

var, let e const

Em JavaScript há uma comportamento chamado hoisting. O uso de var trazia algumas pegadinhas, como por exemplo, declarar a mesma variavel 2x usando var

var abc = 25
// ...
// ...
var abc = 99
@vinicius73
vinicius73 / npm-cheat-sheet.md
Last active April 5, 2019 07:32 — forked from AvnerCohen/npm-cheat-sheet.md
Node.js - npm Cheat Sheet

Node.js - npm Cheat Sheet

(Descrição completa e mais comandos aqui - https://npmjs.org/doc/index.html)

Instale um pacote e também atualize o package.json com a versão instalada e o nome do pacote.
npm install <module-name> --save
# Versions
# Where the ambientum cache will live
A_CACHE_HOME=$HOME/.cache/ambientum
# Define specific cache directories
A_NPM_CONFIG=$A_CACHE_HOME/npm-config
A_NPM_CACHE=$A_CACHE_HOME/npm-cache
A_COMPOSER_CACHE=$A_CACHE_HOME/composer
@vinicius73
vinicius73 / post.md
Created November 22, 2016 12:26
["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

#["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

Se preparem que o texto é longo.

Várias vezes chegam novatos aqui perguntando como começar, e a galera diz "estuda lógica primeiro, depois vai pra linguagem X". Vivo dizendo que é bobagem. Ontem, em particular, falei isso, e vieram várias pessoas por inbox me perguntar porquê (e uma pra me xingar, achando que falei por arrogância).

Pra facilitar, eu vou escrever uma boa explicação de porquê "lógica de programação" é furada, doa a quem doer, e postar na APDA e no fórum da EnergyLabs (para futuras referências, porque esse assunto vai voltar, ctz).

@vinicius73
vinicius73 / async-examples.js
Created October 21, 2016 09:58 — forked from developit/async-examples.js
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;