Skip to content

Instantly share code, notes, and snippets.

View danmatthews's full-sized avatar
😃
Working.

Dan Matthews danmatthews

😃
Working.
View GitHub Profile
$('#item').die('click').live('click', function() {
// The code in this block will only attach ONCE.
});
@danmatthews
danmatthews / _statustext.php
Created November 20, 2011 03:32
Helper function to convert HTTP status codes into descriptive text.
<?php
function _statustext($code = 0) {
// List of HTTP status codes.
$statuslist = array(
'100' => 'Continue',
'101' => 'Switching Protocols',
'200' => 'OK',
'201' => 'Created',
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
X-WR-CALNAME:Water Bill - £20
METHOD:PUBLISH
PRODID:-//Apple Inc.//iCal 5.0.1//EN
BEGIN:VEVENT
UID:26B03B14-B5C3-401B-8F7B-AC76E0208EC5
DTEND;VALUE=DATE:20101002
RRULE:FREQ=MONTHLY
/**
* Add order suffix to numbers ex. 1st 2nd 3rd 4th 5th
*
* @param int the number to ordinalize
* @return string the ordinalized version of $number
* @link http://snipplr.com/view/4627/a-function-to-add-a-prefix-to-numbers-ex-1st-2nd-3rd-4th-5th/
*/
public static function ordinalize($number)
{
if ( ! is_numeric($number))
@danmatthews
danmatthews / function.create_url.php
Created March 2, 2012 17:58
Smarty plugin to use Fuel's Uri::create() functionality in templates.
<?php
/* Save this file to /Fuel/app/vendor/Smarty/lib/plugins/function.create_url.php
* You can then call it like {create_url url="controller/action"} in your templates.
*/
function smarty_function_create_url($params, &$smarty)
{
$('#search-input').die('keyup').live('keyup', function() {
var SearchTermVariable = $('#search-input').val().toString().toLowerCase();
if($.trim(SearchTermVariable) == '') {
$('ul#group-contact-list li').show();
} else {
SELECT e.date_subscribed,
countries.name
FROM countries
JOIN contacts c
LEFT OUTER JOIN contacts_economic_updates_countries e
ON e.country_name = countries.name
WHERE c.contact_id='80d0624061395e3d9f108165cd163e004a2ed12e37def2995f866d82dd40b3f2'
ORDER BY countries.name
@danmatthews
danmatthews / gist:3240064
Created August 2, 2012 19:49
Solution to doing some processing for every method of FuelPHP REST controller.
<?php
class ExampleRestController extends Controller_Rest {
/**
* Make sure the router method has the same method signature as the parent::router declaration.
* @see fuel/core/classes/controller/rest.php
*/
public function router($method, array $params) {
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rss version="2.0">
<channel>
<title>UKVetsOnline Content for Byre Veterinary Surgery</title>
<link>http://www.ukvetsonline.co.uk/node/313954?&amp;m=&amp;mp=313954</link>
<description>The latest in advice &amp; care, promotions, and news from UKVetsOnline.</description>
<language>en-us</language>
<pubDate>Tue, 18 Jan 2011 02:13:01 +0000</pubDate>
<lastBuildDate>Tue, 07 Aug 2012 11:45:33 +0100</lastBuildDate>
<item>
#!/bin/sh
KEY="$HOME/.ssh/id_dsa.pub"
if [ ! -f ~/.ssh/id_dsa.pub ];then
echo "private key not found at $KEY"
echo "* please create it with "ssh-keygen -t dsa" *"
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
exit
fi