Skip to content

Instantly share code, notes, and snippets.

View abdullahbutt's full-sized avatar

Abdullah Butt abdullahbutt

  • Fulda, Deutschland
View GitHub Profile
@abdullahbutt
abdullahbutt / php-style-guide.md
Created May 7, 2020 18:02 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@abdullahbutt
abdullahbutt / swift bmi calculator.playground
Last active April 16, 2020 15:20
swift bmi calculator
//: Playground - noun: a place where people can play
/*
The body mass index (BMI) is a measure used to quantify a person’s mass as well as interpret their body composition. It is defined as the mass (Kg) divided by height (m) squared.
Here’s the BMI calculation formula:
BMI = mass (kg) / height (m2) // Metre square
If the BMI is greater than 25, use the print statement to tell the user that they are overweight.
Otherwise, if the BMI is between 18.5 - 25, tell the user that they are of normal weight.
@abdullahbutt
abdullahbutt / sendmail in wamp
Created April 29, 2014 03:26
how to send email from wamp using sendmail
Install Fake Sendmail (http://glob.com.au/sendmail/). Then configure C:\wamp\sendmail\sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password
The above will work against a Gmail account. And then configure php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Now, restart Apache, and that is basically all you need to do.
@abdullahbutt
abdullahbutt / countries.sql
Last active December 3, 2019 13:44
Countries and nationalities in English and Arabic
DROP TABLE IF EXISTS `countries`;
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(10) UNSIGNED NOT NULL,
`capital` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`citizenship` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`citizenship_ar` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`country_code` char(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`currency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`currency_sub_unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@abdullahbutt
abdullahbutt / countries_nationalities_arabic_english.sql
Created November 28, 2019 10:04 — forked from FlavaSava7/countries_nationalities_arabic_english.sql
SQL Countries & Nationalities List : English and Arabic
CREATE TABLE `countries` (
`country_code` varchar(2) NOT NULL default '',
`country_enName` varchar(100) NOT NULL default '',
`country_arName` varchar(100) NOT NULL default '',
`country_enNationality` varchar(100) NOT NULL default '',
`country_arNationality` varchar(100) NOT NULL default '',
PRIMARY KEY (`country_code`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `countries`
@abdullahbutt
abdullahbutt / access Laravel app with ip address
Created November 12, 2019 10:50
access Laravel app with ip address
php artisan serve --host 192.168.1.125 --port 8000
@abdullahbutt
abdullahbutt / megento 2.3.x blank page issue solution
Last active July 29, 2019 08:51
megento 2.3.x blank page issue solution
This is Magento bug. Wrong paths to Windows are generated. The fixed fix is:
Magento 2.3.0
#/vendor/magento/framework/View/Element/Template/File/Validator.php:138
the string
$realPath = $this->fileDriver->getRealPath($path);
@abdullahbutt
abdullahbutt / magento composer commands
Created July 29, 2019 08:49
magento composer commands
*************** Standard Commands Start******************
1) php bin/magento cache:flush
2) php bin/magento setup:upgrade
3) php bin/magento setup:di:compile
4) php bin/magento setup:static-content:deploy -f
5) php bin/magento indexer:reindex
6) php bin/magento cache:clean
*************** Standard Commands End ******************
@abdullahbutt
abdullahbutt / generating random alphanumeric strings in php
Created June 19, 2019 08:40
generating random alphanumeric strings in php
<?php
// https://code.tutsplus.com/tutorials/generate-random-alphanumeric-strings-in-php--cms-32132
//$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz!@#%';
// Output: 54esmdr0qf
$password = substr(str_shuffle($permitted_chars), 0, 8);
echo $password;
@abdullahbutt
abdullahbutt / php curl upload file.php
Last active May 2, 2019 10:20
php curl to upload file
<?php
use Illuminate\Support\Facades\Log;
$imageUrl = $linPost->pic_1; // This is a complete URL Path
$pos = strrpos($imageUrl, '/');
$imageName = $pos === false ? $imageUrl : substr($imageUrl, $pos + 1);
$extension = substr(strrchr($imageUrl,'.'),1);
if($extension == 'mp4' || $extension == 'MP4' || $extension == 'mov' || $extension == 'MOV')
{
$path_image_save = public_path('assets/imagegallery/video_upload/' . $imageName);