Skip to content

Instantly share code, notes, and snippets.

View lsgalves's full-sized avatar
🧯

Leonardo Galves lsgalves

🧯
  • Skymail
  • São Paulo, Brazil
  • 19:12 (UTC -03:00)
View GitHub Profile
@lsgalves
lsgalves / SkymailDNS.ps1
Last active July 12, 2024 12:02
Skymail DNS script for win-acme
<#
.SYNOPSIS
Add or remove a DNS TXT record to Skymail
.DESCRIPTION
Note that this script is intended to be run via the install script plugin from win-acme via the batch script wrapper.
As such, we use positional parameters to avoid issues with using a dash in the cmd line.
.PARAMETER RecordName
The fully qualified name of the TXT record.
@lsgalves
lsgalves / check-storage-capacity.py
Last active April 29, 2024 21:44
CloudStack primary storage monitoring
#!/usr/bin/env python3
import json
import sys
import cs
def get_usage_percent(storage: dict) -> float:
allocated_space = float(storage['disksizeallocatedgb'].split()[0])
unallocated_space = float(storage['disksizeunallocatedgb'].split()[0])
usage = (allocated_space / (allocated_space + unallocated_space)) * 100
@lsgalves
lsgalves / dns_skymail.sh
Created October 14, 2023 19:20
Skymail DNS provider for acme.sh DNS API
#!/usr/bin/env sh
#
#SKYMAIL_Token="sdfsdfsdfljlbjkljlkjsdfoiwje"
#
#SKYMAIL_Email="xxxx"
#SKYMAIL_Password="xxxx"
#SKYMAIL_Secret="xxxx"
@lsgalves
lsgalves / google-docs.js
Last active December 24, 2023 04:04
My scripts for Google Docs Apps Script.
/**
* Sums cell values in a range if they have the given background color
*
* @param {Array<number>} range Values of the desired range
* @param {String} colorRef Label to color reference to match values on range
*
* @return {number} Sum of all cell values matching the condition
* @customfunction
*/
function sumByColor(range, colorRef) {
@lsgalves
lsgalves / tinytobind.py
Created August 14, 2023 03:30
Convert TinyDNS zone file to Bind format.
#!/usr/bin/env python3
import sys
records = []
if len(sys.argv) < 2:
print('Usage: tinytobind.py ZONEFILE')
sys.exit(0)
with open(sys.argv[1], 'r') as zonefile:
@lsgalves
lsgalves / setup-fb-odbc.sh
Last active April 3, 2023 09:50
Install latest Firebird ODBC Driver (2.0.5) on RHEL
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]
then echo "Need run as root"
exit 1
fi
# Install libfbclient
@lsgalves
lsgalves / firebird-cheat-sheet.md
Last active May 11, 2022 15:42
Firebird Cheat Sheet

Firebird Cheat Sheet

Firebird Tracing presentation

List open transactions to connected database

SELECT * FROM MON$TRANSACTIONS WHERE MON$ATTACHMENT_ID <> CURRENT_CONNECTION;
@lsgalves
lsgalves / docker-compose.yml
Last active October 7, 2023 21:21
Wordpress Docker Enviroment
version: "3"
services:
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- wordpress_files:/var/www/html
ports:
- "8080:80"