Skip to content

Instantly share code, notes, and snippets.

View antoniojps's full-sized avatar
🐬
Always learning

António Santos antoniojps

🐬
Always learning
View GitHub Profile
@antoniojps
antoniojps / react-hooks-context-usage.js
Last active June 19, 2019 11:52
React Hooks and Context for Global State Management Example
import React, { useEffect } from 'react';
import { useExampleContext, actions, ExampleProvider } from 'context/ExampleContext';
const Page = () => {
// first element is the state
// second is the actions dispatcher
const [{ greet }, dispatch] = useExampleContext();
useEffect(() => {
dispatch({
type: actions.GREET_UPDATE,

Adobe Premiere Shortcuts

Navigate through cuts

⬆️ and ⬇️

Cut clip

Preview:

  • i- in
  • o - out
@antoniojps
antoniojps / react-hooks.md
Last active March 20, 2019 10:56
Native react hooks summary

useState

// const [value, setValue] = useState(initialState)
const [isToggled, setToggle] = useState(false)

useRef

const Component = () => {
  const ref = useRef()
// ITERATORS
// Exemplo de modificar o iterator para adicionar uma string 'is Sexy'
// sempre que utilizamos um for of loop
let myArray = ['Antonio', 'Toze', 'Toninho'];
myArray[Symbol.iterator] = function() {
let index = -1;
const length = this.length;
const arr = this;
// default state
const defaultState = {
welcome: 'Hello',
otherState: 'some stuff',
}
// reducer, always returns new object based on the action type
const greeting = (state = defaultState, action) => {
switch (action.type) {
case 'GREET_ME':
@antoniojps
antoniojps / laravel-setup.md
Created October 18, 2018 18:05
Laravel setup

Set up env

vagrant up

Migrate and seed db

php artisan migrate:refresh --seed

Destroy env

vagrant destroy

@antoniojps
antoniojps / es7-async-await.js
Created July 19, 2018 09:45
async await & error handling
const axios = require('axios');
const getExchangeRate = async (from, to) => {
try {
const response = await axios.get('http://data.fixer.io/api/latest?access_key=d32d75de5146611ae7f23de0782ac09b');
const euro = 1 / response.data.rates[from];
const rate = euro * response.data.rates[to];
if (isNaN(rate)) {
throw new Error();
@antoniojps
antoniojps / vue-animations.vue
Created July 15, 2018 14:24
vue animations
<template>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<h1>Animations</h1>
<hr>
<button class="btn btn-primary" @click="show=!show">Show alert</button>
<br><br>
<transition name="fade">
<div class="alert alert-info" v-if="show">This is some info</div>
{
"eslint.validate": [
"javascript",
"javascriptreact",
"vue"
],
"editor.fontFamily": "Consolas , Menlo, Monaco, 'Courier New', monospace, 'Apple Color Emoji'",
"editor.fontSize": 14,
"terminal.integrated.shell.osx": "zsh",
"[markdown]": {

Utilizar ou não ponto-e-vírgulas

O syntax parser do javascript adiciona ponto-e-virgulas automaticamente. (ASI: automatic semicolon insertion)

Erros possíveis:

randomNumber(x){
    return 
    {
 number : x