Skip to content

Instantly share code, notes, and snippets.

View renanlage's full-sized avatar

Renan Lage renanlage

  • Rio de Janeiro - Brazil
View GitHub Profile
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import filterObject from 'utils/filterObject'
// utils/filterObject.js
// ------------------------------------
// export default = (obj, allowed) => (
// Object.keys(obj)
// .filter(key => allowed.includes(key))
// .reduce((obj, key) => {

Know Your Tooling

Mastering Git

Why use a version control system?

  • Collaboration
  • Storing versions (properly)
  • Restoring previous versions
  • Understanding what happened
  • Backup
@renanlage
renanlage / crash_eventstore.ex
Last active July 31, 2018 03:21
Mata a conexão do listener do Postgrex na marra
{_, port} = \
GenServer.whereis(EventStore.Notifications.Listener.Postgrex)\
|> :sys.get_state()\
|> Map.get(:pid)\
|> :sys.get_state()\
|> Map.get(:mod_state)\
|> Map.get(:protocol)\
|> Map.get(:sock)
:erlang.port_close(port)
@renanlage
renanlage / idempotency.ex
Last active October 28, 2018 01:38
Exemplo de função para implementar idempotência no banco
def get_cache_or_insert(idempotency_key, request_hash) do
Multi.new()
|> Multi.run(:query, fn _ ->
query = from(
entry in IdempotencyEntry,
left_join: cache in IdempotencyCache,
on: cache.entry_key == entry.key,
select: fragment("CASE WHEN request_hash != ? THEN 'conflict' WHEN cache = NULL THEN 'no_cache' ELSE cache END", request_hash)
)
@renanlage
renanlage / .tmux.conf
Created November 5, 2018 21:21
tmux conf file
# set Zsh as your default Tmux shell
set-option -g default-shell /usr/bin/zsh
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"
defmodule Notificator do
def notify(topic, %{account_id: account_id} = event) do
# Do some stuff with account_id
resource_identifier = resource_for_topic(topic, event)
with {:ok, resorce_data} = Transfers.get_resource(resource_identifier),
{:ok, notification_params} <-
to_notification(topic, event, resource_identifier, resource_data),
{:ok, notification} <- Notification.save(notification_params) do
@renanlage
renanlage / remote.md
Created April 5, 2020 15:47
Let's work from home!

Let's work from home!

Pessoal, sabemos que trabalhar remoto é ao mesmo tempo uma bênção e um desafio. Nossa Família Banking trabalha muito bem de casa, e, depois de algumas conversas em 1:1s, decidi fazer esse doc com o objetivo de passar para todos algumas dicas sobre trabalho remoto que os nossos próprios devs seguem.

Eu trabalho bem de casa? Bom, não é nem perto do que o que vocês conseguem fazer, então queria pedir a todos que coloquem nos comentários as suas dicas e os seus segredos (mua-ha-ha), para fazermos disso aqui um documento colaborativo (e quem sabe conseguirmos ajudar até outras áreas, clientes, etc.)! Eu dividi a doc em "Por favor façam""Por favor não façam" e "Parece simples, mas pode ajudar muito". Se puderem, sigam o padrão nos comentários, que vou editando por aqui.

E lembrem-se: eu e jujubot estamos aqui para e por vocês. Nos procurem!
Temos as mesmas dificuldades (the struggle is real), vamos nos ajudar =]