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 / RouteMacro.php
Last active August 9, 2019 21:46
Create a Route macro to route pages to follow a defined pages folder within your views in Laravel.
<?php
//service provider boot method
public function boot()
{
Route::macro('pages', function ($root = 'pages', $prefix = null) {
Route::get($prefix . '/{page?}', function ($path = 'home') use ($root) {
$path = str_replace('/', '.', $path);
$page = trim(sprintf("%s.%s", $root, $path), '.');
if (!view()->exists($page)) {
function d-up() {
(CURRENT_UID=$(id -u):$(id -g) docker-compose up -d $*)
}
function d-run() {
(CURRENT_UID=$(id -u):$(id -g) docker-compose run --rm $*)
}
@willishq
willishq / scriptloader.js
Last active September 4, 2017 12:22
ES6 script loader
import qs from 'qs';
/*
loadScript('https://example.com/script.js').then(() => {
// do something
}).catch(e => console.log(e));
const loadjQuery = async () => {
try {
await loadscript('https://code.jquery.com/jquery-3.2.1.js');
@willishq
willishq / VueDatepicker.vue
Created August 1, 2017 10:28
VueJS Datepicker component
<template>
<div>
<label :for="name" :class="{
'label-error': errors.has(name),
}">{{ label }}</label>
<div class="datepicker-selects">
<select v-if="showDay" v-model="day" :class="{
'input-error': !isValid('day') || errors.has(name),
}" :disabled="!isInitialised()">
<option :value="null" disabled :selected="day === null">Day</option>
@willishq
willishq / vue-datepicker.js
Created February 13, 2017 23:10
Bootstrap Vue Datepicker
<template>
<div class="form-group">
<label :for="name">Date of Birth</label>
<div class="form-inline">
<input type="number" :id="name" min="1" step="1" :max="maxDay" size="2" class="form-control" v-model="day" placeholder="Day">
<select class="form-control" v-model="month">
<option value="-1" disabled>Month</option>
<option v-for="(month, index) in months" :value="index">{{ month }}</option>
</select>
<input type="number" :min="minYear" :max="maxYear" class="form-control" v-model="year">
@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)
{
@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 / 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 ../..
Verifying that +willishq is my blockchain ID. https://onename.com/willishq
@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] = {};
}