Skip to content

Instantly share code, notes, and snippets.

View mahdyar's full-sized avatar
🌱

Mahdyar Hasanpour mahdyar

🌱
View GitHub Profile
@mahdyar
mahdyar / bustan.js
Last active May 29, 2024 10:27
پرکردن نظرسنجی‌های بوستان به صورت خودکار | Select Bustan survey checkboxes
var allInputs = document.getElementsByTagName("input");
for (var i = 0, max = allInputs.length; i < max; i++){
if (allInputs[i].type === 'checkbox' && allInputs[i].id.endsWith('_8'))
allInputs[i].checked = true;
}
@mahdyar
mahdyar / functions.php
Created September 2, 2022 20:26
Hide the default "Add to cart" button and show a customized "Add to cart" button in WooCommerce
<?php
/*
*
* Customized add to cart button for WooCommerce
* © mahdyar.me (hasanpour@mahdyar.me)
*
* Add this to the end of your template's "functions.php" file (without "<?php" at the begining of this file)
*
*/
@mahdyar
mahdyar / vo-asiatech.php
Created August 21, 2022 12:04
سرویس سامانه پیامکی آسیاتک برای افزونه پیام کوتاه WHMCS وهاب آنلاین
<?php
/*
*
*
*
* Developed by Mahdyar.me
* Contact: hi@mahdyar.me
*
@mahdyar
mahdyar / creditcardverification.php
Created May 9, 2022 17:02
بررسی صحت شماره کارت ایرانی در PHP
<?php
function validateCardNumber($cardNumber)
{
if (empty($cardNumber) || strlen($cardNumber) !== 16) {
return false;
}
$cardToArr = str_split($cardNumber);
$cardTotal = 0;
for ($i = 0; $i < 16; $i++) {
@mahdyar
mahdyar / cPanel.yml
Created September 8, 2021 20:56
Deploy to cPanel with GitHub Actions (FTP)
name: Deploy to cPanel
on:
push:
branches:
- master
jobs:
FTP-Deploy-Action:
name: FTP-Deploy-Action
runs-on: ubuntu-latest
steps:
wir(){
NAME=$(sed 's/ /_/g' <<< "$@")
INITIAL=$(echo $NAME | head -c 1)
IMDB_ID=$(curl -ks "https://v2.sg.media-imdb.com/suggestion/$INITIAL/$NAME.json" | jq -r '.d[0].id')
LINK="https://wir31.site/${IMDB_ID}/"
curl -ks "$LINK" | lynx -dump -nonumbers -listonly -stdin | grep -e '.mkv' -e '.mp4' | grep 'http://'
}
@mahdyar
mahdyar / persian-first-names.txt
Last active June 12, 2024 16:09
A list of common Persian/ Iranian first names in English
aaxar
abadaleh
abazar
abbas
abbasali
abbasi
abdolali
abdolamir
abdolghani
abdolhamid
@mahdyar
mahdyar / verify-github-webhook.php
Created August 13, 2021 10:09
Verify GitHub webhook request sha256 in PHP
<?php
// It's better to be exported as an environment variable or in a .env file.
define("SECRET", "<SECRET>");
$body = file_get_contents("php://input");
// $decodedBody = json_decode(urldecode($body));
if (verifySignature($body) !== false) {
// verified
@mahdyar
mahdyar / awesome-dark-theme-switch.markdown
Created May 11, 2021 09:28
Awesome Dark theme switch
@mahdyar
mahdyar / AllowedUsername.php
Last active May 5, 2024 19:18
Prevent your users to register with your route paths like login, or reserved usernames as their usernames in Laravel. More: https://blog.mahdyar.me/2021/04/18/route-paths-and-reserved-usernames-in-laravel/
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\Route;
class AllowedUsername implements Rule
{
/**