Skip to content

Instantly share code, notes, and snippets.

Matthew Suan matthewsuan

View GitHub Profile
@matthewsuan
matthewsuan / axios.js
Last active May 31, 2020
Axios request queue-like that limits number of requests at any given time
View axios.js
import axios from 'axios'
const MAX_REQUESTS_COUNT = 5
const INTERVAL_MS = 10
let PENDING_REQUESTS = 0
// create new axios instance
const api = axios.create({})
/**
View Homestead error
Jervens-MacBook-Pro-2:Homestead jervenmatthew$ vagrant reload --provision
==> homestead-7: Removing hosts
==> homestead-7: Attempting graceful shutdown of VM...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
@matthewsuan
matthewsuan / dont-delete-private-files.php
Created May 8, 2017 — forked from Shelob9/dont-delete-private-files.php
One way to prevent files, uploaded through Caldera Forms file fields, not set to be added to media library, from being deleted.
View dont-delete-private-files.php
<?php
/** Wait until caldera_forms_core_init hook so we know all actions were added **/
add_action( 'caldera_forms_core_init', function() {
//File delete is attempted first here, but if an email should send, the file isn't deleted//
remove_action( 'caldera_forms_submit_complete', array( 'Caldera_Forms_Files', 'cleanup' ) );
//If email is set to be used, we wait until email is sent to delete on these hooks:
remove_action( 'caldera_forms_mailer_complete', array( 'Caldera_Forms_Files', 'delete_after_mail' ), 10, 3 );
remove_action( 'caldera_forms_mailer_failed', array( 'Caldera_Forms_Files', 'delete_after_mail' ), 10, 3 );
@matthewsuan
matthewsuan / laravel-slug.php
Created Jun 19, 2016
Improved Unique Slug Generator from @ericbarnes, @AucT
View laravel-slug.php
<?php
namespace App\Services;
class Slug
{
private $entity;
private $slugAttr;
public function __construct($entity = \App\Post::class, $slugAttr = 'slug')
You can’t perform that action at this time.