Skip to content

Instantly share code, notes, and snippets.

Jamie York ziadoz

View GitHub Profile
@beryllium
beryllium / components.md
Created Jun 12, 2014
Zero-Dependency Symfony Components
View components.md

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 Aug 15, 2014
A MySQLi Proxy with Query logging.
View MySQLiProxy.php
<?php
namespace Core\Database;
use Logger;
use mysqli;
use Psr\Log\LoggerInterface;
/**
* Class MySQLiProxy
@nojacko
nojacko / Coding Standards for Lazy PHP Devs
Last active Aug 29, 2015
Coding Standards for Lazy PHP Devs
View 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
View phantomjs.yml
---
- 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 Aug 29, 2015
Simple Navigation Iterator (Fun With Iterators)
View RecursiveNavigationIterator
<?php
/**
* RecursiveNavigationIterator
*/
class RecursiveNavigationIterator extends RecursiveIteratorIterator
{
public $openTag = "<ul>\n";
public $closeTag = "</ul>\n";
View gist:07f4de6479621ea7e194
<?php
/* This gist is offered as is, make sure to test in your environment
*
* This class can be used to iterate over a large Eloquent query. It uses a combination of the PDO Fetch and
* the chunk methods to collect a series of items in memory. The chunk part was necessary in order to implement
* eager loading options. You can set the CHUNK_SIZE in the code to set how many rows to load in memory at a time
* again for the eager loading purposes.
*
* I am sure there are other ways to implement this technique more effectively
View gist:023b84f2002a39ae6c53
// 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 Jun 16, 2015
The Monty Hall Problem
View monty-hall.php
<?php
class MontyHall
{
const CAR = 'Car';
const GOAT = 'Goat';
public $doors;
public $choice;
public function __construct()
@jordelver
jordelver / gist:3230399
Created Aug 1, 2012
Ruby simple delegator
View gist:3230399
# Example from http://mikepackdev.com/blog_posts/31-exhibit-vs-presenter
class Decorator < SimpleDelegator
end
class Car
def price
1_000_000
end
end
View ChunkExtension.php
<?php
namespace Acme\DemoBundle\Twig;
use Twig_Extension;
use Twig_Filter_Method;
class ChunkExtension extends \Twig_Extension
{
public function getFilters()
You can’t perform that action at this time.