Skip to content

Instantly share code, notes, and snippets.

@wanmigs
wanmigs / axios.js
Created March 2, 2020 06:15
Axios Inteceptors
import getConfig from 'next/config'
import axios from 'axios';
import { isLoggedIn, logout } from './auth'
const {
publicRuntimeConfig: {API_URL}, // Available both client and server side
} = getConfig()
let axiosIntance = { ...axios}
axiosIntance.defaults.baseURL = API_URL
@wanmigs
wanmigs / .editorconfig
Last active October 14, 2019 02:13
Editor Config
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@wanmigs
wanmigs / SystemController.php
Created June 17, 2019 08:07
Laravel System Check Controller Sample
<?php
namespace App\Http\Controllers;
use wanmigs\HealthCheck\SystemCheck;
use Illuminate\Support\Facades\DB;
class SystemController extends Controller
{
private $system;
@wanmigs
wanmigs / patch.js
Created April 29, 2019 02:05
Fix Formdata on Patch Laravel
let data = new FormData();
data.append("_method", 'PATCH');
// append another data ....
const headers = {
'Content-Type': 'multipart/form-data',
'enctype' : 'multipart/form-data',
'Authorization' : 'Bearer ' + token
}
@wanmigs
wanmigs / swiftmailerDatatoImage.php
Created April 4, 2019 01:14
Swiftmailer embed data image
protected function getImagesFromMsg($msg)
{
if (!empty($msg))
{
preg_match_all('/<img[^>]+>/i', stripcslashes($msg), $imgTags);
//All img tags
for ($i=0; $i < count($imgTags[0]); $i++)
{
preg_match('/src="([^"]+)/i', $imgTags[0][$i], $withSrc);
@wanmigs
wanmigs / index.js
Last active April 15, 2019 11:12
React Native Dynamic Exports
const requireContext = require.context('./', false, /.*\.(js)$/)
let components = {};
requireContext.keys().forEach(fileName => {
if (fileName === './index.js') return
let name = fileName.replace(/(\.\/|\.js)/g, '')
@wanmigs
wanmigs / Testcase.php
Last active October 18, 2023 10:42
Create, Update, Delete and Fetch TestCase
<?php
namespace Tests;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
@wanmigs
wanmigs / Paginators.php
Created February 22, 2019 00:45
Laravel Pagination + Filter
<?php
namespace App\Traits;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
trait Paginators
{
private $sortBy = ['created_at' => 'desc'];