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
---
- 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()
@adactio
adactio / placeholderFromDatalist.js
Created August 12, 2012 15:54
Generate a placeholder attribute from the datalist associated with that input.
(function(win,doc) {
if (doc.querySelectorAll) {
var inputs = doc.querySelectorAll('input[list]'),
total = inputs.length;
for (var i=0; i<total; i++) {
var input = inputs[i],
id = input.getAttribute('list'),
list = doc.getElementById(id),
options = list.getElementsByTagName('option'),
amount = options.length,
@jamierumbelow
jamierumbelow / gist:3702259
Created September 11, 2012 21:38
Something stupidly cool in Ruby
def search id
Model.find id
rescue => e
log "Error in search: #{e.message}"
end