Skip to content

Instantly share code, notes, and snippets.

View saeedvir's full-sized avatar
🎯
Focusing

saeed abdollahian saeedvir

🎯
Focusing
View GitHub Profile
@saeedvir
saeedvir / strip_tags.js
Last active September 27, 2025 03:01
secured and improved version of strip_tags php function in javascript
/*
php version : https://gist.github.com/saeedvir/f00d76c33a95c1fbecb297df4a286ebc
*/
function strip_tags(input, allowed) {
if (input == null || input === '') return '';
// Convert to string and handle non-string inputs safely
const str = String(input);
// Parse allowed tags into a Set for faster lookup
@saeedvir
saeedvir / strip_tags_secure.php
Last active September 27, 2025 03:01
secure strip_tags function
<?php
/*
javascript version : https://gist.github.com/saeedvir/d9b80ff857481dcce26b7610442dfb3f
*/
function strip_tags_secure($input, $allowed = '', $options = []) {
if ($input === null || $input === '') {
return '';
}
/*
const scripts = [
'https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js', // ✅ Valid
'https://example.com/nonexistent-script.js', // ❌ 404 — THIS WILL BREAK SEQUENCE
'https://cdn.jsdelivr.net/npm/[email protected]/moment.min.js' // ⛔ Won't load due to previous error
];
try {
const loadedScripts = await loadScriptsSequentiallyEnhanced(scripts, { timeout: 5000 });
@saeedvir
saeedvir / pint.json
Created June 8, 2025 04:06 — forked from JustSteveKing/pint.json
Laravel Pint configuration
{
"preset": "per",
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_syntax": true,
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,
@saeedvir
saeedvir / injectResource.js
Created May 1, 2025 03:35
Injects an external resource (script or stylesheet) into the current HTML document
/**
* Injects an external resource (script or stylesheet) into the current HTML document
*
* @param {string} url - The URL of the resource to inject
* @param {string} type - The type of resource ('script' or 'style')
* @param {function} [callback] - Optional callback function (only for scripts) that executes after loading
*/
function injectResource(url, type, callback) {
// Variable to hold the DOM element we'll create
let element;
@saeedvir
saeedvir / Script_Loading_Example.html
Last active February 11, 2025 03:04
This JavaScript snippet dynamically loads external scripts with a delay after the page has fully loaded.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Script Loader Example</title>
</head>
<body>
<h1>Script Loading Example</h1>
@saeedvir
saeedvir / density_of_points.php
Created December 5, 2024 04:28
how with php Get the density of points in the coordinate plane?
<?php
$points = [
[3, 4], [7, 9], [12, 15], // Coordinates
[18, 5], [20, 25]
];
$grid_size = 10;
$grid_density = [];
@saeedvir
saeedvir / refreshAndCleanup.bat
Created December 2, 2024 05:10
refresh and cleanup windows and network
@echo off
:: ============================
:: Batch File for System Cleanup and Memory Release
:: ============================
:: Ensure the script is run as administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Please run this script as administrator.
pause
@saeedvir
saeedvir / web.php
Last active November 26, 2024 20:19
Laravel QR-Code Verification Code
<?php
// composer require sebastiandevs/simplethenticator
use Illuminate\Http\Request;
use src\SimpleAuthenticator;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
$auth = new SimpleAuthenticator(6, 'SHA1');
try
{
@saeedvir
saeedvir / .htaccess
Created March 12, 2024 05:21 — forked from gaelbillon/.htaccess
custom htaccess for speed, cache, gzip, ETags, etc
### ENVIRONMENT VARIABLES ###
#SetEnv PHP_VER 5
#SetEnv REGISTER_GLOBALS 0
### MAIN DEFAULTS ###
Options All -Indexes
DirectoryIndex index.html index.htm index.php
AddDefaultCharset UTF-8
### MIME TYPES ###