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
<?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 / placeholders.js
Created December 16, 2013 07:46 — forked from codeguy/placeholders.js
Add placeholder attribute fallback for older browsers
placeholderSupport = ("placeholder" in document.createElement("input"));
if (placeholderSupport === false) {
$('[placeholder]').each(function () {
var $input = $(this),
placeholder = $input.attr('placeholder');
$input
.val(placeholder)
.focus(function () {
@codyphobe
codyphobe / 0_reuse_code.js
Created January 10, 2014 05:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
[
{
"command": "escape"
},
{
"command": "expand_selection",
"args": {"to": "word"}
},
{
"command": "copy"
@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 / 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 / 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: