Skip to content

Instantly share code, notes, and snippets.

View leemason's full-sized avatar
🎯
Focusing

Lee Mason leemason

🎯
Focusing
View GitHub Profile
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 / 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
@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
{
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
<?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;
<?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
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Domain extends Model
{
/**
* The attributes that are mass assignable.
@leemason
leemason / example.js
Created May 6, 2016 19:21
Hybrid ORM
var Mapper = require('./Mapper'),
Model = require('./Model');
var User = Model.extend({
attributes: {
name: String,
email: String
}
});