Skip to content

Instantly share code, notes, and snippets.

View D1360-64RC14's full-sized avatar
👨‍💻
Learning

Diego Garcia D1360-64RC14

👨‍💻
Learning
View GitHub Profile
@D1360-64RC14
D1360-64RC14 / metrics
Last active August 7, 2026 17:14
Store Prometheus metrics in sqlite database, on-the-fly.
#!/usr/bin/env python3
"""
metrics - append a Prometheus-style metric line to a SQLite database.
Usage:
metrics [--database=metrics.sqlite] [--group=default] <metric_name>{<flags>} <value> [timestamp]
Metric line format (split across argv, not a single quoted string):
name{flag1="v1",flag2="v2"} value [timestamp]
@D1360-64RC14
D1360-64RC14 / README.md
Last active August 5, 2026 13:03
Linux/Firewall configuration to setup a VPS relay/entering node through WireGuard. IPv4 and IPv6.

Wireguard VPS Relay

Problem

I had the following problem:

I want to host my own servers (aka. homelab), but I live behind CGNAT, and the ISP don't want to allow 80/443 ports.

Solution

@D1360-64RC14
D1360-64RC14 / 10-secured.conf
Last active July 14, 2026 20:55
Minimum secure sshd_config. Place at "/etc/sshd_config.d/10-secured.conf"
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
@D1360-64RC14
D1360-64RC14 / README.md
Created July 3, 2026 15:06
Laravel Queue and Schedule timer/services for SystemD, templated

How to use

Install

  1. Copy/install the .service and .timer files into /etc/systemd/system/;
  2. Update their permission to 644 (u=rw,g=r,o=r; -rw-r--r--);
    • chmod 644 /etc/systemd/system/laravel.queue@.service
    • chmod 644 /etc/systemd/system/laravel.schedule@.service
    • chmod 644 /etc/systemd/system/laravel.schedule@.timer
  3. Enable the respective service needed.
@D1360-64RC14
D1360-64RC14 / watch.sh
Last active May 10, 2026 17:44
Watch script in bash to rebuild and run a program. Made for compiled languages, like go.
#!/bin/bash
# BEGIN Configuration
WATCH_PATHS=($@)
BUILD_COMMAND="go build ./cmd/main"
RUN_COMMAND="./main"
# END Configuration
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solicite seu Orçamento</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Barlow:wght@400;500;600&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/RobinHerbots/Inputmask@5.0.9/dist/inputmask.min.js" integrity="sha256-C6bCPhHNXLmv0/IqH2qbROMoFXPRhWtcMSxkYgQ3a3I=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js"></script>
@D1360-64RC14
D1360-64RC14 / LexorankOrdering.php
Last active April 13, 2026 11:41
Lexorank orderer function in PHP. With helper trait for Laravel.
<?php
/**
* Trait LexorankOrdering to be used with Laravel framework.
*
* It must be used (`use LexorankOrdering;`) inside the model that supports the
* lexorank ordering, attaching helper methods to it.
*
* The lexorank column must be a varchar, with enough space to store the
* lexorank. `varchar(32)` is recomended.
@D1360-64RC14
D1360-64RC14 / README.md
Created March 20, 2026 13:48
Extrair todas as notas técnicas NFe
@D1360-64RC14
D1360-64RC14 / StructMap.php
Last active February 10, 2026 16:59
PHP class to filter entire structs using dot array accessors (array->get('some.list.*.name')) and fluent API. PHP 8.0+.
<?php
// Copyright 2026 Diego Garcia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@D1360-64RC14
D1360-64RC14 / demo.php
Last active January 26, 2026 16:57
DEMO. Using PHP Attributes and Reflection to extract model's tables names, ready to be queried.
<?php
#[Attribute(Attribute::TARGET_PROPERTY)]
class Column
{
public function __construct(
public ?string $name = null
) {}
}