Skip to content

Instantly share code, notes, and snippets.

View petrusnog's full-sized avatar
🏠
Coding from home

Petrus Nogueira petrusnog

🏠
Coding from home
  • Fortaleza - CE
View GitHub Profile
@petrusnog
petrusnog / azure-ad-login-curl.php
Last active December 20, 2023 18:11
Two ways to login with AAD, one using cURL, another using GuzzleHttp. For the guzzle method, there's a composer.json file indexed.
<?php
$tenantId = 'common';
$authenticationUrl = "https://login.microsoft.com/{$tenantId}/oauth2/v2.0/authorize";
$clientId = "{seu-client-id}";
$clientSecret = '{seu-client-secret}';
$redirectUri = '{seu-redirect-uri}';
$scope = "openid profile offline_access User.Read"; // Escopo de permissões necessárias
$authenticationUrl .= "?client_id=$clientId&redirect_uri=$redirectUri&response_type=code&scope=$scope";
if (isset($_GET['code'])) {
@petrusnog
petrusnog / formatBrazilianPhone.php
Created April 27, 2023 03:28
Retrieves the phone structure from a given phone number.
<?php
/**
* @param string $phone_number
* @return string
*/
function formatBrazilianPhone($phone_number)
{
$phone_number = preg_replace( '/[^0-9]/', '', $phone_number );
$phone_object = [
@petrusnog
petrusnog / curl_request_logs.php
Created March 24, 2023 01:09
Gets PHP cURL requisition logs
<?php
$curlHandle = curl_init();
$curl_setopt_array = [
CURLOPT_URL => 'https://google.com.br',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
@petrusnog
petrusnog / getremotelogs.py
Last active August 5, 2022 17:00
A Python automation for getting access logs massively from a remote server.
#!/usr/bin/env python3
import os
import sys
import getopt
print("""
╔═╗╔═╗╔╦╗ ╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗ ╦ ╔═╗╔═╗╔═╗
║ ╦║╣ ║ ╠╦╝║╣ ║║║║ ║ ║ ║╣ ║ ║ ║║ ╦╚═╗
╚═╝╚═╝ ╩ ╩╚═╚═╝╩ ╩╚═╝ ╩ ╚═╝ ╩═╝╚═╝╚═╝╚═╝
""")
@petrusnog
petrusnog / delete_user_wp.sql
Last active April 4, 2022 16:15
Completely delete an user from a WordPress database. (Switch 0 to your user id)
DELETE FROM wp_users WHERE ID = 0;
DELETE FROM wp_usermeta WHERE user_id = 0;
DELETE FROM wp_comments WHERE user_id = 0;
@petrusnog
petrusnog / Dockerfile
Last active March 29, 2022 02:31
Desenvolvendo container com versões específicas de tecnologias (EM DESENVOLVIMENTO)
FROM ubuntu
RUN apt-get update
RUN apt-get install -y sudo\
wget\
file\
libapr1-dev\
libaprutil1-dev\
g++\
make\
libc6-dev\
@petrusnog
petrusnog / PaulistaGenerator.md
Last active February 23, 2022 14:42
Gerador de paulistas mediante cobertura de cidades

Paulista Generator

Gerador de paulistas mediante cobertura de cidades

How to use

python3 --version
pip --version
pip install fordev
@petrusnog
petrusnog / substrings.py
Created February 10, 2022 04:22
Script to study about string indexes and substrings.
def set_line(word_length):
line = '+'
line += word_length * '---+'
line += '\n'
return line
def set_letters(word):
count = 1
letters = ''
@petrusnog
petrusnog / get_user_by_meta.sql
Created August 9, 2021 19:46
SQL that filters users by some metadata existance.
SELECT u.ID, u.user_login, u.user_nicename, u.user_email
FROM wp_users u
INNER JOIN wp_usermeta m ON m.user_id = u.ID
WHERE m.meta_key = 'billing_rg'!='';
@petrusnog
petrusnog / ghost_client.py
Created March 27, 2021 04:55
Gerador de dados cadastrais de usuario que mora em São Paulo.
# pip install fordev
from fordev.generators import people
searching_valid_cep = True
print('Aguarde, estou gerando dados de um cliente fantasma na cidade de São Paulo...')
while(searching_valid_cep) :
new_people = people(uf_code='SP')
if (new_people.get('cidade') == 'São Paulo') :