Skip to content

Instantly share code, notes, and snippets.

View terremoth's full-sized avatar
🌄
Open to work. #HireMe #OpenToWork

Lucas M. Dutra terremoth

🌄
Open to work. #HireMe #OpenToWork
View GitHub Profile
@terremoth
terremoth / gui-example.c
Last active March 16, 2025 13:08
Simple input and button with pure C + Win32 API
#include <windows.h>
#define ID_EDITBOX 1001
#define ID_BUTTON_OK 1002
void DrawCustomButton(LPDRAWITEMSTRUCT lpDrawItem) {
COLORREF bgColor = RGB(255, 165, 0); // orange
COLORREF textColor = RGB(128, 128, 128); // grey
@terremoth
terremoth / fibonacci.xsl
Last active January 11, 2025 17:48
XSLT + XML are turing complete
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Fibonacci Sequence</title>
</head>
<body>
<h1>Fibonacci Sequence</h1>
@terremoth
terremoth / CollectionPaginate.php
Created January 3, 2025 11:59
Laravel Collection Pagination
<?php
namespace App\Resources;
use Illuminate\Container\Container;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
class CollectionHelper
@terremoth
terremoth / helpers.php
Created January 3, 2025 11:56
Some useful PHP helper functions
<?php
// Don't just COPY everything to your codebase without looking the need of these functions.
// Helpers functions can be a cancer if you don't have any idea where to put and why.
const DS = DIRECTORY_SEPARATOR;
function echoln($str) {
echo $str . PHP_EOL;
}
@terremoth
terremoth / reconfigure-php-ini.sh
Created January 3, 2025 11:38
Script to reconfigure and increase PHP.ini settings (FPM)
#!/usr/bin/env sh
# The FPM ini file, and not the CLI one
ini_file=$(php -i | grep "Loaded Configuration File" | awk -F ' => ' '{print $2}' | sed 's/cli/fpm/g')
echo $ini_file
sudo sed -i 's/memory_limit\s*=.*/memory_limit = 256M/g' $ini_file
cat $ini_file | grep memory_limit
sudo sed -i 's/upload_max_filesize\s*=.*/upload_max_filesize = 3G/g' $ini_file
@terremoth
terremoth / versions.sh
Created January 3, 2025 11:36
web development tools versions for diagnosis
#!/bin/sh
uname -a;
lsb_release -a;
php --version;
mysql --version;
composer --version;
echo nodejs $(node --version);
echo npm $(npm --version);
openssl version;
ssh -V;
@terremoth
terremoth / pageid.vbs
Created December 27, 2024 21:03
Get POST ID from page
' Solicita ao usuário a URL
url = InputBox("Insira a URL da página:", "Capturar POST ID")
' Verifica se a URL foi inserida
If url <> "" Then
' Cria o objeto para fazer a requisição HTTP
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
On Error Resume Next
' Faz a requisição GET
@terremoth
terremoth / pageid.ps1
Created December 24, 2024 14:02
get page id from URL
$url = $args[0]
try {
$response = Invoke-WebRequest -Uri $url
} catch {
Write-Output $_.Exception
if ($_.Exception.Response.StatusCode -eq "404") {
Write-Host "Error: Page does not exist"
} else {
Write-Host "Error: Page could not be processed" -ForegroundColor red -BackgroundColor black
@terremoth
terremoth / simple-mailer.php
Last active December 19, 2024 00:49
Perfect email config to use on mail() php function
<?php
$mail_to = filter_input(INPUT_POST, 'to', FILTER_VALIDATE_EMAIL);
$mail_subject = filter_input(INPUT_POST, 'subject', FILTER_SANITIZE_STRING);
$mail_message = filter_input(INPUT_POST, 'message'); // user can send HTML here
$from_name = 'Your Name';
$from_mail = '[email protected]';
if (!$mail_to || !$mail_subject || !$mail_message) {
die('Invalid data! Must contain a TO, SUBJECT and a MESSAGE at least');
@terremoth
terremoth / gta-sa-terremoth-starter-save.txt
Created November 30, 2024 21:55
GTA San Andreas Terremoth Starter Save Accomplishments
# GTA San Andreas Terremoth Master Save
- [x] without die
- [x] without being arrested
- [x] no cheats used
- [x] maximum lung capacity
- [x] maximum stamina
- [x] maximum muscle
- [ ] maximum respect