Skip to content

Instantly share code, notes, and snippets.

@asule90
asule90 / post-receive-laravel
Last active August 14, 2019 07:07
post-receive-deploy
#!/bin/bash
#/usr/local/bin/composer
#/usr/bin/php
echo '--- --- --- --- --- --- --- --- --- --- ---'
echo 'Deploying site...'
echo '--- --- --- --- --- --- --- --- --- --- ---'
while read oldrev newrev refname
do
@asule90
asule90 / DiagnosticMiddleware.php
Created February 2, 2019 20:26
DiagnosticMiddleware.php
public function handle($request, Closure $next)
{
// Get the response
$response = $next($request);
$content = $response->getContent();
if($content AND (is_array($content) OR is_object($content)) ){
// Calculate execution time
$executionTime = microtime(true) - LUMEN_START;
@asule90
asule90 / post-receive
Created December 29, 2018 02:26
Git hook post-receive auto deploy based on branch
#!/bin/bash
echo '--- --- --- --- --- --- --- --- --- --- ---'
echo 'Deploying site...'
echo '--- --- --- --- --- --- --- --- --- --- ---'
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
# Master Branch
@asule90
asule90 / JWTMiddleware.php
Last active August 14, 2019 07:08
Middleware sample for verifying JWT
<?php
namespace App\Http\Middleware;
use Closure;
use Firebase\JWT\JWT;
use Firebase\JWT\ExpiredException;
class JWTMiddleware
{
@asule90
asule90 / http.js
Last active August 14, 2019 07:08
Setup cache and header for axios instance
import axios from "axios";
import store from "@/store";
import {
cacheAdapterEnhancer,
throttleAdapterEnhancer
} from "axios-extensions";
const axios_instance = axios.create({
baseURL: your-api-url,
@asule90
asule90 / UserController.php
Created December 9, 2018 05:51
Code snippet for UserController example
$payload = [
'iss' => 'Organization', // Issuer of the token, Organization / Product
'sub' => 'subject', // Subject of the token
'iat' => time(), // Time when JWT was issued.
'exp' => time() + 60*60 // Expiration time
...
'user' => ...,
'desc' => ...,
];