Skip to content

Instantly share code, notes, and snippets.

View treffynnon's full-sized avatar
🧟

Simon Holywell treffynnon

🧟
View GitHub Profile
@treffynnon
treffynnon / iframeJQuery.js
Created February 4, 2010 15:19
jQuery: Accessing the contents of an iFrame
var iFrameBody = '';
$('#iframe').load(function(){
iFrameBody = $(this).contents().find('body');
});
@treffynnon
treffynnon / jQuery Using and Manipulating Select Lists.js
Created February 4, 2010 15:19
jQuery: Using and Manipulating Select Lists
//Get the currently selected option's value
$(this).val();
//Get the currently selected option's title
$(this).text();
//Set the currently selected option to the supplied value
$(this).val('value');
//Get an option with a specified value
@treffynnon
treffynnon / Method 1.php
Created February 4, 2010 15:19
Agavi: Form pre-population
<?php
// Like so
$this->getContext()->getRequest()->setAttribute('populate', new AgaviParameterHolder(array(
'question[0]' => 'Can you eat cheese?',
'answer[0]' => 'No'
)), 'org.agavi.filter.FormPopulationFilter');
// Or like so...
@treffynnon
treffynnon / Method 2.php
Created February 4, 2010 15:19
Agavi: Form pre-population by ID
<?php
// With ID
$populate =& $this->getContext()->getRequest()->getAttribute('populate', 'org.agavi.filter.FormPopulationFilter');
$populate['form-id-1'] = new AgaviParameterHolder(array(
'question[0]' => 'Can you eat cheese?',
'answer[0]' => 'No'
));
$populate['form-id-2'] = new AgaviParameterHolder(array(
'question[0]' => "How many frags do I have to get before I'm considered awesome?",
@treffynnon
treffynnon / jquery-ui-datepicker-in-dialogue.js
Created April 15, 2010 14:38
jQuery UI Datepicker in a Dialog
$('#dialogue').dialog({
modal: true,
open: function() {
$("#ui-datepicker-div").css("z-index", $(this).parents(".ui-dialog").css("z-index")+1);
}
});
@treffynnon
treffynnon / drop-cap-regex.php
Created July 9, 2010 17:31
Regex for adding a drop cap span into article text
<?php
$article['full_text'] = preg_replace('/^([\<\sa-z\d\/\>]*)(([a-z\&\;]+)|([\"\'\w]))/', '$1<span class="drop-cap">$2</span>', $article['full_text']);
@treffynnon
treffynnon / firefox-auto-complete-off.js
Created August 9, 2010 18:55
Firefox with Radio Inputs and it's Annoying Autocomplete
if($.browser.mozilla) {
$("form").attr("autocomplete", "off");
}
@treffynnon
treffynnon / Config.php
Created September 3, 2010 09:20
A PHP class to access a PHP array via dot notation
<?php
namespace Treffynnon;
/**
* A PHP class to access a PHP array via dot notation
* (Agavi http://www.agavi.org was the inspiration).
*
* This was hacked in to an existing codebase hence the
* global config array variable.
@treffynnon
treffynnon / gist:608936
Created October 3, 2010 21:06
An Excellent Development Server for a Team of Developers
# This file is /etc/apache2/httpd.conf
# This file is automatically included by Ubuntu in /etc/apache2/apache2.conf
Include /etc/apache2/dev-server.conf
@treffynnon
treffynnon / .htaccess
Created October 6, 2010 14:20
Force URLs to lower case in a RewriteRule using PHP. Blogged at http://simonholywell.com/post/2012/11/force-lowercase-urls-rewrite-php.html
RewriteEngine on
RewriteBase /
# force url to lowercase
RewriteCond %{REQUEST_URI} [A-Z]
# ensure it is not a file on the drive first
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule (.*) rewrite-strtolower.php?rewrite-strtolower-url=$1 [QSA,L]