Skip to content

Instantly share code, notes, and snippets.

function setSelectionPlugin() {
var _setSelectionRange, _getCursorPosition, support = (function() {
var input = document.createElement('input'), result;
result = {
setSelectionRange: ('setSelectionRange' in input) || ('selectionStart' in input),
createTextRange: ('createTextRange' in input) || ('selection' in document)
};
input = null;
return result;
}());
@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active September 24, 2024 14:47
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
@raykolbe
raykolbe / CQRS.php
Created May 21, 2013 20:36
CQRS is simple!
<?php
namespace CQRSSample\Domain\Model
{
/**
* Please read this. It may be interesting to you. You can ridicule me ONLY if you read the whole thing.
*
* CQRS is NOT about different data sources and is NOT about Event Sourcing.
* CQRS IS about breaking out your reads and writes. It's powerful and simple!
@gordalina
gordalina / Example.php
Created May 17, 2013 08:40
Resolve Link headers into entities and inject them in the request attributes
<?php
// Controller
public function linkAction(Request $request)
{
if (false === $request->attributes->has('link')) {
throw new HttpException(400, 'Link header was not provided');
}
@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
@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')
@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
{
@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",
 ...
@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 {
@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"),