Skip to content

Instantly share code, notes, and snippets.

View willishq's full-sized avatar
😺
Swiping Cats

Andrew Willis willishq

😺
Swiping Cats
View GitHub Profile
@willishq
willishq / robot.js
Created December 3, 2012 20:34
WillisBot
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot){
this.offset = 1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
@willishq
willishq / inactive.php
Last active December 29, 2015 15:58
Adding active timestamps to Eloquent
<?php
namespace Extreloquent;
use Illuminate\Database\Eloquent\Builder;
/**
* Extension of the Eloquent model to add active dates to data
*
* Class Model
@willishq
willishq / EloquentBaseModel.php
Last active January 2, 2016 17:09
This is my Eloquent Base Model which I use to turn off timestamps as a default and also to add validation as a method on each model.
<?php
class BaseModel extends Eloquent
{
public $timestamps = false;
/**
* Validation rules
*
* @var array
@willishq
willishq / tags-input.jquery.js
Created January 27, 2015 21:35
Simple input tags jQuery snippet
Array.prototype.remove = function (value) {
return this.filter(function (element) {return element !== value});
};
var tags = [];
$('.tag-box').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
$('.tag-input', this).focus();
});
$('.tag-input').on('keyup', function (e) {
@willishq
willishq / Flash.php
Last active August 18, 2019 12:07
Laravel 5 Flash messages inspired by Laracasts Flash, optimized for Zurb Foundation
<?php namespace App\Services;
use Illuminate\Session\Store;
/**
* Laravel 5 Flash messages inspired by Laracasts Flash Messages.
*
* @link https://github.com/laracasts/flash
*
* @author Andrew Willis <[email protected]>
*
@willishq
willishq / event-bus.js
Last active October 10, 2015 22:06
Simple ES6 Event Bus implementation
class Listeners {
constructor() {
this.list = {};
}
create(eventName, id, cb) {
if (!this.list[eventName]) {
this.list[eventName] = {};
}
Verifying that +willishq is my blockchain ID. https://onename.com/willishq
@willishq
willishq / Homestead Redis-geo.md
Last active April 27, 2016 20:47
Adding Redis-geo to homestead
sudo apt-get remove redis-server -y
mkdir -p ~/repos
cd ~/repos
git clone https://github.com/antirez/redis
git checkout tags/3.2.0-rc3 
make
sudo make install
sudo ./utils/install_server.sh
cd ../..
@willishq
willishq / storage_link.sh
Last active November 14, 2016 17:16
Creates a symlink from the storage/public directory to public/storage, optionally takes an argument to name the link something other than public/storage
@willishq
willishq / TransactionMiddleware.php
Created November 16, 2016 11:46
Database transaction middleware
<?php
namespace App\Http\Middleware;
use DB;
class TransactionMiddleware
{
public function ($request, $next)
{