Skip to content

Instantly share code, notes, and snippets.

View marcusmoore's full-sized avatar

Marcus Moore marcusmoore

View GitHub Profile
//...
public function register()
{
$this->app->singleton('command.migrate.fresh', function () {
return new FreshCommand();
});
}
//...
public function handle()
{
$key = "charges_loader" . $this->store->id . $this->page;
Redis::throttle($key)->allow(10)->every(60)->then(function () {
echo "HTTP Request Sending...... for page#$this->page \n";
}, function () {
return $this->release(10);
});
}
@paulredmond
paulredmond / ValidateMailgunWebhook.php
Created April 24, 2017 21:55
Laravel Middleware to Validate a signed Mailgun webhook
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
/**
* Validate Mailgun Webhooks
* @see https://documentation.mailgun.com/user_manual.html#securing-webhooks
@taylorotwell
taylorotwell / weather.sh
Last active August 27, 2019 13:40
Weather CLI
alias weather='curl -s wttr.in | sed -n "1,7p"'
@Kindari
Kindari / .bashrc
Last active October 24, 2016 15:13
Art (Laravel Artisan) command that can be used from almost any sub directory
art() {
# We cheat and assume that artisan is in the root of the repository. Thus the almost any sub directory. :)
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) = "true" ]]; then
php `git rev-parse --show-toplevel`/artisan $@
else
echo "Can't find artisan, are you in a git repository?"
fi
}
@wei
wei / whois-watch.sh
Last active August 4, 2017 13:26 — forked from zhovner/whois-change.sh
Monitor whois changes
#!/bin/bash
#
# Run this script once per minute
#
# * * * * * /path/to/whois-watch.sh google.com apple.com >> /var/log/whois-watch.log 2>&1
# update username in mail command
# update sed command depending on server return text
#
@themsaid
themsaid / HasEnums.php
Last active August 29, 2020 23:23
PHP Enumerated Type
trait HasEnums
{
/**
* The array of enumerators of a given group.
*
* @param null|string $group
* @return array
*/
static function enums($group = null)
{
@ericvanjohnson
ericvanjohnson / ThrottleRequest.php
Last active July 18, 2016 07:37
My back port to Laravel 5.1 of the Laravel 5.2 middleware feature to have the ability to throttle request coming in.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Cache\RateLimiter;
class ThrottleRequests
{
@ehvanr
ehvanr / ban_dupes.py
Last active May 2, 2018 14:17
Duplicate User Plex IPTables Drop Rule
#!/usr/bin/env python
# DESCRIPTION:
#
# This script is meant to be run as a root cronjob. You can run it however frequently
# you desire - I run it every minute. It determines the number of streams, and cross
# references the usernames. If there are duplicate usernames, it checks if the IP
# addresses are different. If so, it generates IPTables rules that will drop packets
# from both IP addresses.
#
@iolson
iolson / .env.example
Created September 17, 2015 22:14
GitLab CI Laravel 5.1.*
DB_HOST=mysql
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret