Skip to content

Instantly share code, notes, and snippets.

@darrenderidder
darrenderidder / bashpath.sh
Created May 16, 2011 15:24
Get path of running script in bash
#!/bin/bash
# A simple test script to demonstrate how to find the
# "absolute path" at which a script is running. Used
# to avoid some of the pitfals of using 'pwd' or hard-
# coded paths when running scripts from cron or another
# directory.
#
# Try it out:
# run the script from the current directory, then
@xanf
xanf / AjaxAuthenticationListener.php
Created June 8, 2011 19:20
AJAX auth errors listener for Symfony2
<?php
namespace Application\ProdrepHelperBundle\Component\Event;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
/**
*/
class AjaxAuthenticationListener
@jakzal
jakzal / KernelAwareTest.php
Last active June 27, 2024 16:20
KernelAwareTest
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@rocktronica
rocktronica / gist:1700623
Created January 29, 2012 21:01
An Auto-Updating Data URI Text Editor
data:text/html,
<body id='b'>
<textarea spellcheck="false" id="t"></textarea>
<script>
var f,
t = document.getElementById("t"),
@leon
leon / nginx.conf
Created June 29, 2012 16:34
Nginx PHP-FPM Symfony 2 minimal config
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
@ollietb
ollietb / 1. README.md
Created July 10, 2012 11:02 — forked from Dattaya/1. README.md
Symfony2.1.*. How to integrate assetic lessphp filter.

Symfony2.1. How to integrate assetic lessphp filter.

  • Add the following package to your composer.json:
"require": {
    ...
    "leafo/lessphp": "dev-master",
 ...
@xphere
xphere / TagBundle.php
Created July 11, 2012 18:55
Mark a service as a consumer of others via tags and extension
<?php
namespace xPheRe\Bundle\TagBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use xPheRe\Bundle\TagBundle\DependencyInjection\Compiler\TagCollectionPass;
class xPheReTagBundle extends Bundle
{
@xphere
xphere / MenuPlannerAPI.php
Last active October 12, 2015 03:38
Menu Planner API
$planner = new Planner();
$planner
->menu('menu')
->avoid('ingredient:sugar')
->avoid('type:fish')
->day('monday')
->meal('breakfast')
->dish('snack')->end()
->end()
->meal('dinner')
@mbostock
mbostock / .block
Last active August 10, 2025 18:05
Force-Directed Graph
license: gpl-3.0
height: 600
redirect: https://observablehq.com/@d3/d3-force-directed-graph