Skip to content

Instantly share code, notes, and snippets.

View Arifursdev's full-sized avatar
🕷️

Arifursdev

🕷️
View GitHub Profile
@Arifursdev
Arifursdev / phpdangerousfuncs.md
Created January 14, 2024 18:09 — forked from mccabe615/phpdangerousfuncs.md
Dangerous PHP Functions

Command Execution

exec           - Returns last line of commands output
passthru       - Passes commands output directly to the browser
system         - Passes commands output directly to the browser and returns last line
shell_exec     - Returns commands output
\`\` (backticks) - Same as shell_exec()
popen          - Opens read or write pipe to process of a command
proc_open      - Similar to popen() but greater degree of control
pcntl_exec - Executes a program

Unicode cheat sheet

A curated list of unicode characters I want to have quick reference toward, including their literal presentation (where possible), description from the unicode table, various representations, and how to enter it as a Vim digraph*.

They are grouped by category, including a link to the relevant Unicode block. Also see the full list of Unicode blocks

<?php
function progressBar($current, $total, $barLength = 50) {
$progress = ($current / $total) * 100;
$progressBar = floor(($progress / 100) * $barLength);
$emptyBar = $barLength - $progressBar;
ob_start();
echo "[";
Alpine.directive('typed', (el, { expression, modifiers }, { evaluateLater, effect, cleanup }) => {
const getStrings = evaluateLater(expression);
const modifierValue = (key, fallback) => {
if (-1 === modifiers.indexOf(key)) {
return fallback;
}
const value = modifiers[modifiers.indexOf(key) + 1];

See: alpinejs/alpine#3016

I have found the bset approach to be this:

Install Alpine.js from npm and bundle it with your js file (documentation). Don't assign it to window:

import Alpine from "alpinejs";
// Assign a custom prefix:
Alpine.prefix("xyz-");
// Don't assign Alpine to the window (keep it private):

WARNING: USE AT YOUR OWN RISK.

Create a folder on any disk, for example, D:\python_scripts and add that folder to the system environment variable path. create new file eg: 'xampp.py' in that folder.

paste this code and rename the xampp_path variable to the path where you have installed xampp.

import subprocess
import os
import time
@Arifursdev
Arifursdev / createFormDataFromArray.js
Last active July 11, 2024 12:22
createFormDataFrom Array
function adevCreateFormData(formData, key, data) {
if (data === Object(data) || Array.isArray(data)) {
for (var i in data) {
adevCreateFormData(formData, key + '[' + i + ']', data[i]);
}
} else {
formData.append(key, data);
}
}
class AdevScrollState {
constructor(element) {
this.scrollableEl = this.selectElement(element);
if (this.scrollableEl === null) return console.error("AdevScrollState: Element not found");
this.isScrollable = false;
this.isScrolled = false;
this.isAtTop = false;
this.isAtBottom = false;
@Arifursdev
Arifursdev / upload_files_to_wordpress_php.php
Last active December 11, 2024 19:37
Upload files to WordPress PHP
<?php
$final_submission = [];
if ( isset( $_FILES['files'] ) && is_array( $_FILES['files']) && !empty( $_FILES['files'] ) ) {
$files = $_FILES['files'];
$allowed_file_types = ['image/jpeg', 'image/png', 'video/mp4'];
$max_file_size = 5 * 1024 * 1024; // 5MB
$max_files = 5;
@Arifursdev
Arifursdev / load-wordpress-from-theme-folder.php
Created December 11, 2024 21:46
default location of wp-load from theme folder
<?php
require_once( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/wp-load.php' );