Skip to content

Instantly share code, notes, and snippets.

Martin Bean martinbean

Block or report user

Report or block martinbean

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@martinbean
martinbean / Condition.php
Created Jan 30, 2014
A rough, basic query object implementation
View Condition.php
<?php
class Condition
{
protected $field;
protected $comparator;
protected $value;
const EQUALS = '=';
const GREATER_THAN = '>';
const LESS_THAN = '<';
@martinbean
martinbean / config.json
Created Aug 1, 2014 — forked from anonymous/config.json
Your Fight Site CMS Bootstrap variables
View config.json
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#c00",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
@martinbean
martinbean / ValidatorTrait.php
Last active Aug 29, 2015
Laravel validation trait.
View ValidatorTrait.php
<?php
trait ValidatorTrait {
protected $validator;
public function isValid()
{
return $this->getValidator()->passes();
}
@martinbean
martinbean / gist:8d299655f4207c580cac
Last active Aug 29, 2015
Displays a confirmation dialog if a form’s changed and the user tries to leave the page.
View gist:8d299655f4207c580cac
(function ($) {
$.fn.confirmUnload = function (options) {
var settings = $.extend({
message: 'You have unsaved changes.'
}, options);
return this.filter('form').each(function () {
var form = $(this);
var dataOnLoad = form.serialize();
@martinbean
martinbean / validation.php
Created Jul 28, 2015
Check submitted value matches a hash in Laravel.
View validation.php
<?php
// Definition
Validator::extend('hash_matches', function ($attribute, $value, $parameters) {
return Hash::check($value, $parameters[0]);
});
// Usage
'old_password' => 'required|hash_matches:'.$old_password,
@martinbean
martinbean / .bowerrc
Created Aug 9, 2015
Bower/Grunt example
View .bowerrc
{
"analytics": false,
"directory": "vendor/bower_components",
"interactive": false
}
@martinbean
martinbean / analytics.php
Created Aug 22, 2015
Regular expression to match Google Analytics property tracking ID
View analytics.php
<?php return preg_match('/^UA-\d+-\d+$/', $test);
@martinbean
martinbean / Administrator.php
Last active Sep 6, 2015
Is administrator middleware for Laravel
View Administrator.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class Administrator
{
/**
@martinbean
martinbean / WHOIS look-up bookmark
Created Oct 26, 2010
Want to quickly do a WHOIS look-up of the domain of the current website you're browsing? Simple save the following snippet as a bookmark in your favourite WebKit-enabled web browser...
View WHOIS look-up bookmark
javascript:var loc=window.location.host;window.location.href='http://whois.domaintools.com/'+loc;
View toro_example_index.php
<?php
// include both our template library and the Toro framework
require_once('lib/php-template.php');
require_once('lib/toro.php');
// set our template directory and a new instance
$tpl_path = dirname(__FILE__) . '/templates/';
$tpl = new Template($tpl_path);
You can’t perform that action at this time.