Skip to content

Instantly share code, notes, and snippets.

View victorvhpg's full-sized avatar
🎯
Focusing

Victor Hugo victorvhpg

🎯
Focusing
View GitHub Profile
@victorvhpg
victorvhpg / jquery.sh
Last active July 12, 2018 06:11
npm install jquery --save
npm install jquery --save
@victorvhpg
victorvhpg / action.js
Last active April 9, 2018 02:14
actions.js
import CONSTANTS from '../constants';
export let actionCreditar = (valorCredito) => {
return {
type: CONSTANTS.CREDITO,
payload: {
valor: valorCredito
}
};
};
@victorvhpg
victorvhpg / reducer.js
Last active April 9, 2018 01:11
reducer.js
import CONSTANTS from '../constants/';
const initialState = {
saldo: 0,
valorTransacao: 0,
erro: ""
};
let reducerConta = (state = initialState, action) => {
switch (action.type) {
import { createStore, applyMiddleware } from 'redux';
//importa os middlewares
import logger from 'redux-logger';
import thunk from 'redux-thunk';
//importa os reducers
import rootReducers from './reducers';
//cria a store passando os reducers e os middlewares
let store = createStore(
rootReducers,
@victorvhpg
victorvhpg / middlewares.js
Last active April 7, 2018 21:14
middlewares
//exemplo estrutura de um middleware
export let middlewareExemplo = ({ getState, dispatch }) => next => action => {
//.next() passa a action para os proximos middlewares
//ate chegar nos reducers que atualizam o state
let result = next(action);
//retorna o retorno da execucao dos middlewares seguintes
//ou action caso seja o ultimo middleware em execucao
return result;
};
@victorvhpg
victorvhpg / etc-sysconfig-varnish.sh
Last active December 5, 2017 01:53
/etc/sysconfig/varnish
# Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#
# Maximum number of open files (for ulimit -n)
NFILES=131072
# Locked shared memory (for ulimit -l)
downloadArquivo("./video.ogv", function(progresso, total, perc) {
document.querySelector("progress").value = perc;
}).then(function(arrayBuffer) {
//cria um Blob a partir do arrayBuffer
var blob = new Blob([arrayBuffer], {
type: "video/ogg"
});
//cria o elemento video
var video = document.createElement("video");
video.autoplay = true;
//para modulos default
import variavelDefault from "./exemplo.js";
//para modulos default que também possuem outros exports
import variavelDefault, { variavelNaoDefault } from "./exemplo.js";
//renomeando a default
import { default as variavelDefault, variavelNaoDefault } from "./exemplo.js";
export default function(a, b){
return a+b;
}
//ou
function soma(a, b){
return a + b;
}
export default soma;
//importando apenas um identificador
import {algumaCoisa} from "./modulo-teste.js";
//importando apenas um identificador e renomeando
import {algumaCoisa as teste} from "./modulo-teste.js";
//importando vários identificadores
import {algumaCoisa, Pokemon, soma} from "./modulo-teste.js"
//importando o modulo inteiro