Skip to content

Instantly share code, notes, and snippets.

@bbrothers
bbrothers / showlayout.css
Created March 23, 2014 01:39
Highlight DOM elements
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
<?php
use ArrayObject;
use OutOfBoundsException;
use SplObjectStorage;
class IdentityMap
{
/**
* @var ArrayObject
@bbrothers
bbrothers / DecoratorTrait.php
Created September 15, 2015 17:59
Array/Object Unifier
<?php namespace Acme\Util;
use ArrayAccess;
use Countable;
trait DecoratorTrait
{
/**
* The object or array being decorated
*
#!/bin/bash
git diff --cached --name-only | while read FILE; do
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then
# Courtesy of swytsh from the comments below.
if [[ -f $FILE ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo -e "\e[1;31m\tAborting commit due to files with syntax errors" >&2
exit 1
@bbrothers
bbrothers / devldn.raml
Created November 25, 2015 07:59
First rough draft of the devldn API
#%RAML 0.8
title: devldn
version: v1
baseUri: https://devldn.dev
mediaType: application/json
resourceTypes:
- readOnlyCollection:
description: Collection of available <<resourcePathName>>.
get:
@bbrothers
bbrothers / detect-ajax
Created December 17, 2012 15:49
Detect if ajax request
$_SERVER['HTTP_X_REQUESTED_WITH'] == 'xmlhttprequest'
@bbrothers
bbrothers / gist:4441191
Last active December 10, 2015 13:29
Test Question 3
<?php
echo '<pre>';
for($i = 100;$i>=0;$i--){
print $i;
if($i % 2 === 0) {
print " is even";
if($i % 12 === 0) printf(" and is %d dozen",$i/12);
}
else print " is odd";
print ".\n";
.email {
unicode-bidi: bidi-override;
direction: rtl;
text-align: left;
}
@bbrothers
bbrothers / string-replace.sql
Created March 13, 2013 20:23
mysql string replace
UPDATE my_table
SET my_field = REPLACE(my_field, 'old-string', 'new-string')
WHERE my_field LIKE '%old-string%'
# laravel new-app
alias laravel="git clone -o laravel -b develop https://github.com/laravel/laravel.git"
alias artisan="php artisan"
alias migrate="php artisan migrate"
alias serve="php artisan serve"
alias dump="php artisan dump"
alias t="phpunit"
# Generators Package