This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
file_url="FILE_URL" | |
file_name="fileName" | |
for i in 1 2 3 4; do | |
wget —limit-rate=5m -O $file_name $file_url | |
sudo rm -rfv $file_name | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove UTF8 Bom | |
function removeUtf8Bom($text) | |
{ | |
$bom = pack('H*', 'EFBBBF'); | |
$text = preg_replace("/^$bom/", '', $text); | |
return $text; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatNumber(num) { | |
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') | |
} | |
console.log(formatNumber(1234)) // 1,234 | |
console.log(formatNumber(123456)) // 123,456 | |
console.log(formatNumber(123456789)) // 123,456,789 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((colors, query) => | |
Array.from(document.querySelectorAll(query)).forEach(cell => | |
cell.setAttribute( | |
"fill", | |
`#${colors[Math.floor(Math.random() * colors.length)]}` | |
) | |
))(["acd5f2", "7fa8c9", "527ba0", "254e77"], ".user-contrib-cell"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Farhad Hassan Pour | |
* Author Url: https://farhadhp.ir | |
* Description: Convert Latin numbers to persian number | |
*/ | |
function convert_numbers_to_persian($srting,$toPersian=true) | |
{ | |
$en_num = array('0','1','2','3','4','5','6','7','8','9'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Farhad Hassan pour | |
* Author url: https://farhadhp.ir | |
* Description: floor — Round fractions down | |
*/ | |
// example | |
echo floor(4.9); // Output: 4 | |
echo floor(8.2); // Output: 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Get current url in wordpress | |
* @return url | |
*/ | |
function get_current_url(){ | |
global $wp; | |
return add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Author : Farhad Hassan Pour (https://farhadhp.github.io/) | |
*/ | |
function has_duplicated_array($arr) { | |
$count_value = array_count_values($arr); | |
rsort($count_value); | |
return $count_value[0] > 1; | |
} |