Skip to content

Instantly share code, notes, and snippets.

Thiago Campezzi campezzi

Block or report user

Report or block campezzi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
  • About me
  • The world's fastest explanation of refactoring
  • Some examples of refactoring from real-life applications
  • Hairier examples of refactoring from real-life applications
  • My refactoring algorithm
  • Open mic
campezzi / Application.ex
Last active Jan 17, 2019
Elixir - Using GenStage's ConsumerSupervisor to have a dynamic pool of consumer processes
View Application.ex
defmodule MyApp.Application do
use Application
def start(_type, _args) do
children = [
Supervisor.Spec.worker(Producer, []),
Supervisor.Spec.worker(Consumer, [], id: 1)
opts = [strategy: :one_for_one, name: Stages.Supervisor]
campezzi / Howto convert a PFX to a seperate .key & .crt file How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
View Howto convert a PFX to a seperate .key & .crt file
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
campezzi / server.js
Created Oct 20, 2017
CORS Bypass Proxy
View server.js
const express = require('express');
const proxy = require('express-http-proxy');
const cors = require('cors');
const app = express();
app.use('/', proxy(''));
campezzi / ghci.conf
Created May 29, 2017
GHCI - Bold Cyan Lambda Prompt
View ghci.conf
:set prompt "\ESC[1;36mλ> \ESC[m"
campezzi /
Created May 29, 2017
Search for lambda logs
#!/usr/bin/env bash
function get_events() {
echo "Fetching logs for $1 lambda in the $2 region (since $3)..."
aws logs filter-log-events --log-group-name "/aws/lambda/$1" --region "$2" --start-time "$3" --filter-pattern requestId | jq '.events'
case $1 in
get_events $2 ${3:-us-west-2} ${4:-1496030995836}
campezzi /
Created Nov 15, 2016 — forked from keeth/
Apex + Terraform + AWS Lambda + API Gateway + JSON Encoded Errors + CORS
resource "aws_api_gateway_rest_api" "myApi" {
name = "myApi-${var.env}"
description = "My awesome API (${var.env} environment)"
resource "aws_api_gateway_deployment" "myApi" {
depends_on = [
campezzi / query.sql
Created Oct 11, 2016
Calculate Postgres index size
View query.sql
c.reltuples AS num_rows,
pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size,
pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size,
CASE WHEN indisunique THEN 'Y'
idx_scan AS number_of_scans,
campezzi / 01_imperative.exs
Created Oct 11, 2016
Comparison of an imperative bit of code vs. a typical Elixir functional implementation
View 01_imperative.exs
chunk_size = 50_000
lists =, fn x ->
range_start = x * chunk_size
range_end = range_start + chunk_size, fn y -> %{data: %{title: "#{y} is love, #{y} is life"}} end)
Enum.each(lists, fn list -> Repo.insert_all(Meme, list) end)
campezzi /
Last active Sep 19, 2016
Phoenix + Elm setup

Phoenix + Elm Setup


  1. This was tested on Phoenix 1.2.0;
  2. Make sure you have npm 3.x or above - older versions will spit out tons of Babel-related errors.


  1. Create a Phoenix project: mix my_awesome_project
You can’t perform that action at this time.