Skip to content

Instantly share code, notes, and snippets.

View alimranahmed's full-sized avatar

Al Imran Ahmed alimranahmed

View GitHub Profile
@alimranahmed
alimranahmed / extendCollectionWithPaginate.php
Last active January 31, 2019 15:18
Extends Laravel collection with paginate() function like Eloquent
<?php
//----------------------------------------How to use?----------------------------------------------
// 1. Add the following private method in App\Providers\AppServiceProvider class
// 2. Call this function from boot() method of same class: $this->extendCollectionWithPaginate();
//-------------------------------------------------------------------------------------------------
/**
* Macro to extends Laravel Collection
* If you have a collection called $item and you want to paginate it like Eloquent paginate:
* $items->paginate($perPage)
@alimranahmed
alimranahmed / uk_mobile_regex.md
Last active September 6, 2019 06:22
UK Mobile Number Validation Regex

((0|44|\+44|\+44\s*\(0\)|\+44\s*0)\s*)?7(\s*[0-9]){9}

<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->name('_ide_helper')
->notName('*.blade.php')
->ignoreDotFiles(true)
@alimranahmed
alimranahmed / installation_and_upgrades.md
Last active March 26, 2020 06:23
Guide to Installations and Upgrades

Upgrade npm:

sudo npm install npm@latest -g
npm -v

Upgrade node:

sudo npm cache clean -f
<?php
namespace App\Helpers;
/**
* XML to Associative Array Class
*
* Usage:
* $domObj = new xmlToArrayParser($xml);

To access from remote

mysql –u root -p
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

For changing from sudo accessible to password accessible(auth_socket to mysql_native_password)

<?php
function isMatched(string $pattern, string $value): bool
{
if ($pattern == $value) {
return true;
}
$pattern = preg_quote($pattern, '#');
@alimranahmed
alimranahmed / linux_server_setup_for_php_project.sh
Last active March 5, 2023 17:28
Commands for setting up linux server for PHP Project
# Source1: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04
sudo apt update
sudo apt install -y apache2
sudo apache2 -v
sudo apt install -y mysql-server
sudo apt install -y php libapache2-mod-php php-mysql php-common php-cli php-common php-json php-opcache php-readline php-dom php-curl
php -v
@alimranahmed
alimranahmed / video_to_gif_convert_improved.py
Created March 27, 2024 11:00 — forked from artturijalli/video_to_gif_convert_improved.py
Convert video to gif with 3 lines of code. Install Tkinter with brew install python-tk. Install moviepy with pip install moviepy
from moviepy.editor import VideoFileClip
from tkinter.filedialog import *
import os
# Accept only .mov and .mp4 files. Feel free to change.
accepted_files = [("Mov files", "*.mov"), ("MP4 files", "*.mp4")]
# Select a video which is one of the accepted file types from your machine
video_file = askopenfilename(filetypes=accepted_files)