Skip to content

Instantly share code, notes, and snippets.

View fhferreira's full-sized avatar
🏠
Home-Office since 2005

Flávio H. Ferreira fhferreira

🏠
Home-Office since 2005
View GitHub Profile
@fhferreira
fhferreira / nginx-proxy.conf
Created August 16, 2019 02:52
Proxy nginx to use Google Tag Manager
# Google Analytics Bypassing Adblockers
## Client
change www.googletagmanager.com => your.domain.com
```
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://your.domain.com/gtag/js?id=UA-123456789-1"></script>
```
@fhferreira
fhferreira / RetryAllFailedJobsCommand.php
Created December 8, 2023 04:01 — forked from ulcuber/RetryAllFailedJobsCommand.php
Laravel Horizon. Retry all of the failed jobs like one in the horizon dashboard
<?php
namespace App\Console\Commands\Horizon;
use Illuminate\Console\Command;
use Illuminate\Queue\Failed\FailedJobProviderInterface;
use Laravel\Horizon\Contracts\JobRepository;
use Laravel\Horizon\Jobs\RetryFailedJob;
class RetryAllFailedJobsCommand extends Command
@fhferreira
fhferreira / duplicated.php
Created April 15, 2024 20:55
replaced duplicated spaces with PHP
<?php
//Replacing multiple spaces with a single space simple single line of php code:
$output = preg_replace('/\s+/', ' ', $input);
//This mean that spaces, tabs or line breaks (one or more) will be replaced by a single space.
//Replace multiple spaces with one space:
$output = preg_replace('/\s+/', ' ', $input);
//Replace one or multiple tabs with one space:
$output = preg_replace('/\t+/', ' ', $input);
@fhferreira
fhferreira / test.php
Created February 22, 2024 19:39 — forked from claudiosanches/test.php
Regex for test credit card brand
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@fhferreira
fhferreira / numerology.php
Created January 29, 2024 11:49 — forked from mateuslopes/numerology.php
PHP Numerology Calculator
<?php
class NumerologyCalc {
const BASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const VALID_FINAL_NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44];
public $numerology = null;
function __construct($input = "", $show = false) {
@fhferreira
fhferreira / crawler.php
Created October 11, 2023 19:07 — forked from krakjoe/crawler.php
parallel Futures, Channels (buffered, unbuffered, synchros), Events using parallel producer/consumer pattern
<?php
use \parallel\{Runtime, Future, Channel, Events};
/* usage php crawler.php [http://example.com] [workers=8] [limit=500] */
$page = $argv[1] ?: "https://blog.krakjoe.ninja"; # start crawling this page
$workers = $argv[2] ?: 8; # start this number of threads
$limit = $argv[3] ?: 500; # stop at this number of unique pages
$timeout = $argv[4] ?: 3; # socket timeout for producers
@fhferreira
fhferreira / example.php
Created October 11, 2023 19:07 — forked from krakjoe/example.php
Executor Service with Parallel and Channels
<?php
use \parallel\{Runtime, Channel};
class ExecutorService {
public function __construct(int $workers, string $channel = __CLASS__, int $backlog = Channel::Infinite) {
if ($backlog == 0) {
/*
* execute() will block until a worker is ready
*/
<?php
try{
$url = "https://api.listclean.xyz/v1/";
$endpoint = 'verify/email/';
$api_key = YOUR_API_KEY;
@fhferreira
fhferreira / SecureHeaders.php
Created July 21, 2023 04:27 — forked from DavidMRGaona/SecureHeaders.php
Laravel Middleware to add/remove headers
<?php
namespace App\Http\Middleware;
use Closure;
class SecureHeaders
{
// Enumerate unwanted headers
private $unwantedHeaderList = [
#!/bin/bash
# Be Sure To Change This!
Client_Key=A2a9SfT4NeFBl6df5cu42
API_Key=mnqWGdu4OfLBwwJPee6cpjkeY70qv9mKicqZYvtHJ
droplets()
{
echo "Your current droplets:"
All_Droplets=`curl -s "https://api.digitalocean.com/droplets/?client_id=$Client_Key&api_key=$API_Key"`
echo $All_Droplets | sed -e 's/,/\n/g' | sed -e 's/{/\n/g' | sed -e 's/}/\n/g' | sed -e 's/"//g'