Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View marijn's full-sized avatar

Marijn Huizendveld marijn

View GitHub Profile
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="pink_tie.logger.command_formatter" class="Monolog\Formatter\LineFormatter">
<argument>{ "%%message%%": %%context%% }
</argument>
</service>
</services>
</container>
@marijn
marijn / CustomerContext.php
Created January 28, 2013 12:23
Example organization of context files in Behat.
<?php
use Behat\Behat\Context\BehatContext;
final class CustomerContext extends BehatContext
{
// ... your step definitions related to customer
}
@marijn
marijn / terms-and-conditions-in-label.twig
Created November 23, 2012 21:54
This is how you add a link to a label with Symfony forms, sort of. Cause you'll have a label tag twice...
{% set terms_link %}<a title="{% trans %}Read the General Terms and Conditions{% endtrans %}" href="{{ path('get_general_terms_and_conditions') }}">{% trans %}General Terms and Conditions{% endtrans %}</a>{% endset %}
{% set general_terms_and_conditions %}{{ 'I have read and accept the %general_terms_and_conditions%.'|trans({ '%general_terms_and_conditions%': terms_link })|raw }}{% endset %}
<div>
{{ form_errors(form.acceptGeneralTermsAndConditions) }}
{{ form_widget(form.acceptGeneralTermsAndConditions) }}
<label for="{{ form.acceptGeneralTermsAndConditions.vars.id }}">{{ general_terms_and_conditions|raw }}</label>
</div>
@marijn
marijn / unshorten.php
Created October 16, 2012 20:52
Unshorten URLS with PHP and CURL
<?php
/**
* @link http://jonathonhill.net/2012-05-18/unshorten-urls-with-php-and-curl/
*/
function unshorten_url($url) {
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => TRUE, // the magic sauce
CURLOPT_RETURNTRANSFER => TRUE,
@marijn
marijn / mobile-meta-links.html
Created October 15, 2012 21:34 — forked from pierswarmers/mobile-meta-links.html
iOS Web App Configuration
@marijn
marijn / SELECT_PAGES_THAT_ARE_NOT_APPS.sql
Created August 30, 2012 13:11
FQL for selecting pages that are not FB apps
SELECT page_id, name, description, page_url FROM page WHERE page_id IN (
SELECT page_id FROM page_admin WHERE uid=me() AND NOT (
page_id IN (
SELECT page_id, type FROM page_admin WHERE uid=me() AND type = 'APPLICATION'
)
)
)
@marijn
marijn / apc.php
Created May 15, 2012 11:20
Default APC.php file for clearing the opcode cache etc.
<?php
/*
+----------------------------------------------------------------------+
| APC |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2011 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
<?php
class DateTimeTest extends PHPUnit_Framework_TestCase
{
private $dateTimeZone;
public function setUp()
{
$this->dateTimeZone = new DateTimeZone("UTC");
}
@marijn
marijn / Example.php
Created April 3, 2012 16:53
An example on sorting Doctrine\Common\Collection\ArrayCollection elements
<?php
$collection = new Doctrine\Common\Collection\ArrayCollection();
// add objects to the collection that contain a getCreated method returning a DateTime instance
$iterator = $collection->getIterator();
$iterator->uasort(function ($first, $second) {
if ($first === $second) {
@marijn
marijn / README.markdown
Created March 20, 2012 16:10
Finite state machine for locks