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
kocoten1992 / check_ssh.sh
Created Feb 10, 2019
check we could establish ssh connection using bash
View check_ssh.sh
#!/bin/bash
# source http://mindspill.net/computing/linux-notes/bash-script-to-check-ssh-connection/
ssh -q -o BatchMode=yes -o ConnectTimeout=10 example.com exit
if [ $? -ne 0 ]
then
# Do stuff here if example.com SSH is down
echo 'Can not connect to example.com' | mail -s "example.com down" whoever@wherever
@kocoten1992
kocoten1992 / AppServiceProvider.php
Last active Feb 22, 2019
auto retry database connection to different node laravel
View AppServiceProvider.php
<?php
namespace App\Providers;
use DB;
use App\Setting;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@kocoten1992
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");
outer.style.visibility = "hidden";
outer.style.width = "100px";
outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
document.body.appendChild(outer);
var widthNoScroll = outer.offsetWidth;
// force scrollbars
You can’t perform that action at this time.