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 / 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
@terremoth
terremoth / handle_keypress_linux.php
Last active November 14, 2024 03:57
How to handle keypress non blocking real time get pressed keys on PHP (Linux only)
<?php
$stdin = fopen('php://stdin', 'r');
system('stty cbreak -echo');
stream_set_blocking($stdin, false);
while (1) {
if ($keypress = fgets($stdin)) {
@terremoth
terremoth / load-image-from-file-input.js
Last active November 6, 2024 01:45
Load or render image to <img> after input file load
/*
MIT License
Copyright (c) 2024 Terremoth (github.com/terremoth)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@terremoth
terremoth / db_connection_test_example.php
Last active October 3, 2024 21:41
Test connection to the database (mysql, pgsql etc) generalist script
<?php
// change credentials below and then run this php script from terminal
$driver = 'mysql';
$host = 'localhost';
$port = 3306;
$dbname = 'test';
$user = 'root';
$password = '';
@terremoth
terremoth / cf.php
Created June 18, 2024 22:41
Gets the input string from terminal stream and converts all the words to uppercase first chars
<?php
/**
* @author terremoth
* @license GNU General Public License, version 3
*/
$stream = file_get_contents("php://stdin");
$rows = explode("\n", $stream);
foreach ($rows as $row) {
@terremoth
terremoth / tricks.py
Created April 27, 2024 03:15
Python string formatting tricks
number: int = 1_000_000_000
print(number) # 1000000000
print(f'{number:_}') # 1_000_000_000
print(f'{number:,}') # 1,000,000,000
var: str = 'var'
print(f'{var:>20}')
@terremoth
terremoth / zeus.ps1
Last active March 14, 2024 02:36
Zeus Package Manager for Athena (PS2 - JS) first draft made in powershell
Write-Output "Zeus Package Manager for AthenaEnv PS2 libraries and Modules"
Write-Output "Made by github.com/terremoth"
$command = $args[0]
$library = $args[1]
$modulesDir = "athena_libs"
$libPath = "https://api.github.com/repos/terremoth/athenaenv-libs/contents/"+$library
$packageManagerFunction = "install", "update", "remove", "search"
$actualPath = $pwd
@terremoth
terremoth / bot_dfm.py
Last active April 6, 2024 03:25
Bot DFM
import pyautogui
import random
import time
import keyboard
screenWidth, screenHeight = pyautogui.size()
def random_sleep():
return random.uniform(0.625, 1.555)