Skip to content

Instantly share code, notes, and snippets.

View dhrrgn's full-sized avatar
🦙

Dan Horrigan dhrrgn

🦙
  • OH, USA
  • 09:24 (UTC -04:00)
View GitHub Profile
@dhrrgn
dhrrgn / bootstrap.php
Created May 2, 2011 01:32
Load config based on Environment in Fuel
<?php
/********** This is in app/bootstrap.php ************/
// Bootstrap the framework DO NOT edit this
require_once COREPATH.'bootstrap.php';
/**
* Set the timezone to what you need it to be.
*/
<?php
class Guy {
protected $girl = null;
protected $drinks = 0;
public function __construct(Girl $girl)
{
$this->girl = $girl;
@dhrrgn
dhrrgn / custom_loader.php
Created May 18, 2011 01:18
Small Benchmarks to test the speed of loading from the include path rather than a custom loader.
<?php
/**
* As you can see this code is longer and does more. It seems to be about 32%
* slower than using the PHP Include path (see next file)
*/
class Finder {
protected static $paths;
public static function add_path($path) {
@dhrrgn
dhrrgn / di.php
Created September 22, 2011 17:47
DI Example
<?php
class Foo extends Container {
public function send_mail()
{
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
@dhrrgn
dhrrgn / non-di.php
Created September 22, 2011 18:01
Non-DI Example
<?php
class Foo extends Container {
public function send_mail()
{
$mailer = Swift_Mailer::newInstance('mail');
$mailer->newMessage('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
@dhrrgn
dhrrgn / _instructions.md
Created September 28, 2011 03:50
A Sublime Text 2 Project file for Fuel

Sublime Text 2 Fuel Project File

Description

This sets up your Sublime Text 2 Fuel project so that your tab and line ending settings are all correct. This way if you like spaces or something, you can still use them by default.

Usage

  1. Create a file named fuel.sublime-project in your Fuel root directory (not the web root).
  2. Open with Sublime Text 2
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@dhrrgn
dhrrgn / PSR-0-final-proposal.md
Created October 7, 2011 02:50 — forked from Thinkscape/PSR-0-final-proposal.md
PSR-0 Final Proposal (PHP Standards Working Group)

PSR-0 Final Proposal (PHP Standards Working Group)

The following describes the mandatory requirements that must be adhered to for autoloader interoperability.

Mandatory:

  • A fully-qualified namespace and class must have the following structure \ <Vendor Name> \ (<Namespace>)* \ <Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
@dhrrgn
dhrrgn / config.yml
Created October 9, 2011 19:12
Fuel Default config in Yaml
base_url:
url_suffix:
index_file: index.php
profiling: false
caching: false
cache_dir: %APPPATH%cache/
@dhrrgn
dhrrgn / gist:1281581
Created October 12, 2011 15:47
Bookmarklet to make all bug references in the EE Changelog links
javascript:$('div[id^=version] ul li ul li').each(function () {var el = $(this);el.html(el.html().replace(/[\s\(\[]#(\d+)\)/, '(<a href="http:\/\/expressionengine.com\/bug_tracker\/bug\/$1">#$1</a>)'));});