Skip to content

Instantly share code, notes, and snippets.

View fhdalikhan's full-sized avatar
🏠
Working from home

Fahad Ali Khan fhdalikhan

🏠
Working from home
  • Karachi, Pakistan.
View GitHub Profile
@fhdalikhan
fhdalikhan / supervisord.sh
Created October 9, 2018 11:13 — forked from danmackinlay/supervisord.sh
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@fhdalikhan
fhdalikhan / nginxproxy.md
Created December 19, 2018 05:57 — forked from barbietunnie/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@fhdalikhan
fhdalikhan / reset-last-commit.md
Created December 19, 2018 05:57 — forked from barbietunnie/reset-last-commit.md
Undo the most recent commits in Git

Undo a commit and redo

$ git commit -m "Something terribly misguided"             # (1)
$ git reset HEAD~                                          # (2)
<< edit files as necessary >>                              # (3)
$ git add ...                                              # (4)
$ git commit -c ORIG_HEAD                                  # (5)
<?php
return [
'GB' => '/^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}$/',
'JE' => '/^JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/',
'GG' => '/^GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/',
'IM' => '/^IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/',
'US' => '/^\d{5}([ \-]\d{4})?$/',
'CA' => '/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d$/',
'DE' => '/^\d{5}$/',
@fhdalikhan
fhdalikhan / states.js
Created April 16, 2019 12:49 — forked from paulredmond/states.js
US States for a JS Dropdown
var states = [
{
label: 'Alabama',
value: 'AL'
},
{
label: 'Alaska',
value: 'AK'
},
{
@fhdalikhan
fhdalikhan / ab-laravel-php.sh
Created May 7, 2019 04:53 — forked from eusonlito/ab-laravel-php.sh
Benchmark project with different Laravel versions vs PHP versions
#!/bin/bash
phps="7.1 7.2 7.3"
laravels="5.5 5.6 5.7 5.8"
requests="1000"
concurrencies="1 10 100"
native="$1"
function csv {
for t in requests time; do
@fhdalikhan
fhdalikhan / basecamp-classic-files.php
Created May 7, 2019 04:53 — forked from eusonlito/basecamp-classic-files.php
Download all your file from Basecamp Classic
<?php
define('BASE', './basecamp'); // Folder to store files (must be writable)
define('BASECAMP_URL', '[YOUR BASECAMP URL HERE]'); // e.g. https://stelabouras.basecamphq.com/ (Don't forget the trailing slash!)
define('BASECAMP_KEY', '[YOUR API KEY HERE]'); // e.g. one huge string (found in 'My info' in the Authentication tokens section)
define('COOKIE', tempnam(sys_get_temp_dir(), uniqid()));
function curl($url, $prefix = true)
{
$url = ($prefix ? BASECAMP_URL : '').$url;
@fhdalikhan
fhdalikhan / drop-column-if-exists.sql
Created June 4, 2019 08:01 — forked from eusonlito/drop-column-if-exists.sql
Drop table column only if exists in a MySQL database
DROP PROCEDURE IF EXISTS `DropColumnIfExists`;
DELIMITER $$
CREATE PROCEDURE `DropColumnIfExists` (`@TABLE` VARCHAR(100), `@COLUMN` VARCHAR(100))
`DropColumnIfExists`: BEGIN
DECLARE `@EXISTS` INT UNSIGNED DEFAULT 0;
SELECT COUNT(*) INTO `@EXISTS`
FROM `information_schema`.`columns`
@fhdalikhan
fhdalikhan / us-cities.csv
Created July 15, 2019 09:07 — forked from sohlis/us-cities.csv
All US Cities CSV
City State short
Holtsville NY
Agawam MA
Amherst MA
Barre MA
Belchertown MA
Blandford MA
Bondsville MA
Brimfield MA
Chester MA
@fhdalikhan
fhdalikhan / AuthServiceProvider.php
Created March 26, 2019 06:52 — forked from ralphschindler/AuthServiceProvider.php
Laravel 5.8 Policy Guesser For Using "Models" Directory
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**