Skip to content

Instantly share code, notes, and snippets.

@mgiacomini
mgiacomini / retrieve_token.sh
Last active July 25, 2018 14:04
How retrieve Kubernetes access token to current cluster (context)
# Check if the current cluster is right
kubectl config current-context
# Get the current context access token
TOKEN=$(kubectl describe secret $(kubectl get secrets | grep ^default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d " ")
# Print it :)
echo $TOKEN
# More info: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/
@mgiacomini
mgiacomini / drilldown.js
Created August 29, 2018 20:09
How to drill down charts with ChartJS?
// https://stackoverflow.com/questions/51609922/how-to-drill-down-charts-with-chartjs
// https://stackoverflow.com/questions/26257268/click-events-on-pie-charts-in-chart-js
$(document).ready(function() {
var canvas = document.getElementById("myChart");
var ctx = canvas.getContext("2d");
var myNewChart = new Chart(ctx, {
type: 'pie',
data: data
});
@mgiacomini
mgiacomini / Procfile
Created September 20, 2018 14:25
Heroku elixir setup
web: MIX_ENV=prod mix phx.server
@mgiacomini
mgiacomini / delete-evicted-pods-all-namespaces.sh
Created December 26, 2018 12:28 — forked from psxvoid/delete-evicted-pods-all-namespaces.sh
Delete evicted pods from all namespaces (also ImagePullBackOff and ErrImagePull)
#!/bin/sh
# based on https://gist.github.com/ipedrazas/9c622404fb41f2343a0db85b3821275d
# delete all evicted pods from all namespaces
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff state from all namespaces
kubectl get pods --all-namespaces | grep 'ImagePullBackOff' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff or ErrImagePull or Evicted state from all namespaces
@mgiacomini
mgiacomini / miner.exs
Created January 15, 2019 01:12
Bcredi miner example
path
|> CsvParser.parse(:stream)
|> Flow.from_enumerable()
|> Flow.map(&cast_contract/1) # will return {:ok, %Contract{}} | {:error, changeset}
|> Flow.map(&apply_blacklist/1) # will return {:ok, %Contract{}} | {:error, changeset} | {:filtered, reason}
|> Flow.partition(key: {:elem, 0})
|> Flow.group_by(& elem(&1, 0))
|> Flow.filter(fn
{:error, changeset} -> log_error(changeset) && false
{:filtered, reason} -> log_filtered(reason) && false
curl -X POST 'https://staging.ebanx.com.br/ws/direct' \
-d 'request_body={
"integration_key": "<bcredi-integration-key>",
"operation": "request",
"payment": {
"name": "José Silva",
"email": "[email protected]",
"document": "853.513.468-93",
"address": "Rua E",
"street_number": "1040",
@mgiacomini
mgiacomini / mappings.ex
Created June 14, 2019 17:55
pipefy mappings
@statuses %{
"1.0 Cobrança Jurídica" => %{
"Leilão" => {:foreclosure_auction, "auction_in_progress"},
"Tentativa de Negociação" => {:notification, "attempt_to_negotiate"},
"Não Notificar (Casos de exceção)" => {:notification, "not_notify"}
},
"1.1 Notificação" => %{
"Emissão" => {:notification, "notification_in_progress"},
"Envio e Custas" => {:notification, "notification_in_progress"},
"Análise do Cartório" => {:notification, "notification_in_progress"},
@mgiacomini
mgiacomini / doom.txt
Created June 24, 2019 17:26 — forked from hjertnes/doom.txt
Doom Emacs Cheatsheet
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@mgiacomini
mgiacomini / install.sh
Created July 19, 2019 14:08
Install helm for k8s
helm init
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl create serviceaccount --namespace kube-system tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
@mgiacomini
mgiacomini / contract_mappings.ex
Created August 8, 2019 13:54
contract_mappings
@contract_mappings %{
external_id: %{
field: "NUMERO_CONTRATO",
type: :string
},
enterprise_name: %{
field: "NOME_EMPREENDIMENTO",
type: :string
},
enterprise_id: %{