Skip to content

Instantly share code, notes, and snippets.

View codyphobe's full-sized avatar
🏍️
Chasing the sunset

Cody codyphobe

🏍️
Chasing the sunset
View GitHub Profile
@codyphobe
codyphobe / gist:f452a453c74c709ceac2
Last active August 29, 2015 14:26 — forked from steveneaston/gist:73d623549a2c414f2789
Initialise properties Sublime macro
{
"keys": ["super+i"],
"command": "run_macro_file",
"args": {"file": "Packages/User/Macros/initialize_properties.sublime-macro"},
"context": [{"key": "selector", "operator": "equal", "operand": "source.php"}]
}
@codyphobe
codyphobe / NullingTrait.php
Last active September 5, 2015 22:36 — forked from dwightwatson/NullingTrait.php
NullingTrait.php
<?php namespace App\Support;
trait NullingTrait
{
/**
* Boot the trait. Adds an observer class for nulling.
*
* @return void
*/
public static function bootNullingTrait()
@codyphobe
codyphobe / global-homestead.sh
Created September 24, 2015 21:21 — forked from taylorotwell/global-homestead.sh
Global Homestead Without Composer
alias homestead='function __homestead() { (cd ~/Documents/Code/Homestead && vagrant $*); unset -f __homestead; }; __homestead'
# Usage
homestead up
homestead halt
# etc...
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Request;
use View;
use App;
abstract class ApplicationsServiceProvider extends ServiceProvider
{
public function register()
@codyphobe
codyphobe / PjaxMiddleware.php
Created October 11, 2015 04:37 — forked from JeffreyWay/PjaxMiddleware.php
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@codyphobe
codyphobe / tenant-middleware.php
Last active December 12, 2015 10:23 — forked from taylorotwell/tenant-middleware
Magical tenant middleware thing
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Auth\Access\AuthorizationException;
class VerifyTenants
{
/**
@codyphobe
codyphobe / ReadOnlyModel.php
Created February 20, 2016 22:59
Laravel 5.1 Read only Model
<?php
//Similar to Rails Active Directory Read only models in ruby gems
namespace App;
use Illuminate\Database\Eloquent\Model;
class ReadOnly extends Model
{
public $table = 'tablename';
protected $connection = 'db_test';
// protected static $carbonFields = ['created_at', 'updated_at', 'deleted_at'];
@codyphobe
codyphobe / ssh-telegram.sh
Created March 5, 2016 22:35 — forked from matriphe/ssh-telegram.sh
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use jq to parse JSON from ipinfo.io
# get jq from here http://stedolan.github.io/jq/
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ]; then
@codyphobe
codyphobe / permute.md
Created July 6, 2016 17:00
Laravel Collection macro to get the permutations of a set.

This is a recursive (read: inefficient) macro for Laravel's Collection that generates a list of all permutations of the values in a collection. I don't know of many cases in which one would need this, but who cares.

Note: Duplicate values in the original collection are not removed during permutation.

Collection::macro('permute', function () {
    if ($this->isEmpty()) {
        return new static([[]]);
    }
@codyphobe
codyphobe / keybase.md
Created August 23, 2016 16:01
Keybase proof

Keybase proof

I hereby claim:

  • I am codyphobe on github.
  • I am codyphobe (https://keybase.io/codyphobe) on keybase.
  • I have a public key whose fingerprint is E4C6 32E3 999E F465 1B8D 18D7 350E B30C D10E 00DA

To claim this, I am signing this object: