Skip to content

Instantly share code, notes, and snippets.

View k-msalehi's full-sized avatar
🎵
What's happening?

Mohammad Salehi k-msalehi

🎵
What's happening?
View GitHub Profile
@k-msalehi
k-msalehi / EnDigitsToPersian-without-toLocalString.js
Last active April 15, 2024 13:49
convert english numbers to persian with thousand seperator (without tolocalstring)
function numberToPersian(number) {
let numberToString = number.toString();
let result = "";
const farsiDigits = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
if (numberToString.length >= 4) {
let toPersian = numberToString
.split("")
.map((x) => farsiDigits[x])
.join("");
@k-msalehi
k-msalehi / enDigitsToFa.js
Last active April 24, 2024 12:04
Convert English digits to persian digits or persian words
// with thousand separator
const convertToPersianDigits = (number) => number.toLocaleString('fa-IR')
// without thousand separator
const convertToPersianDigitsNoDec = (string) => string.toLocaleString('fa-IR', {useGrouping: false})
// Keep non numeric characters intact and convert english digits to persian
function convertToPersianDigits(input) {
// Convert input to a string
input = input.toString();
const url = new URL(window.location);
url.searchParams.set('someQueryParameter', 'someValue');
window.history.pushState(null, '', url.toString());
@k-msalehi
k-msalehi / emalls woo api.php
Last active April 15, 2024 13:51
emalls woo api
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://example.com',
'ck_xxxxxxxxxxxxxxxxxxxx',
'cs_xxxxxxxxxxxxxxxxxxxx',
[
@k-msalehi
k-msalehi / opcache.ini
Last active January 31, 2022 07:17 — forked from rohankhudedev/opcache.ini
Best Zend OpCache Settings / Tuning / Configurations
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=1
; The OPcache shared memory storage size.
opcache.memory_consumption=768
@k-msalehi
k-msalehi / LineCounter.php
Last active October 13, 2018 17:36
Count number of lines by suffix of files
<?php
/**
* get files in folders and subfolders with $extensions extensions in $path.
* @param array $extentios
* @param string $path optinal. default is path of execution directory
*/
//default path is current directory and sub directories
function listFolderFiles($extensions ,$path = '.')
{
//files to count line numbers sort in $files