Skip to content

Instantly share code, notes, and snippets.

View roshandelpoor's full-sized avatar
🎗️
Working From Company

Roshandelpoor Mohammad roshandelpoor

🎗️
Working From Company
View GitHub Profile
@roshandelpoor
roshandelpoor / README.md
Created September 15, 2024 08:25 — forked from Mehrdad-Dadkhah/README.md
High performance MySQL configuration with complete description and formulas.

MySQL Configuration Guide

Overview

This document provides a comprehensive explanation of the MySQL configuration settings used in the provided configuration file. The settings are optimized for a high-performance MySQL server with a focus on balancing memory usage, CPU utilization, and disk I/O efficiency. The comments in the file also include guidelines for adjusting parameters based on server hardware and workload characteristics.

General Settings

innodb_buffer_pool_size

  • Description: The size of the InnoDB buffer pool, which caches data and indexes from InnoDB tables.
@roshandelpoor
roshandelpoor / install_oci8_ubuntu20_php7.4.md
Created May 22, 2021 12:28 — forked from eSkiSo/install_oci8_ubuntu20_php7.4.md
Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4
@roshandelpoor
roshandelpoor / weight-utility.php
Created April 3, 2021 18:16 — forked from irazasyed/weight-utility.php
PHP: Utility function for getting random values with weighting.
<?php
/**
* getRandomWeightedElement()
* Utility function for getting random values with weighting.
* Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50)
* An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
* The return value is the array key, A, B, or C in this case. Note that the values assigned
* do not have to be percentages. The values are simply relative to each other. If one value
* weight was 2, and the other weight of 1, the value with the weight of 2 has about a 66%
* chance of being selected. Also note that weights should be integers.
@roshandelpoor
roshandelpoor / gist:4d2620d0afe88e1ea265d1e010b542d9
Created June 14, 2020 13:01 — forked from ebraminio/gist:5292017
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت، کاتلین، گرووی، راست، هسکل، ارلنگ، الکسیر
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@roshandelpoor
roshandelpoor / laravel-on-shared-hosting-htaccess.md
Created June 13, 2020 07:39 — forked from bladeSk/laravel-on-shared-hosting-htaccess.md
Deploying Laravel on a shared hosting using only .htaccess

Deploying Laravel on a shared hosting using only .htaccess

Making Laravel work on a shared hosting can be troublesome, because Laravel needs to have its document root set to the public directory. This may not be configurable by a user or even desirable, when the server is hosting multiple websites.

Here's a simple method using only a .htaccess file placed in Laravel's root directory - e.g. alongside app, bootstrap, config, ... No changes whatsoever are necessary to your code.

The file rewrites all the requests so that requesting /file.png would in fact return /public/file.png and anything else is routed to /public/index.php. This also ensures that nothing outside the public folder can be accessed, thereby protecting any sensitive files like .env or database/*.

The simple method

@roshandelpoor
roshandelpoor / install.txt
Created March 25, 2020 11:40 — forked from xiaol825/install.txt
How to install Chrome, ChromeDriver and Selenium on CentOS. Plus a sample scraping script.
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`

How to install OCI8 in windows

Instantclient Version 12.2.0.1.0

Xampp
php 7.2.4
Windows 10

Step 1

Download OCI8 2.1.8 - 7.2 Thread Safe (TS) x86

class KavenegarSms
{
private $fix_url = 'https://api.kavenegar.com/v1/';
private $api_key = 'YOUR-API-KEY';
function lunchCURL($url, $fields){
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, $url );
curl_setopt( $ch,CURLOPT_POST, true );
@roshandelpoor
roshandelpoor / PostMessageToSlackChannel.php
Created September 2, 2018 06:28 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar
@roshandelpoor
roshandelpoor / simple-json-reponse.php
Created August 26, 2018 11:24 — forked from james2doyle/simple-json-reponse.php
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($message = null, $code = 200)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");