Skip to content

Instantly share code, notes, and snippets.

Avatar

Al Imran Ahmed alimranahmed

View GitHub Profile
@alimranahmed
alimranahmed / linux_server_setup_for_php_project.sh
Last active Jun 18, 2020
Commands for setting up linux server for PHP Project
View linux_server_setup_for_php_project.sh
# 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 mysql_secure_installation
sudo apt install -y php libapache2-mod-php php-mysql php-common php-cli php-common php-json php-opcache php-readline php-dom
View str_is_matched.php
<?php
function isMatched(string $pattern, string $value): bool
{
if ($pattern == $value) {
return true;
}
$pattern = preg_quote($pattern, '#');
View Give remote access to a database
mysql –u root -p
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
View XmlToArrayParser.php
<?php
namespace App\Helpers;
/**
* XML to Associative Array Class
*
* Usage:
* $domObj = new xmlToArrayParser($xml);
@alimranahmed
alimranahmed / installation_and_upgrades.md
Last active Mar 26, 2020
Guide to Installations and Upgrades
View installation_and_upgrades.md

Upgrade npm:

sudo npm install npm@latest -g
npm -v

Upgrade node:

sudo npm cache clean -f
View .php_cs
<?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 / uk_mobile_regex.md
Last active Sep 6, 2019
UK Mobile Number Validation Regex
View uk_mobile_regex.md

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

@alimranahmed
alimranahmed / extendCollectionWithPaginate.php
Last active Jan 31, 2019
Extends Laravel collection with paginate() function like Eloquent
View extendCollectionWithPaginate.php
<?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 / laravel.js
Created Jul 5, 2018 — forked from JeffreyWay/laravel.js
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
View laravel.js
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@alimranahmed
alimranahmed / xml-decoder.py
Last active Oct 29, 2017
A very simple tool to decode xml. Python's Tkinter library used to build the interface. Python3^ is required.
View xml-decoder.py
import html
from tkinter import *
import xml.dom.minidom as dom
# author Al Imran Ahmed
# A very simple interface to decoded xml. i.e. &lttag&gt => <tag>
# requires python3^ with tkinter GUI library installed
class Application(Frame):
def decode_xml(self):
You can’t perform that action at this time.