Skip to content

Instantly share code, notes, and snippets.

View sh-sh-dev's full-sized avatar

Shaygan Shokrollahi sh-sh-dev

  • Tehran
View GitHub Profile
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
class EncodeToWebp extends Command
{
@sh-sh-dev
sh-sh-dev / bot.php
Last active April 19, 2023 22:23
Get Telegram files direct link
<?php
// Configuration
$token = '123:abc';
$adminId = 123456;
$webhookSecret = 'random-long-text';
// Security
if ($_SERVER['REQUEST_METHOD'] !== 'POST')
@sh-sh-dev
sh-sh-dev / code-to-city.json
Created August 6, 2022 13:49
National code to city
{
"***": "اصفهان",
"169": "آذرشهر",
"170": "اسکو",
"149": "اهر",
"171": "بستان آباد",
"168": "بناب",
"136": "تبریز",
"545": "ترکمانچای",
"505": "جلفا",
@sh-sh-dev
sh-sh-dev / bin.php
Last active April 19, 2023 22:24
Simple request bin, works with Telegram Bot
<?php
$botToken = 'x';
$chatId = 1234;
$dontIncludeHeadersName = 'nh';
$separator = PHP_EOL;
$twoSeparator = $separator . $separator;
function bot($method, $data = null) {
global $botToken;
@sh-sh-dev
sh-sh-dev / subDomain.sh
Last active April 19, 2023 22:24
Apache subdomain creator bash script
#!/usr/bin/env bash
Domain='example.com' # root domain
Name=''
G='\033[0;32m'
N='\033[0m'
while [[ -z ${Name} ]]; do
echo "Enter Subdomain: (for example api)"
read Name
@sh-sh-dev
sh-sh-dev / GQRCode.php
Last active April 19, 2023 22:26
Generate QR Code using Google service
<?php
/**
* @param string $data The data to encode. Data can be digits (0-9), alphanumeric characters, binary bytes of data, or Kanji. You cannot mix data types within a QR code. Note that URLs have a 2K maximum length, so if you want to encode more than 2K bytes (minus the other URL characters).
* @param int $width
* @param int $height
* @param int $margin The width of the white border around the data portion of the code. This is in rows, not in pixels.
* @param string $errorCorrection QR codes support four levels of error correction to enable recovery of missing, misread, or obscured data. Greater redundancy is achieved at the cost of being able to store less data. The supported values: L (Allows recovery of up to 7% data loss) | M (15%) | Q (25%) | H (30%)
* @param string $encoding How to encode the data in the QR code. The available values: UTF-8 | Shift_JIS | ISO-8859-1
* @return string URL of the QR code.
*/
@sh-sh-dev
sh-sh-dev / Transfer.php
Last active July 29, 2019 21:40
transfer.sh
<?php
function Transfer($file, $name = null, $maxDownloads = null, $maxDays = null) {
$naf = false;
// If file doesn't exist, create a file with the $file content
if (!is_file($file)) {
$naf = true;
$cFile = !empty($name) ? $name : "Transfer-" . rand(1111, 9999) . ".tmp";
file_put_contents($cFile, $file);
$file = $cFile;
}
@sh-sh-dev
sh-sh-dev / DigikalaProduct.php
Last active July 25, 2022 06:06
Digikala Products Info
<?php
function digikalaProduct($PID) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.digikala.com/v1/product/$PID/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.81 Safari/537.36");
$output = curl_exec($ch);
curl_close($ch);
return $output;
@sh-sh-dev
sh-sh-dev / ZarinpalMessage.php
Last active November 6, 2020 07:15
Convert Zarinpal's status code to a human-readable message
<?php
function ZarinpalMessage($statusCode) {
$message = "تشخیص خطا امکان پذیر نبود";
switch ($statusCode) {
case -1:
$message = "اطلاعات ارسال شده ناقص است";
break;
case -2:
$message = "آیپی یا مرچنت کد صحیح نیست";
break;