Skip to content

Instantly share code, notes, and snippets.

View Faizanq's full-sized avatar

Faizan Qureshi Faizanq

View GitHub Profile
@Faizanq
Faizanq / class.database.php
Created January 27, 2019 07:04 — forked from jonashansen229/class.database.php
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";
require "../config.php";
require "../common.php";
try {
$connection = new PDO($dsn, $username, $password, $options);
$new_user = array(
"firstname" => $_POST['firstname'],
"lastname" => $_POST['lastname'],
"email" => $_POST['email'],
@Faizanq
Faizanq / readme.md
Created January 27, 2019 07:08 — forked from skhani/readme.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

@Faizanq
Faizanq / php-html-css-js-minifier.php
Created January 27, 2019 07:10 — forked from skhani/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
https://jsfiddle.net/lesson8/HkEuf/1/
For the fun of it, I tested the performance of the following:
1. json_decode('{}');
2. new StdClass();
3. (object)[];
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5000
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
or
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
@Faizanq
Faizanq / Node Version Install
Last active October 7, 2019 17:59
Node Version Install
Step 1 – Add Node.js PPA
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Step 2 – Install Node.js on Ubuntu
sudo apt-get install nodejs
Step 3
@Faizanq
Faizanq / Composer install
Last active May 25, 2019 16:25
Composer install
sudo curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer