Skip to content

Instantly share code, notes, and snippets.

What's happening?

Chuong kocoten1992

What's happening?
Block or report user

Report or block kocoten1992

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kocoten1992 /
Created Feb 10, 2019
check we could establish ssh connection using bash
# source
ssh -q -o BatchMode=yes -o ConnectTimeout=10 exit
if [ $? -ne 0 ]
# Do stuff here if SSH is down
echo 'Can not connect to' | mail -s " down" whoever@wherever
kocoten1992 / AppServiceProvider.php
Last active Feb 22, 2019
auto retry database connection to different node laravel
View AppServiceProvider.php
namespace App\Providers;
use DB;
use App\Setting;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
kocoten1992 / findUser.php
Created Nov 25, 2016
Find user purely on laravel_session
View findUser.php
//Please mind that in newer version laravel, thing may change
//It work at least for 5.x version
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
$key = base64_decode('HoEXdquDDDXR20pZy7QleR7FTGZZXix1JeHwDv5Hhh8=');
$sr = new SymfonyRequest;
$sr->initialize([], [], [], ['laravel_session' => 'eyJpdiI6IjhOcFROekxpamU1U0oyYjIzZkw2TlE9PSIsInZhbHVlIjoiZUo0TmJTZURuS2RTVXc1SVY0cWU3XC9BcVwva2NnUFAzUmI0K2NwTXlzd3BibEpncFwvdzZKNEZpMTlmaWxLZHRmTGd5cXZPTWszS1BuNG5vOGRVWkVKSFE9PSIsIm1hYyI6Ijg3MzFhMTAzZDUwZjdmZjY4MDZkYmY5ZDQ3ZDA1ZTYxOWEwYmNiYTBhNmI0ZTNhY2Q2NzMzY2YzMTIzMjdhYTQifQ==']);
View gist:c7b7775ec705a8db96cf1902d91bf049
function getScrollbarWidth() {
var outer = document.createElement("div"); = "hidden"; = "100px"; = "scrollbar"; // needed for WinJS apps
var widthNoScroll = outer.offsetWidth;
// force scrollbars
You can’t perform that action at this time.