Skip to content

Instantly share code, notes, and snippets.

View asfo's full-sized avatar
Verified profile

Asfo Zavala asfo

Verified profile
View GitHub Profile
/**
* This code is stored to save my exam to Wizeline that I took for fun, sorry Wizeline if someone finds this...
* Technically it could be pretty simple, a "join" of the array, then parse to int, then sum 1, then split again the numbers
* and parse each to integer, and that's it, but the rules are:
* the numbers are going to be between 1 and 9, no trailing zero...like: [1,2,3,4,5,6,7,8,9] in the array but...
* the array size can be up to 10,000 (10e4 -> 10 * 10 * 10 * 10) so we can have a digits.length of 10,000 which means, we can have
* a loooooooooooooot of numbers that are going to "sum" a really big number, if we use parseInt then, after the "join" we are going
* to end with a "32131e1221" which is something that we don't want to...
* and the "+1" rule so for example: [9,9,9] is converted to 999 + 1 = 1000 and we need to return [1,0,0,0]
*
@asfo
asfo / functions.php
Created September 6, 2023 01:32
Send WP Media to Another Server Using FTP
<?php
// Not working at the moment as this cause an issue with Elementor
function upload_to_ftp( $args ) {
$upload_dir = wp_upload_dir();
$upload_url = get_option('upload_url_path');
$upload_yrm = get_option('uploads_use_yearmonth_folders');
$settings = array(
'host' => '', // * the ftp-server hostname
'port' => 21, // * the ftp-server port (of type int)