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
<!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
) {}
}
@D1360-64RC14
D1360-64RC14 / bcmath_rpn_calculator.php
Created October 10, 2025 18:52
A Reverse Polish Notation expression calculator in PHP 8.4 using BCMath.
<?php
function bc(string $exp): string
{
$stack = [];
$tokens = explode(' ', $exp);
foreach ($tokens as $token) {
if (strlen($token) <= 0) continue;
@D1360-64RC14
D1360-64RC14 / install-go.sh
Last active September 7, 2025 20:44
Download and install golang version into /opt/go folder. Supports version managing though alternatives command.
#!/bin/env bash
set -e
DOWNLOAD_URL='https://go.dev/dl/go1.25.1.linux-amd64.tar.gz'
# goM.mm.ff.linux-amd64.tar.gz
GOLANG_TAR_GZ="$(basename $DOWNLOAD_URL)"
# goM.mm.ff.linux-amd64
GOLANG="$(basename $GOLANG_TAR_GZ .tar.gz)"
@D1360-64RC14
D1360-64RC14 / README.md
Created August 25, 2025 18:34
PHP 8.4 -- Benchmark between `get_class()` vs `instanceof`.

PHP 8.4 -- Benchmark of get_class() vs instanceof.

Result from onlinephp.io (link w/ code):

float(0.5350112915039062)
float(0.308990478515625)
float(0.5180835723876953)
float(0.2639293670654297)
float(0.5099773406982422)
@D1360-64RC14
D1360-64RC14 / unwrapE.php
Last active August 21, 2025 19:21
Function to unwrap scientific notation into float number. Made with PHP 8.4.3.
<?php
function unwrapE(float $value)
{
$strVal = strval($value);
if (!str_contains($strVal, 'E')) {
return $strVal;
}
@D1360-64RC14
D1360-64RC14 / rm-useless-gitkeeps.sh
Created July 25, 2025 19:24
Delete all .gitkeeps within a folder already with files.
for ign in $(find . -name '.gitkeep' ! -path './vendor/*'); do
if [[ $(ls $(dirname $ign) | wc -l | tr -d ' ') > 0 ]]; then
rm $ign
fi;
done