Skip to content

Instantly share code, notes, and snippets.

View Faizanq's full-sized avatar

Faizan Qureshi Faizanq

View GitHub Profile
@Faizanq
Faizanq / settimeout.php
Created July 9, 2020 10:12 — forked from edwjusti/settimeout.php
setTimeout for php
<?php
class TimeoutClass extends Thread {
public function __construct(callable $cb, int $time, $args){
$this->callback = $cb;
$this->args = $args;
$this->time = $time * 1000;
}
public function run(){
usleep($this->time);
@Faizanq
Faizanq / ID.js
Created June 12, 2020 08:26
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@Faizanq
Faizanq / bash-script-git.sh
Created July 11, 2019 09:20 — forked from salcode/bash-script-git.sh
Notes for bash scripting git commands
# Current branch - Determine current git branch, store in $currentbranch, and exit if not on a branch
if ! currentbranch=$(git symbolic-ref --short -q HEAD)
then
echo We are not currently on a branch.
exit 1
fi
# Uncommited Changes - Exit script if there uncommited changes
if ! git diff-index --quiet HEAD --; then
echo "There are uncommited changes on this repository."
@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) {
@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 "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@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";
<?php
class Db
{
private $_connection;
private static $_instance; //The single instance
private $_host = DB_HOST;
private $_username = DB_USER;
private $_password = DB_PASSWORD;
private $_database = DB_DB;
@Faizanq
Faizanq / app.js
Created November 15, 2018 13:18 — forked from narirou/app.js
express.js + pjax workflow
var express = require( 'express' ),
bodyParser = require( 'body-parser' ),
pjax = require( './pjax-helper' );
var app = express();
app.set( 'views', __dirname + '/views' );
app.set( 'view engine', 'jade' );
app.use( pjax() );