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 / watch.sh
Last active March 3, 2021 10:09 — forked from espaciomore/watch.sh
Watch command for Git Bash
#!/bin/bash
ARGS="${@}"
clear;
while(true); do
clear
OUTPUT=`$ARGS`
echo -e "${OUTPUT[@]}"
sleep 1
done
@fhdalikhan
fhdalikhan / backup.php
Created July 14, 2020 00:16 — forked from toddsby/backup.php
backup.php
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* (c) 2012-2014: Marvin Menzerath - http://menzerath.eu
* contribution: Drew Toddsby
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@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 / 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 / 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 / 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 / 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'
},
{
<?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 / 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
{
/**
@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)