Skip to content

Instantly share code, notes, and snippets.

View arfar-x's full-sized avatar
🎯
Focusing

Alireza Farhanian arfar-x

🎯
Focusing
View GitHub Profile
before_script:
- |
# Validate repo's Git credentials.
git config user.email "$GITLAB_USER_EMAIL"
git config user.name "$GITLAB_USER_NAME"
git config credential.helper "store --file=.git/credentials"
git config http.sslverify "false"
.commit_version: &commit_version
- git remote set-url origin https://${GITLAB_USER_LOGIN}:${ACCESS_KEY}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
@arfar-x
arfar-x / commands.md
Last active November 13, 2024 13:36
Useful Shell scripts

Remove the files with creation time more than 10 days.

find . -type f -ctime +10 -exec rm {} +

Get creation time of a file in a human-readable format.

stat -c "%w"
@arfar-x
arfar-x / Group by conditions over separated documents.json5
Last active June 29, 2025 11:02
Join (Left outer join) operation in MongoDB
/*
من یک فیچری دارم بنام رسانه، هر کاربر میتونه یک رسانه بسازه و تعیین کنه که نوع اون چی باشه. هر رسانه فقط یک نوع میتونه داشته باشه، میتونه تلگرام باشه، بله باشه، یا وب‌هوک باشه.
هر رسانه در قالب یک داکیومنت جدا در مونگو ذخیره میشه. پس اگر یک کاربر دو نوع رسانه تلگرام و وب‌هوک رو خواست، ما براش دو تا درخواست توی دیبتابیس ذخیره میکنیم که یکیش نوع تلگرام هست (فیلد telegram_id داره) و یکی دیگه که نوع وب‌هوک هست (فیلد webhook_id داره).
حالا من میخوام چک کنم که کدوم کاربر ها دو نوع تلگرام و وب‌هوک رو دارن.
در نظر بگیر که هر نوع رسانه توی داکیومنت جدا ذخیره میشه.
*/
// MongoDB aggregations
[
{
$match: {
@arfar-x
arfar-x / .php-cs-fixer.php
Last active November 16, 2024 09:58
Coding style with PHP-CS-Fixer
<?php
/*
* @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/master/doc
*/
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
@arfar-x
arfar-x / Hyprland-Ubuntu.md
Created August 15, 2023 13:14 — forked from Vertecedoc4545/Hyprland-Ubuntu.md
Ubuntu 23.04 Build and Install instructions for Hyprland

Building on Ubuntu 23.04

You have 2 options, use the script descrived bellow or follow the instrutions

script in this gist if you want the source code

wget https://gist.githubusercontent.com/Vertecedoc4545/6e54487f07a1888b656b656c0cdd9764/raw/2c5e8ccb428fc331307e2f653cab88174c051310/build-ubuntu-23.sh
chmod +x build-ubuntu-23.sh
./build-ubuntu-23.sh
@arfar-x
arfar-x / docker-containers-run.sh
Last active October 4, 2023 08:30
Common Docker containers
##########################
## MySQL container
##########################
# Using binded data
docker run -d -p 3306:3306 -p 33060:33060 \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
--restart unless-stopped \
-v /var/lib/mysql/data:/var/lib/mysql \
-v /etc/mysql/config:/etc/mysql/conf.d \
@arfar-x
arfar-x / NormalizerNumbers.php
Created May 22, 2023 06:42
Normalize Persian and Arabic numbers to English in Laravel Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class NormalizeNumbersMiddleware