Skip to content

Instantly share code, notes, and snippets.

View martinbean's full-sized avatar

Martin Bean martinbean

View GitHub Profile
@martinbean
martinbean / Condition.php
Created January 30, 2014 14:30
A rough, basic query object implementation
<?php
class Condition
{
protected $field;
protected $comparator;
protected $value;
const EQUALS = '=';
const GREATER_THAN = '>';
const LESS_THAN = '<';
@martinbean
martinbean / config.json
Created August 1, 2014 07:23 — forked from anonymous/config.json
Your Fight Site CMS Bootstrap variables
{
"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 August 29, 2015 14:05
Laravel validation trait.
<?php
trait ValidatorTrait {
protected $validator;
public function isValid()
{
return $this->getValidator()->passes();
}
@martinbean
martinbean / gist:8d299655f4207c580cac
Last active August 29, 2015 14:20
Displays a confirmation dialog if a form’s changed and the user tries to leave the page.
(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 July 28, 2015 18:58
Check submitted value matches a hash in Laravel.
<?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 August 9, 2015 19:55
Bower/Grunt example
{
"analytics": false,
"directory": "vendor/bower_components",
"interactive": false
}
@martinbean
martinbean / analytics.php
Created August 22, 2015 00:44
Regular expression to match Google Analytics property tracking ID
<?php return preg_match('/^UA-\d+-\d+$/', $test);
@martinbean
martinbean / Administrator.php
Last active September 6, 2015 19:21
Is administrator middleware for Laravel
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class Administrator
{
/**
<?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);
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.events.MouseEvent;
var myVideo:NetConnection = new NetConnection();
myVideo.connect(null);
var newStream:NetStream = new NetStream(myVideo);