Skip to content

Instantly share code, notes, and snippets.

View adrianlzt's full-sized avatar

Adrián López adrianlzt

View GitHub Profile
#!/bin/bash
#
# Aplicación para editar un KV secret version 2 en Vault
#
path=$1
tmpfile=$(mktemp)
# Fetch the secret and write it to a temporary file
vault kv get -format=json $path | jq -er .data.data > $tmpfile
@adrianlzt
adrianlzt / aes_cryptojs_pycrypto.js
Last active March 8, 2024 05:02
Interoperable CryptoJS (defaults) <-> PyCrypto
/*
* CryptoJS by default:
* - uses CBC mode
* - pkcs7 for padding
* - evpKDF to extract key
* - part of the key is used as IV
* - before converting to base64 it makes "Salt__"+salt+encrypted_text
*/
var CryptoJS = require('crypto-js');
# Creamos una CA self-signed para generar los certificados de los clientes VPN
resource "tls_private_key" "foo-vpn-ca-key" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "tls_self_signed_cert" "foo-vpn-ca" {
private_key_pem = tls_private_key.foo-vpn-ca-key.private_key_pem
subject {
@adrianlzt
adrianlzt / revprox.go
Created January 16, 2024 16:05 — forked from c0d3kid/revprox.go
Simple reverse proxy in Go (forked to adapt to Azure functions use-case)
package main
import (
"crypto/tls"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
)
@adrianlzt
adrianlzt / query.sql
Created February 9, 2023 08:11
Zabbix: PostgreSQL query to migrate the old item prototype macros ($1) to its discovery macro
WITH macro AS (
SELECT
itemid,
(regexp_matches(key_, '(\{#[^\}]*\})'))[1] AS m
FROM
items)
UPDATE
items
SET
name = regexp_replace(name, '(\$1)', macro.m)
@adrianlzt
adrianlzt / hx711-overlay.dts
Created March 26, 2020 15:19
Devicetree overlay for HX711 in Raspberry Pi Zero
/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target-path = "/";
#!/usr/bin/env python
"""
Script to handle keepalived notifications.
This script will be called by keepalived with three arguments:
- "GROUP" or "INSTANCE"
- name of the group or instance
- target state of the transition: "MASTER", "BACKUP", "FAULT"
The script should return 1 if the number of parameters is not 3, if the
target state is not "MASTER", "BACKUP" or "FAULT", or if the first parameter
@adrianlzt
adrianlzt / instructions.txt
Created July 9, 2020 07:07
CMDB not-complete build instructions
Download code from sourceforge (.tar.gz)
Deps needed:
https://bitbucket.org/tecnoteca/cmdbuild-dependencies/downloads/
Uncompress and install:
bash install-artifacts.sh
Copy those deps to our m2 local cache:
rsync -a . $HOME/.m2/repository/
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
cryptography = "==2.8"
django = "==2.2.11"
[dev-packages]
@adrianlzt
adrianlzt / gitlab-automatic-upgrade.py
Created October 28, 2022 11:31
Script to upgrade gitlab from one version to the latest, using a backup and docker
#!/usr/bin/env python
# -*- coding: utf-8 -*
# vim:fenc=utf-8
#
# Script to upgrade gitlab from one version to the latest, using a backup and docker.
#
import os
import sys
import argparse