Skip to content

Instantly share code, notes, and snippets.

View kingsloi's full-sized avatar

Kingsley Raspe kingsloi

View GitHub Profile
@kingsloi
kingsloi / bootstrap.sh
Created February 6, 2024 19:34
New Server Bootstrapping Script
#!/bin/sh
############################################################
# Usage #
# https://gist.github.com/hfossli/4368aa5a577742c3c9f9266ed214aa58
############################################################
function usage() {
if [ -n "$1" ]; then
echo -e "${RED}👉 $1${CLEAR}\n";
fi
@kingsloi
kingsloi / PermissionServiceProvider.php
Created June 27, 2016 16:07
Spatie's Laravel Permission fix for registering Blade directives in Laravel 5.2
<?php
namespace Spatie\Permission;
use Blade;
use Illuminate\Support\ServiceProvider;
use Spatie\Permission\Contracts\Permission as PermissionContract;
use Spatie\Permission\Contracts\Role as RoleContract;
class PermissionServiceProvider extends ServiceProvider
@kingsloi
kingsloi / AnyPage.vue
Created January 14, 2017 01:33
Vue 2 - VueRouter - Simple Dynamic breadcrumbs + Microdata
export default {
beforeRouteEnter(route, redirect, next) {
next(vm => {
vm.$http.get(`${API.BASE}/${API.PAGE}/${route.name}`).then((response) => {
vm.page = response.data.page;
vm.eventHub.$emit('update-breadcrumb', [
{
title: 'Home',
@kingsloi
kingsloi / pug-bomb.php
Created December 15, 2018 00:00 — forked from retgef/pug-bomb.php
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
@kingsloi
kingsloi / PageController.php
Last active November 29, 2018 16:24 — forked from jeffochoa/EloquentSortableServiceProvider.php
Persistent Laravel filtering, pagination and column sorting link generation using macros
// Http/Controllers/PageController.php
public function index() {
$users = Page::sort()->paginate(10)->appends(request()->query());
return view('pages', compact('pages'));
}
@kingsloi
kingsloi / generate-select-for-bootstrap-tabs.js
Last active March 25, 2018 04:59
Generate <select> drop down boxes for Twitter Bootstrap tabs (.nav-tabs) - jsfiddle: http://jsfiddle.net/kingsloi/96ur6epu/
$(document).ready(function(){
//set the index counter
var i = 0;
//convert all .nav-tabs, except those with the class .keep-tabs
$('.nav-tabs').not( ".keep-tabs" ).each(function(){
//init variables
var $select,
@kingsloi
kingsloi / rpi-gpio-epaper-full-picture.js
Created January 5, 2018 23:26 — forked from dbushell/rpi-gpio-epaper-full-picture.js
rpi-gpio-epaper full picture example
const fs = require('fs');
const PNG = require('pngjs').PNG;
const EPD = require('rpi-gpio-epaper');
function readImage(imagePath) {
return new Promise((resolve, reject) => {
fs
.createReadStream(imagePath)
.pipe(new PNG())
.on('parsed', function() {
@kingsloi
kingsloi / installation.sh
Last active December 5, 2017 23:56
HAYO
# Download
composer global require heyareyouonline/hayo
# Register
hayo register <token>
# Usage
hayo online # Go online
hayo offline # Go offline
hayo heartbeat # Send single heartbeat
@kingsloi
kingsloi / curl.sh
Last active September 28, 2017 21:14
HAYO
curl -X GET \
https://heyareyou.online/api/kingsley.raspe \
-H 'cache-control: no-cache'
# Response:
# {"status":"online","lastReceived":1505584946,"expiryDate":1505585245}
curl -X POST \
https://heyareyou.online/api/heartbeat \
-H 'authorization: Bearer <token>'

Per Team User Subscription in Laravel Spark

If you want the ability to charge a team owner based on how many members their team has, like $10/user/month, then you utilize the Laravel Cashier functionality of incrementing the quantity.

You listen for when a new team member is added and you increase the quantity of the subscription by the amount of users and also listen for when a team member is removed to downsize charges. - Not Braintree Compatible


Within EventServiceProvider.php
'Laravel\Spark\Events\Teams\TeamMemberAdded' => [