Skip to content

Instantly share code, notes, and snippets.

View joshuapowell's full-sized avatar
🧬
Synchronisation and Assimilation

Joshua Powell joshuapowell

🧬
Synchronisation and Assimilation
View GitHub Profile
@joshuapowell
joshuapowell / PHP IS_NUMBER
Created April 12, 2011 02:01
Check if a value is a number, if it is print it out and keep going, other wise return FALSE
<?php
/**
* Check if a value is a number, if it is print it out and keep going, other wise return FALSE
*
* @param (string) $number
* @return (mixed) boolean/$number
*/
function is_number($number) {
@joshuapowell
joshuapowell / Drupal Display Array
Created April 12, 2011 02:04
Display an array in a readable format, preserving the whitespace, formatting as code, and displaying inside of a Message box.
<?php
/**
* Display an array in a readable format, preserving the whitespace,
* formatting as code, and displaying inside of a Message box. This can
* be placed inside of any function within a Drupal module or theme.
* This is primarily used during troubleshooting and should never be
* used on a production website.
*
* @param $array
@joshuapowell
joshuapowell / HTML5 Stub
Created April 12, 2011 04:53
A generic & empty HTML5 page structure.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="robots" content="index, follow" />
<!--[if lt IE9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="description" content="" />
<title></title>
<!-- Flash player dependant upon WP Audio Player by Martin Laine -->
@joshuapowell
joshuapowell / gist:1345339
Created November 7, 2011 15:55
Convert a string (e.g., News &amp; Events) to a usable CSS selector (e.g., id="news-events", class="news-events").
<?php
/**
* Convert a string (e.g., News &amp; Events) into a usable
* CSS selector (e.g., id="news-events", class="news-events").
*
* @param $text
* @return $text
*/
function check_selector($text) {
@joshuapowell
joshuapowell / MYMODULE.info
Created November 25, 2011 23:08
Drupal 7 & Views 3 capable dynamically loading views
name = "MY MODULE"
description = "Custom Views specific to a website"
package = "MY WEBSITE"
core = 7.x
dependencies[] = views
@joshuapowell
joshuapowell / gist:1478159
Created December 14, 2011 19:49
JustinTV JSON Caching
<?php
/**
* Class SM
*
* Define a generic wrapper class with some system
* wide functionality. In this case we'll give it
* the ability to fetch a social media feed from
* another server for parsing and possibly caching.
*
@joshuapowell
joshuapowell / hooks.inc
Created January 26, 2012 02:10
Drupal: Update the meta elements in the <head> of the template that are generated dynamically. In this case we are setting the charset according to HTML5 standards and removing the generator meta tag, RSS meta tag, the default FAVICON, and the default sho
<?php
/**
* Implementation of hook_html_head_alter().
*/
function THEMENAME_html_head_alter(&$head_elements) {
// Update the charset to use HTML5 format
$head_elements['system_meta_content_type'] = array(
'#type' => 'html_tag',
@joshuapowell
joshuapowell / theme.inc
Created January 26, 2012 02:11
Drupal: Wrap all menu elements with an HTML <nav> tag
<?php
/**
* Implementation of theme_menu_tree().
*/
function MYTHEME_menu_tree(&$variables) {
return '<nav><ul class="menu">' . $variables['tree'] . '</ul></nav>';
}