Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@beryllium
beryllium / components.md
Created June 12, 2014 21:10
Zero-Dependency Symfony Components

Zero-Dependency Symfony Components

These components have zero dependencies. They all require PHP > 5.3.3, but they can be integrated into projects without pulling in surprise dependencies. Some of them might not be terribly useful without a good binding component (e.g., DomCrawler and CSSSelector work best when using BrowserKit).

@dhrrgn
dhrrgn / MySQLiProxy.php
Created August 15, 2014 15:28
A MySQLi Proxy with Query logging.
<?php
namespace Core\Database;
use Logger;
use mysqli;
use Psr\Log\LoggerInterface;
/**
* Class MySQLiProxy
@nojacko
nojacko / Coding Standards for Lazy PHP Devs
Last active August 29, 2015 14:08
Coding Standards for Lazy PHP Devs
export PATH=~/.composer/vendor/bin:$PATH
composer global require "squizlabs/php_codesniffer=*";
# Check and Beautify
# - Ignore some commonly ignored things (composer folder, blade templates, ...)
phpcs ./ --ignore=test-reports,vendor,*.blade.php --standard=psr2,psr1 --report=summary
phpcbf ./ --ignore=test-reports,vendor,*.blade.php --standard=psr2,psr1 --report=summary
---
- name: Install libfontconfig1
apt: pkg=libfontconfig1 state=installed
- name: Download phantomjs
get_url: url=https://bitbucket.org/ariya/phantomjs/downloads/{{phantomjs.name}}.tar.bz2 dest=/usr/local/share/{{phantomjs.name}}.tar.bz2 validate_certs=no
- name: Unpack phantomjs
command: tar xvjf /usr/local/share/{{phantomjs.name}}.tar.bz2 -C /usr/local/share creates=/usr/local/share/{{phantomjs.name}}
@jakefolio
jakefolio / RecursiveNavigationIterator
Last active August 29, 2015 14:09
Simple Navigation Iterator (Fun With Iterators)
<?php
/**
* RecursiveNavigationIterator
*/
class RecursiveNavigationIterator extends RecursiveIteratorIterator
{
public $openTag = "<ul>\n";
public $closeTag = "</ul>\n";
// declaration
function foo (n) { return n + 1; }
// expression
// note, fat arrow functions have very different meaning (usually what I want, though)
var foo = function (n) { return n + 1; };
var foo = (n) => { return n + 1; };
var foo = n => n + 1;
// object methods
@WillJW
WillJW / monty-hall.php
Created June 16, 2015 23:03
The Monty Hall Problem
<?php
class MontyHall
{
const CAR = 'Car';
const GOAT = 'Goat';
public $doors;
public $choice;
public function __construct()
@jordelver
jordelver / gist:3230399
Created August 1, 2012 20:25
Ruby simple delegator
# Example from http://mikepackdev.com/blog_posts/31-exhibit-vs-presenter
class Decorator < SimpleDelegator
end
class Car
def price
1_000_000
end
end
@stevelacey
stevelacey / ChunkExtension.php
Created August 2, 2012 09:16
Twig Chunk Extension
<?php
namespace Acme\DemoBundle\Twig;
use Twig_Extension;
use Twig_Filter_Method;
class ChunkExtension extends \Twig_Extension
{
public function getFilters()
@nojacko
nojacko / external.js.md
Last active October 8, 2015 06:29
jQuery: Open External Links in New Window (and add class)