Skip to content

Instantly share code, notes, and snippets.

View shadowlik's full-sized avatar
divide and conquer

Henrique Marques Fernandes shadowlik

divide and conquer
View GitHub Profile
@shadowlik
shadowlik / slugify.postgres.sql
Created February 21, 2023 19:00 — forked from abn/slugify.postgres.sql
A slugify function for postgres
-- original source: https://medium.com/adhawk-engineering/using-postgresql-to-generate-slugs-5ec9dd759e88
-- https://www.postgresql.org/docs/9.6/unaccent.html
CREATE EXTENSION IF NOT EXISTS unaccent;
-- create the function in the public schema
CREATE OR REPLACE FUNCTION public.slugify(
v TEXT
) RETURNS TEXT
LANGUAGE plpgsql

Remove $decimal from express json response

Simple but effective way to remove recursively all the annoying $decimal key when using res.json.

It's a simple regex that cleans the response object as a json before sending.

Google Cloud Monitoring/Alert Notification Webhook to Discord

I was struggling to find the webhook API documentation, if someone know where it is, please share!

I've created a simple google cloud function (index.js) with NodeJS to push the monitoring alert to Discord.

You can also find a webhook body data as an example and a typescript interface.

kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@shadowlik
shadowlik / rabbitmq.txt
Created October 9, 2019 17:40 — forked from sdieunidou/rabbitmq.txt
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
@shadowlik
shadowlik / README.md
Last active October 4, 2019 14:07
Comandos úteis - Kubernetes e Docker

Docker

Remover todas as imagens não usadas

rmi $(docker images | grep '^' | awk '{print $3}')

Remover todos os volumes não usados

docker volume rm $(docker volume ls -qf dangling=true)

Kubernetes

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@shadowlik
shadowlik / mod_k2_content_.idea_.name
Created November 11, 2014 16:16
Template com carousel bootstrap para mod_k2_content
mod_k2_content