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>
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@btompkins
btompkins / Fabric-UserSetup.py
Created February 7, 2011 18:15
Simple fabric function to create a new user
def new_user(admin_username, admin_password):
env.user = 'root'
# Create the admin group and add it to the sudoers file
admin_group = 'admin'
runcmd('addgroup {group}'.format(group=admin_group))
runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format(
group=admin_group))
# Create the new admin user (default group=username); add to admin group
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);
@nrk
nrk / RedisPublishHandler.php
Created August 24, 2011 14:01
A simple handler for Monolog that publishes log entries to Redis channels.
<?php
namespace Nrk\Monolog\Handler;
use Predis\Client;
use Monolog\Logger;
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\AbstractProcessingHandler;
/**
@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.
*/
<!DOCTYPE html>
<script src="url.js"></script>
<script>
var url = new URL('http://www.example.com/a/b/c.html?p=q&r=s&p&p=t#hash');
for (var key in url) {
console.log(key, url[key]);
}
@jakzal
jakzal / deploy.rb
Created November 28, 2011 16:11
Updating assets version before assetic dump (capifony)
namespace :symfony do
namespace :assets do
desc "Updates assets version"
task :update_version do
run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/app/config/config.yml"
end
end
end
before "symfony:assetic:dump" do