Skip to content

Instantly share code, notes, and snippets.

View tayyebi's full-sized avatar
📿
Grateful

MohammadReza Tayyebi tayyebi

📿
Grateful
View GitHub Profile
@tayyebi
tayyebi / autoload.php
Created April 17, 2025 07:27
PHP Auto-loader
<?php
spl_autoload_register(function (string $class_name): void {
$namespace = 'Gordarg';
if (strpos($class_name, $namespace) === 0) {
$class_file = ROOT_PATH . 'src';
$class_file .=
str_replace(
[$namespace, '\\'],
['', DIRECTORY_SEPARATOR],
$class_name
<?php
/*
Plugin Name: WP Admin Access Control
Description: Restricts access to wp-admin based on environment and custom header or referrer.
*/
function check_wp_admin_access() {
// Check if the current request is for wp-admin and the environment is production
if ((is_admin() || $GLOBALS['pagenow'] === 'wp-login.php') && getenv('WP_ENV') === 'production') {
// Retrieve the HTACCESS_TOKEN from the environment variable
@tayyebi
tayyebi / main.js
Created April 17, 2025 05:52
Smooth/Lazy navigation/loading (refresh-less, no post-back)
// Written with assistance of AI
document.dispatchEvent(new CustomEvent('contentLoaded'));
$('body').append('<div id="loading" style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%, -50%); background-color:#fff; padding:10px; border:1px solid #ccc; z-index:1000;">' + strings.loading + ' ... </div>');
// Function to show loading indicator
function showLoading() {
$('#loading').show();
}
//+------------------------------------------------------------------+
//| Tayyebi.mq5 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property version ""
#property strict
@tayyebi
tayyebi / MetaTrader.py
Created March 7, 2025 19:43
A python client for MetaTrader 5 terminal (disclaimer: only for educational purpose)
# Authors: MohammadReza Tayyebi, Microsoft Copilot, DeepSeek-V3
# Description: A Python script for algorithmic trading using MetaTrader 5 (MT5).
# Features: Symbol management, order management, real-time trading signals, manual command execution, and audible feedback.
import MetaTrader5 as mt5
import pandas as pd
import time
import threading
import winsound # For Windows beep sounds
import os # For non-Windows systems
@tayyebi
tayyebi / json-transformer.php
Last active December 30, 2024 12:49
Transforms JSON data by moving values between specified addresses within the JSON structure (destructive transformation).
<?php
/**
* JSON Transformer (Destructive)
*
* Copyright (c) 2025 Microsoft Copilot
* Copyright (c) 2025 Gemini (Google)
* Copyright (c) 2025 MohammadReza Tayyebi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@tayyebi
tayyebi / .gitignore
Last active October 11, 2024 10:29
Troubleshoot internet
traceroute_*.*
tshark_*.*
@tayyebi
tayyebi / Dockerfile
Last active July 16, 2024 17:34
Laravel 11.0 Dockerize
# Use PHP with Apache as the base image
# Note: `cb` stands for 'code-base'
FROM php:8.2-apache as cb
# Install Additional System Dependencies
RUN apt-get update && apt-get install -y \
libzip-dev \
zip
# Clear cache
@tayyebi
tayyebi / tk303.rs
Created July 16, 2024 06:55
Coban TK103 GPS Tracker Socket with RUST programming Language
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream, Shutdown};
extern crate reqwest;
extern crate serde_json;
use reqwest::blocking::Client;
use serde_json::json;
fn main() {
let api_url = "http://cb/api/heartbeats";
let ip_address = "0.0.0.0";
CREATE PROCEDURE FindMyData_String
-- https://stackoverflow.com/questions/9185871/how-do-i-search-an-sql-server-database-for-a-string
@DataToFind NVARCHAR(4000),
@ExactMatch BIT = 0
AS
SET NOCOUNT ON
DECLARE @Temp TABLE(RowId INT IDENTITY(1,1), SchemaName sysname, TableName sysname, ColumnName SysName, DataType VARCHAR(100), DataFound BIT, SqlQuery NVARCHAR(MAX))
INSERT INTO @Temp(TableName,SchemaName, ColumnName, DataType)