Skip to content

Instantly share code, notes, and snippets.

View clucasalcantara's full-sized avatar
🔥

Caio Alcantara clucasalcantara

🔥
View GitHub Profile
@clucasalcantara
clucasalcantara / gist:c433b49998160a746e7f0bb496b8ebaa
Created November 16, 2016 14:36
Deployment Access for Universo MW8 developers
This gist is for guide you, amazing developer, into our development process.
First of all, if you haven't done this yet, please share your ssh key (usually on ~/.ssh/id_rsa.pub) with us
for we give u acces on our servers.
@clucasalcantara
clucasalcantara / gist:e4c113d2a549490bc734cdc02f6351eb
Last active July 7, 2017 18:44
Functional example - High order function
const multiply = (x, y) => x * y
const calculateResult = (fn, x, y) => fn(x,y)
const getSix = calculateResult(multiply, 2, 3)
const compose = (f, g) => x => f(g(x));
const addHeart = x => `${x.toLowerCase()}, <3`;
const exclaim = x => x + '!';
const inLove = compose(addHeart, exclaim);
inLove('Hey babe'); // hey babe, <3!
@clucasalcantara
clucasalcantara / currying.js
Last active July 8, 2017 22:44
currying-eveything!
// Thanks Matheus Marciglio: https://github.com/mtmr0x
// This is a regular and not curried function
const sum = function(x, y) => x + y
sum(1, 2) // 3
// With Currying technique we transform that into a curried function
const currySum = (x) => (y) => x + y
currySum(1)(2) // 3
@clucasalcantara
clucasalcantara / hello-curry.js
Created July 7, 2017 17:07
hello-world-curry
const greeting = greet => name => `${greet}, ${name}`;
const eae = greeting('Eae');
eae('World'); // Eae, World
eae('Catioríneo'); // Eae, Catioríneo
console.log(true ? "verdadeiro" : "falso");
console.log(if(true) ? "verdadeiro" : "falso"); // BLAME HERE SYNTAX ERROR!!!
@clucasalcantara
clucasalcantara / server.js
Created November 30, 2017 23:21
Preciso setar maAge: '5d' ou 432000 pras imagens e 120 pra css js
/* eslint-disable no-console */
import 'babel-polyfill'
import path from 'path'
import express from 'express'
import compression from 'compression'
import cache from 'cache-control'
import React from 'react'
import serialize from 'serialize-javascript'
import { renderToStaticMarkup } from 'react-dom/server'
import { Provider } from 'react-redux'
@clucasalcantara
clucasalcantara / gajo.js
Created February 5, 2018 11:08
Gajo - Interview Questions
// What will the code below output to the console and why?
var myObject = {
foo: "bar",
func: function() {
var self = this;
console.log("outer func: this.foo = " + this.foo);
console.log("outer func: self.foo = " + self.foo);
(function() {
console.log("inner func: this.foo = " + this.foo);
@clucasalcantara
clucasalcantara / monkey-patch.js
Last active February 26, 2018 11:47
Temporary solution to fix a unexpected console error using HMRE
if (isDevelopment && module.hot) {
// Hot module reload for App and its routes.
module.hot.accept('./pages/buildRoutes', () =>
renderApp({ routes: buildRoutes() })
);
// While HMRE works, react-router does a `console.error()` because its routes prop changed.
// We monkey-patch `console.error()` to ignore that error.
// See: https://github.com/gaearon/react-hot-loader/issues/298
// See: https://github.com/ReactTraining/react-router/issues/2704
@clucasalcantara
clucasalcantara / CounterWrapper.jsx
Last active April 3, 2018 09:33
render props pattern examples
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import './App.css'
class CounterWrapper extends Component {
state = {
count: 0,
}