Skip to content

Instantly share code, notes, and snippets.

View ryanaby's full-sized avatar

Ryan Aby ryanaby

View GitHub Profile
@ryanaby
ryanaby / custom-upload-directory.php
Created March 15, 2025 15:09
WP Multisite Shared Upload Directory
<?php
/*
Plugin Name: Custom Upload Folder
Description: Force all network uploads to reside in "wp-content/uploads", and by-pass "files" URL rewrite for site-specific directories.
Version: 1.0
Author: Aby
*/
function ab_shared_media_uploads( $dirs ) {
$dirs['baseurl'] = network_site_url( '/wp-content/uploads' );
@ryanaby
ryanaby / function.php
Created March 13, 2025 16:07
Text to image PHP
/**
* Creates an images containing the specified text.
* Useful for sending errors back to the client.
* Source : https://starbeamrainbowlabs.com/blog/article.php?article=posts%2F380-php-text-to-image.html
* @package core
* @param string $text The text to include in the image.
* @param int $target_size The target width to aim for when creating
* the image. Not not specified, a value is
* determined automatically.
* @return resource The handle to the generated GD image.
@ryanaby
ryanaby / hosts
Created November 17, 2024 20:29
Host File to Bypass Binance Access from ISP Blocks
# ---------------------------------------------------
# Binance
# ---------------------------------------------------
3.165.190.67 academy.binance.com
3.165.190.62 academy.binance.com
3.165.190.41 academy.binance.com
3.165.190.45 academy.binance.com
18.165.183.45 accounts.binance.com
18.165.183.97 accounts.binance.com
18.165.183.80 accounts.binance.com
@ryanaby
ryanaby / gist:d46cbbfbe9e8525946b2faefc9b612db
Created March 12, 2024 17:46
Create SSH key for Single Machine with Multiple Github Repository
1. Generate SSH key
ssh-keygen -t rsa -b 4096 -f /root/.ssh/id_rsa_1
2. Create config file in /root/.ssh/config
Host github.com-id_rsa_1
HostName github.com
IdentityFile /root/.ssh/id_rsa_1
IdentitiesOnly yes
@ryanaby
ryanaby / class-EMLParser.php
Created November 5, 2023 17:42
EMLParser without install extension mailparse
<?php
class EMLParser {
private $headers = [];
private $body = '';
public function __construct($emlFilePath) {
$emlContent = file_get_contents($emlFilePath);
$this->parseEMLContent($emlContent);
}
@ryanaby
ryanaby / mixNmatchArray.php
Created November 2, 2022 17:41
Mix n match single dimension array to associative array
<?php
// Mix n match single dimension array to associative array
$sourceArray = ['banana', 'apple', 'strawberry'];
do {
$array = mixnmatch($sourceArray);
} while(count($array) < count($sourceArray));
@ryanaby
ryanaby / convert.php
Created August 23, 2022 20:14
Batch Convert MOV to MP4
<?php
// Put this file into your *.MOV directory
$list = glob(__DIR__ ."/*.MOV");
foreach($list as $item) {
$name = basename($item);
$output = str_replace('MOV', 'mp4', $name);
$command = "ffmpeg -i " . $name . " -an -vcodec h264 -acodec aac " . $output;
@ryanaby
ryanaby / TwitterController.php
Created August 22, 2022 18:33
Socialite dynamic configuration
<?php
namespace App\Http\Controllers;
use App\Models\TwitterApp;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session;
use Laravel\Socialite\Facades\Socialite;
@ryanaby
ryanaby / override.js
Created August 18, 2022 19:53
Override history back button
<script language='Javascript'>
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/history");
history.pushState(null, document.title, location.pathname);
window.addEventListener("popstate", function() {
if(location.hash === "#!/history") {
history.replaceState(null, document.title, location.pathname);
setTimeout(function(){
location.replace("https://your-url-here-blablabla.com/");
@ryanaby
ryanaby / function.php
Created June 6, 2022 03:45
Usefull php functions
<?php
/*
array_merge_recursive with unique value
Reference : https://stackoverflow.com/questions/25712099/php-multidimensional-array-merge-recursive
*/
function array_merge_recursive_ex(array $array1, array $array2)
{
$merged = $array1;