Skip to content

Instantly share code, notes, and snippets.

View colinmollenhour's full-sized avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@colinmollenhour
colinmollenhour / gist:83824
Created March 23, 2009 22:40
Event Delegator for Prototype
/*
Author: Colin Mollenhour
Delegator - An event delegation class for Prototype.
Supports CSS selectors or binary functions and mouseenter and mouseleave emulation.
Usage:
1. Create a 'Delegator' instance passing the event type to delegate. You cannot change the event type later.
2. Add some rules to the Delegator instance using "add". Rules can be added or removed at any point.
class Kohana extends Kohana_Core {
// Se the active component in the Router
public static $component;
/**
* A wrapper for Kohana::find_file, this is to be used where the component path should be searched first
*/
public static function find_file($directory, $filename, $required = FALSE, $ext = FALSE)
{
@colinmollenhour
colinmollenhour / modman
Created October 17, 2009 04:48
Module Manager (old version)
#!/bin/bash
# Module Manager
# Version 1.0.1
# System Requirements:
# - bash
# - web server must follow symlinks
# - The following utilities must be locatable in your $PATH
# svn, grep (POSIX), find, ln, sed, cp, basename, dirname
@colinmollenhour
colinmollenhour / calltest.php
Created February 14, 2010 18:46
call_user_func_array performance comparison
<?php
$iterations = 100000;
echo "Iterations: $iterations\n";
class Test {
public function nothing0(){}
public function nothing1($arg1){}
public function nothing2($arg1,$arg2){}
public function nothing3($arg1,$arg2,$arg3){}
@colinmollenhour
colinmollenhour / monitor-file.sh
Created June 24, 2010 03:37
Monitor File Script
#!/bin/bash
#
# Colin Mollenhour
#
# Run this from a cron job to be notified when a file is changed.
# Use the --append-new option to append new content to the notification email.
#
# Examples:
#
# # File in a directory changed? (recursive)
@colinmollenhour
colinmollenhour / buildhtaccess.sh
Created June 30, 2010 22:42
.htaccess combiner
#!/bin/bash
# Author: Colin Mollenhour
#
# Usage: Run from the webroot, .htaccess-combined will be created.
dest='.htaccess-combined'
pwd=`pwd`
echo -n "" > $dest
while read -r file; do
loc=`dirname $file`
Plotter = {};
Plotter.HOVER_SCALE = 1.5;
Plotter.EVENT_CORNER_RADIUS = 5;
Raphael.fn.gb = {};
Raphael.fn.gb.event = function(event,x,y,w,h){
console.debug('event', event, x,y,w,h);
var set = this.set();
set.rect = this.rect(x,y,w,h,5).attr({
fill:'red',
/**
* Author: Colin Mollenhour
* Description: Wraps Raphael primitives with a set consisting of a primitive and an invisible
* clone used for handling mouse events.
* Access the overlay element and reset its opacity with: overlay()
* Access the set within overlay event handlers with: this.set
*/
Raphael.fn.mouseable = function(){
var args = Array.prototype.slice.call(arguments);
var type = args.shift();
@colinmollenhour
colinmollenhour / Auth_Mongo.php
Created September 20, 2010 02:12
Auth_Mongo for Kohana
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Mongo Auth driver. Adapted from Kohana_Auth_ORM.
*/
class Auth_Mongo extends Auth {
/**
* Checks if a session is active.
*
* @param string role name
@colinmollenhour
colinmollenhour / makePhpstormMap.php
Last active October 6, 2023 13:26
Generate map of factory method arguments to resolved class names for Magento projects
<?php
/* This script generates a mapping of factory methods/parameters to the resulting class
* names in such a way that PhpStorm 6.0.1 can use for autocompletion and chaining.
*
* Example:
* cd [magento root]
* php ~/makePhpstormMap.php > .phpstorm.meta.php
*
*/