Skip to content

Instantly share code, notes, and snippets.

View leemason's full-sized avatar
🎯
Focusing

Lee Mason leemason

🎯
Focusing
View GitHub Profile
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
package foobar
import (
"github.com/xxx/xxx/internal/bazzer" // why not just "../bazzer"?
)
// Existing solution (result not implementation)
const existingWay = theUrlConstructor([ '/api/v1/resource/{0}/{1}', 'my string, with unsafe', 'url +characters+' ])
// /api/v1/resource/my%20string%2C%20with%20unsafe/url%20%2Bcharacters%2B
// New solution
const url = (strings, ...values) => {
return strings.reduce((compiled, string, index) => {
return compiled.concat(string, encodeURIComponent(values[index] || ''))
}, []).join('')
}
@leemason
leemason / 001filebackup.sh
Created April 22, 2016 19:48
Simple tar archive backup script to be placed in the /etc/cron.daily directory.
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
stamp=`date +"%s-%A_%d_%B_%Y@%H_%M"`
name="${stamp}_backup.tgz";
#tar filesystem
tar cvpzf /backups/file/${name} --exclude=/backups/file --exclude=/lost+found --exclude=/proc/* --exclude=/sys/* --exclude=/mnt/* --exclude=/media/* --exclude=/tmp/* --exclude=/var/run/* --exclude=/var/lock/* --exclude=/var/cache/apt/archives/* --exclude=/home/*/.gvfs --exclude=/run --exclude=/dev /
var page = require('webpage').create(),
system = require('system'),
loc, address;
if (system.args.length < 3) {
console.log('Usage: screenshot.js <some URL> <some LOCATION>');
phantom.exit();
}
//viewportSize being the actual size of the headless browser
@leemason
leemason / custom_trigger.php
Last active June 25, 2016 12:59
Example assignment of custom triggers for WHMCS Achievements & Rewards Programme
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
//we register the triggers on this hook to ensure the functions and class is loaded without needing to check if the module is enabled.
add_hook('achievements/register_triggers', 1, function($achievements) {
$achievements->registerTrigger([
'group' => 'forum',//the group this trigger belongs to
'name' => 'newtopic',//the name of this trigger (must be unique)
'description' => 'Creates Topic',//the text to us in the dropdown when an admin selects a trigger
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;
use App\Jobs\Domains\Screenshot;
use App\Models\Domain;
use Illuminate\Http\Request;
class DomainsController extends Controller
@extends('layout')
@section('title', $title)
@section('content')
<div id="domain" style="margin-top:20px;width: 100%;">
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__title mdl-card--expand" :style="{ backgroundImage: 'url(' + domain.screenshot + ')' }">
<?php
namespace App\Events\Domains;
use App\Events\Event;
use App\Models\Domain;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class ScreenshotUpdated extends Event implements ShouldBroadcast
{
<?php
namespace App\Jobs\Domains;
use App\Events\Domains\ScreenshotUpdated;
use App\Jobs\Job;
use App\Models\Domain;
use Carbon\Carbon;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;