Skip to content

Instantly share code, notes, and snippets.

View humbertodosreis's full-sized avatar

Humberto dos Reis Rodrigues humbertodosreis

View GitHub Profile
functions:
hello:
handler: handler.hello
events:
- http:
path: users
method: get
integration: lambda
request:
template:
@humbertodosreis
humbertodosreis / cognito.yaml
Created February 10, 2020 20:30 — forked from singledigit/cognito.yaml
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
(def transacoes [
{:valor 10}
{:valor 50}
{:valor 100}])
(reduce + (map #(:valor %) transacoes))
(->> (map #(:valor %) transacoes)
(reduce +))
(defn so-valor [transacao] (:valor transacao))
(ns clojure-playground.core)
(def transacoes [{:valor 33.0 :descricao "Almoco" :tipo "despesa"}
{:valor 40.0 :descricao "Farmacia" :tipo "despesa"}
{:valor 1000.0 :descricao "Salario" :tipo "receita"}])
(map #(:valor %) transacoes)
(filter #(= (:tipo %)) transacoes)
(first transacoes)
@humbertodosreis
humbertodosreis / sync-fork.sh
Last active January 16, 2020 22:21
Steps to sync local repo with a fork
# Configuring a remote for a fork (https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork)
# List the current configured remote repository for your fork.
git remote -v
#> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
#> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
# Specify a new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
;; valor descontado
(* 100 (- 1 0.10))
;; para melhor clareza
(def preco 100)
(def taxa-desconto (- 1 0.10))
;; valor descontado
(* preco taxa-desconto) ;; => 90
; Parte I
; Objetivo: simbolos locais vs globais
; mostrar o exemplo de cálculo
(def total (* (- 1 0.10) (* 10 5)))
(println "Total", total)
; movemos a expressão para um expressão
(defn valor-totalizado [qtde valor]
(* (- 1 0.10) (* qtde valor)))
@humbertodosreis
humbertodosreis / encrypt-decrypt-openssl.php
Created November 29, 2019 16:27
Encrypt/Decrypt example using openssl and private/public keys
<?php
$privateKey = <<<EOD
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC8kGa1pSjbSYZVebtTRBLxBz5H4i2p/llLCrEeQhta5kaQu/Rn
vuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t0tyazyZ8JXw+KgXTxldMPEL9
5+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4ehde/zUxo6UvS7UrBQIDAQAB
AoGAb/MXV46XxCFRxNuB8LyAtmLDgi/xRnTAlMHjSACddwkyKem8//8eZtw9fzxz
bWZ/1/doQOuHBGYZU8aDzzj59FZ78dyzNFoF91hbvZKkg+6wGyd/LrGVEB+Xre0J
Nil0GReM2AHDNZUYRv+HYJPIOrB0CRczLQsgFJ8K6aAD6F0CQQDzbpjYdx10qgK1
cP59UHiHjPZYC0loEsk7s+hUmT3QHerAQJMZWC11Qrn2N+ybwwNblDKv+s5qgMQ5
@humbertodosreis
humbertodosreis / heroku_pg_db_reset.md
Created October 22, 2019 22:25 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

heroku restart; heroku pg:reset DATABASE --confirm APP-NAME; heroku run rake db:migrate

@humbertodosreis
humbertodosreis / Heroku.md
Created October 22, 2019 22:25 — forked from stevenyap/Heroku.md
Heroku setup and list of commands

Note that Heroku Config is found in /.git/config
** Make sure you have setup your git properly before pushing to Heroku **

Pre-conditions for app on Heroku