Skip to content

Instantly share code, notes, and snippets.

View marijn's full-sized avatar

Marijn Huizendveld marijn

View GitHub Profile
anonymous
anonymous / gist:179268
Created September 1, 2009 18:16
<?php
/**
* sfValidatorZip validates a zip code.
*
* @author Brent Shaffer <bshafs@gmail.com>
*/
class sfValidatorZip extends sfValidatorRegex
{
/*
* AppController.j
* OutlineView
*
* Created by Chandler Kent on December 7, 2009.
* Copyright 2009, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPOutlineView.j>
function t(s,d,p){for(p in d)s=s.replace(new RegExp('{'+p+'}','g'),d[p]);return s;}
/*
String templating engine:
t("Hello {name}!, It is {date}!", { name: "Thomas", date: function(){ return new Date }});
// = "Hello Thomas!, It is Sun May 08 2011 15:15:33 GMT-0400 (EDT)!"
*/
@eligrey
eligrey / document-click.js
Created June 24, 2011 04:35
document.click(x, y) to click the element at specific coords
document.click = function(x, y) {
"use strict";
var
doc = this
, node = doc.elementFromPoint(x, y)
, click = doc.createEvent("UIEvent")
;
click.initUIEvent("click", true, true, self, 1);
return node.dispatchEvent(click);
@eligrey
eligrey / create-view.js
Created October 12, 2011 02:26
Synchronous view creation
/*
* create-view.js
* Easily create new views for accessing clean builtins, etc.
*
* 2011-10-11
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@everzet
everzet / resource_watcher_usage.php
Created November 29, 2011 22:40
Symfony2.1 ResourceWatcher usage example
<?php
$watcher = new Symfony\Component\ResourceWatcher\ResourceWatcher;
// track any change inside directory:
$watcher->track('some/folder1', function($event) {
echo '['.$event->getType().'] '.$event->getResource()."\n"
});
@igorw
igorw / composer.json
Created December 12, 2011 10:42 — forked from beberlei/composer.json
A minimal Symfony Components Framework
{
"require": {
"php": ">=5.3.2",
"symfony/http-kernel": "2.1-dev",
"symfony/routing": "2.1-dev"
}
}
@everzet
everzet / composer.json
Created December 22, 2011 08:56
Install & use Behat+Mink with ALL dependencies through Composer
{
"require": {
"behat/behat": ">=2.2.2",
"behat/mink": ">=1.3.2"
},
"repositories": {
"behat/mink-deps": { "composer": { "url": "behat.org" } }
}
}
@edorian
edorian / clean-use.php
Created February 3, 2012 08:56 — forked from lapistano/clean-use.php
Script to clean unnecessary PHP use statements
#!/usr/bin/env php
<?php
$paths = array();
if (isset($_SERVER['argv']))
{
$paths = $_SERVER['argv'];
array_shift($paths);
if (!$paths)
<?php
final class BlogPost
{
private $created;
private $publish;
public function __construct()
{
$this->created = new DateTime('now');