Skip to content

Instantly share code, notes, and snippets.

View Stanton's full-sized avatar
💃

Paul Stanton Stanton

💃
View GitHub Profile
@Stanton
Stanton / target.js
Created March 12, 2012 13:00
Cross browser JavaScript event.target
/**
* A cross-browser method to get the correct event target
* @param object e The event being fired
* @return object targ The event target
*/
Navigation.prototype.getEventTarget = function(e)
{
var targ;
if (e.target) { // W3C
@Stanton
Stanton / gist:1606415
Created January 13, 2012 14:15
Add method
<?php
App::uses('AppController', 'Controller');
/**
* Users Controller
*
* @property User $User
*/
class UsersController extends AppController {
@Stanton
Stanton / gist:1476863
Created December 14, 2011 14:46
Validation for James
<?php
// set up a stack
$options = array();
/* our list of values to ignore (the ones that are permitted to be duplicates)
(made into an array so that you can easily add other options to be ignored,
without having to modify the other rules) */
$exceptions = array('10');
@Stanton
Stanton / gist:1390945
Created November 24, 2011 09:19
Release notes schema
# Dump of table release_notes
# ------------------------------------------------------------
CREATE TABLE `release_notes` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`version_id` int(11) DEFAULT NULL,
`detail` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@Stanton
Stanton / gist:1200794
Created September 7, 2011 14:58
image.php
<?php
/**
* image Generator -- see trac ticket #778 and #795
*
* Resizes an image
*
* For proper documentation see the phpdoc for the imageGenerator function.
*/
// If there isn't a directory for cached images, make one.
@Stanton
Stanton / gist:1200781
Created September 7, 2011 14:53
imageGenerator usage
<?php
/* HEADLINE ARTICLE */
if (isset($headline)) :
?>
<div id="headline" class="search_result">
<a href="http://<?php print $DOMAIN . buildNewsArticleURL($headline[0]->id);?>">
<?php
if ($headline[0]->imageURL != "") {
print imageGenerator('http://' . $DOMAIN . '/images/'. $headline[0]->imageURL, array(
@Stanton
Stanton / gist:1200761
Created September 7, 2011 14:48
imageGenerator
<?php
/**
* image Generator -- see trac ticket #778
*
* takes an image and does some magic on it.
*/
/**
* Resizes an image
*
* Once an image has been generated by this function, it is cached and subsequent
@Stanton
Stanton / gist:1167702
Created August 24, 2011 09:58
Just for funzies
<?php
// Now this is a story, all about how my $dirTree got flipped-turned upside down
$reversed_dirTree = array_reverse($dirTree);
// and I'd like to take a minute, just sit right there, I'll tell you how loop the object to get the default category down there.
foreach ($reversed_dirTree as $dirTree_category) {
if (in_array($dirTree_category->name, $directory_category_names)) {
$parent_cat_name = $dirTree_category->name;
}
}
?>
<?php
$value = ($short_form == 'sent') ? 'Sent' : 'Send';
?>
<input type="submit" value="<?=$value;?>" />
<?php
function getNeighbours($moblog, $limit = 3, $order = 'Moblog.modified') {
// check for existence of order param in session, and use it if so
if ($this->Session->check('Moblog.order')) {
$order = $this->Session->read('Moblog.order');
}
// modify the find statements based on the order param