Skip to content

Instantly share code, notes, and snippets.

View rowanmanning's full-sized avatar
📢
honk

Rowan Manning rowanmanning

📢
honk
View GitHub Profile
@rowanmanning
rowanmanning / jquery.getfeed.js
Created March 14, 2010 10:09
A simple plugin which wraps the Google Ajax Feeds API (without having to load google ajaxlib)
/*
* jQuery getFeed Plugin 1.0
*
* Tested in jQuery 1.4.2
*
* Copyright 2010, Rowan Manning (http://www.rowanmanning.co.uk/)
* Dual licensed under the MIT or GPL Version 2 licenses
*/
(function($){
//============================================================
@rowanmanning
rowanmanning / git-archiver.sh
Created April 8, 2010 10:32
Simple build script for git archiving
#!/bin/sh
# DROP THIS IN A GIT REPO THEN CALL FROM THE COMMAND LINE
# ask for a version (tag) to build (if not provided)
if [ -z $1 ]
then
echo "Available versions:";
echo $(git tag) | sed s/\ /,\ /g;
echo "Which version would you like to build?";
@rowanmanning
rowanmanning / get_feed.php
Created May 12, 2010 09:40
get_feed php functions
<?php
/**
* Get an RSS or ATOM feed.
* @param string $url The URL of the feed to get.
* @param integer $count [optional] The number of entries to get. Default value is 10.
* @param string $api_key [optional] The Google AJAX Feed API key. Default value is NULL.
* @param string $language [optional] The language to retrieve the feed in. Default value is NULL.
* @return array Returns an array representing the feed.
*/
@rowanmanning
rowanmanning / Graphics_Color.php
Created June 4, 2010 14:24
A simple colour class for PHP
<?php
/**
* PHP Color Class
*
* An simple colour class for PHP. Note: in documentation the 'colour' spelling is intentional.
*
* @subpackage Graphics
* @author Rowan Manning (http://rowanmanning.co.uk/)
* @copyright Copyright (c) 2011, Rowan Manning
* @license Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
@rowanmanning
rowanmanning / jquery.caret.js
Created June 28, 2010 11:40
Cross-browser caret position
/*
* jQuery caret Plugin 0.2
*
* Tested in jQuery 1.4.2
*
* Copyright 2010, Rowan Manning (http://www.rowanmanning.co.uk/)
* Dual licensed under the MIT or GPL Version 2 licenses
*/
(function($){
//============================================================
/*
* jQuery expandAbbr Plugin 0.1
*
* Tested in jQuery 1.4.2
*
* Copyright 2010, Rowan Manning (http://www.rowanmanning.co.uk/)
* Dual licensed under the MIT or GPL Version 2 licenses
*/
(function($){
//============================================================
@rowanmanning
rowanmanning / bookmarklet.js
Created November 22, 2010 22:20
Simple bookmarklet to load a javascript
javascript:(function(d){s=d.createElement('script');s.src='http://example.com/example.js';d.body.appendChild(s);})(document);
@rowanmanning
rowanmanning / relative_time.php
Created February 11, 2011 12:37
Calculate the amount of time between two dates/timestamps in PHP. Return the result as a nicely formatted string or an array of data.
<?php
/**
* Get the relative time between two timestamps.
*
* @access public
* @param integer|string $time The date or timestamp that represents the time we're comparing to.
* @param integer|string $comparison_time [optional] The date or timestamp we want comparisons to be relative to. Defaults to the current timestamp.
* @param boolean $return_array [optional] Whether to return the relative time as an array of components rather than a string. Default value is FALSE.
* @return string Returns the amount of time between the two timestamps as a string or an array if $return_array is TRUE.
@rowanmanning
rowanmanning / foreach-references.php
Created March 29, 2011 09:08
A much cleaner way of writing PHP foreach loops
<?php
// I've been doing this
foreach ($array as $key => $value) {
$array[$key] = $modified_value;
}
// rather than this
foreach ($array as &$value) {
$value = $modified_value;
@rowanmanning
rowanmanning / class-concept.php
Created June 1, 2011 14:34
Concept for a PHP String class
<?php
//============================================================
// CONSTANTS
// direction (for strpos etc)
String::FORWARD;
String::REVERSE;
// case
String::CASE_LOWER;