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 / dynamic-font-sizes.js
Created May 27, 2019 10:00
Change font sizes dynamically for a web page
var StylingHelper = function(){
this.id = 'dynamic-styles';
this.step = 2;
this.count = 1;
this.h1Size, this.h2Size, this.h3Size, this.h4Size, this.h5Size, this.h6Size, this.pSize;
};
StylingHelper.prototype.increment = function() {
this.count++;
* API FOR GET REQUESTS
// most simple and returns iata code
https://airport-autosuggest.flightright.net/v1/airports/COM?name=london
// connected to kiwi.com, but you can still use it for autocompletes and has a lot of information
https://api.skypicker.com/locations/?term=london
* BELOW API IS FOR POST REQUESTS
// related to openflights data or a simple text autocomplete
@fhdalikhan
fhdalikhan / gist:4021446b2ef47fa5c38ac8255141e46a
Created May 8, 2019 09:01
Enable SSL connection for database connection in Laravel / PHP
// Also take a look at this nice article for more knowledge https://mariadb.com/kb/en/library/securing-connections-for-client-and-server/
// for connecting via cli with ssl and host use below command
mysql -u root -p -h ClientCertOne --ssl
// SERVER PART
1 - Create a certificate, see this gist for info https://gist.github.com/fhdalikhan/27461530147a0b6eb281f5db1826912b
2- Add these lines to my.ini config file, providing you have these certificates.
@fhdalikhan
fhdalikhan / gist:27461530147a0b6eb281f5db1826912b
Created May 8, 2019 09:00
Generate self signed certificate and add to MariaDB / MySQL
// generate cert
@see https://mariadb.com/kb/en/library/certificate-creation-with-openssl/
// Add to my.ini
@see https://mariadb.com/kb/en/library/securing-connections-for-client-and-server/
[mariadb]
ssl_cert = D:/work/mysql-certs/server-cert.pem
ssl_key = D:/work/mysql-certs/server-key.pem
ssl_ca = D:/work/mysql-certs/cacert.pem
@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 / misc.sql
Created April 29, 2019 07:10
SQL to count all databases and tables in mysql
# COUNT ALL DATABASES
SELECT COUNT(*) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mysql','information_schema');
# COUNT ALL TABLES
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES;
@fhdalikhan
fhdalikhan / gulpfile.js
Last active April 23, 2019 07:17
Gulpfile for minifying JS and CSS files. It will also watch for changes and run the commands again after changes.
// gulp version 4 used for below
// Step (1 Install gulp CLI) If gulp cli is not installed then npm install --global gulp-cli
// Step (2 Install Dependencies) npm install --save-dev gulp gulp-uglify gulp-rename gulp-if gulp-clean-css gulp-concat
// Step (3 Run gulp) gulp
// gulp command will run the default exported task
// to run an individual command run gulp taskName, be sure to export the task
const { src, dest, watch } = require('gulp');
// const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
@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}$/',