Skip to content

Instantly share code, notes, and snippets.

Avatar

Ahsan Muhammad Yousuf ahsankhatri

View GitHub Profile
@ahsankhatri
ahsankhatri / autorun.cmd
Last active Mar 14, 2019
Make windows command prompt user-friendly.
View autorun.cmd
@echo off
:: Aliases
DOSKEY reload = %USERPROFILE%\autorun.cmd
DOSKEY editalias = "C:\Program Files\Sublime Text 3\subl.exe" %USERPROFILE%\autorun.cmd
DOSKEY www = cd /d C:\xampp\htdocs
DOSKEY sdf = cd /d D:\Ahsaan\Songs
DOSKEY sbcd = cd /d D:\scripts\python\sevenbridges\sevenbridges
DOSKEY sbenv = D:\scripts\python\sevenbridges\venv\Scripts\activate.bat
:: DOSKEY sbinit = DOSKEY sbcd && DOSKEY sbenv && DOSKEY flask run
@ahsankhatri
ahsankhatri / web.php
Created Aug 9, 2018
Preview Notifications (Email) in Browser Laravel 5.4
View web.php
Route::get('/preview-mail', function () {
$user = User::first();
$mail = (new \App\Notifications\Api\Registration($user))->toMail('random@domain.com');
$markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));
return $markdown->render('vendor.notifications.email', $mail->toArray());
});
@ahsankhatri
ahsankhatri / web.php
Created Aug 9, 2018
Preview Mailable in Browser Laravel 5.4
View web.php
Route::get('/preview-mail', function () {
$mail = (new \App\Mail\ShareItenraryTripStarted())->build();
$mocked = new \ReflectionMethod($mail, 'buildView');
$mocked->setAccessible(true);
return $mocked->invoke($mail)['html'];
});
@ahsankhatri
ahsankhatri / keybase.md
Created Apr 17, 2017
Verifying github profile in keybase. Ignore please :)
View keybase.md

Keybase proof

I hereby claim:

  • I am ahsankhatri on github.
  • I am ahsankhatri (https://keybase.io/ahsankhatri) on keybase.
  • I have a public key ASBBH8VLB95fgZnSAwPkChWmRyODSGXcw3N44y2VMk7aDQo

To claim this, I am signing this object:

@ahsankhatri
ahsankhatri / powerOfTwo.php
Created Feb 6, 2017
Check if number is a power of 2
View powerOfTwo.php
<?php
function isPowerOfTwo($num)
{
return ($num > 0) && (($num & ($num - 1)) == 0);
}
// var_dump(4);
// var_dump(5);
// var_dump(6);
@ahsankhatri
ahsankhatri / README.md
Created Feb 2, 2017
Install Ruby, Gem & Mailcatcher in Cygwin (Windows)
View README.md

Install Ruby, Gem & Mailcatcher in Cygwin (Windows)

  1. Install Cygwin (http://www.cygwin.com/)
  • Select the folowing packages: curl, git, nano, openssh, openssl, unzip, util-linux, vim, wget
  1. Install Ruby (https://rubyinstaller.org/downloads/)
  • Download and install ruby.
  • Make sure you've ammend PATH in environment variable
  • Verify in Cygwin by closing and starting cygwin then type: echo $PATH
  • Make sure you got /cygdrive/c/Ruby22/bin (according to your path)
@ahsankhatri
ahsankhatri / README.md
Created Dec 7, 2016
Cygwin Custom Prompt (virtualenv supported)
View README.md

Step 1

  • Edit ~/.bash_profile and overwrite the variable
export PS1="\[\e]0;\w\a\]\n> \[\e[32m\]\u \e\e[0m\]in \[\e[33m\]\w\[\e[0m\] » \[\e[36m\]\@\n\e[m\$ "

Step 2 (Optional)

  • Edit virtualenv/Scripts/activate
@ahsankhatri
ahsankhatri / webComposer.php
Created Oct 2, 2016
Run composer update/install in browser.
View webComposer.php
<?php
// This is just a sample code, do not use it on production as this is insecure
// For security, you may use .htaccess IP Access or HTTP Basic Aauthentication
require 'vendor/autoload.php';
$allowedCommands = [
'update',
'install',
'dump-autoload',
@ahsankhatri
ahsankhatri / README.md
Last active Aug 14, 2018
Laravel 5.0~5.4 Webservice Logger. Log all request and response through middleware in wrapped routes
View README.md

Webservice Logger for Laravel 5.0~5.4 (Haven't tested on 5.5+)

Log all request and response through middleware in api wrapped group routes.

Guide

wrap middleware in api group in app/Http/Kernel.php

    'api' => [
        'throttle:60,1',
        \App\Http\Middleware\WebserviceLogger::class,
@ahsankhatri
ahsankhatri / README.md
Last active May 9, 2020
Database Driven Routes Laravel 5.2
View README.md

Database Driven Routes Laravel 5.2

Table: url_alias

+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
| id | slug            | map_to                                    | params          | http_verb | middleware |
+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
| 1  | page/about-us   | Frontend\HomeController@showPage          | a:1:{i:0;i:4;}  | GET       | web        |
| 2  | page/contact-us | Backend\DashboardController@getContactUs  | a:1:{i:0;i:4;}  | GET       | web        |
| 3  | page/contact-us | Backend\DashboardController@postContactUs |                 | POST      | web        |
You can’t perform that action at this time.