Skip to content

Instantly share code, notes, and snippets.

View chris-jamieson's full-sized avatar

Chris Jamieson chris-jamieson

View GitHub Profile
@chris-jamieson
chris-jamieson / Simple Equal Heights
Created April 28, 2013 14:45
Simple JavaScript / jQuery code to set equal heights to elements. Original snippet from Paul Irish
/* equal heights */
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
}
$(window).load(function() {
$('#elementID, .elementClass').setAllToMaxHeight();
});
@chris-jamieson
chris-jamieson / Set image title attribute as caption
Last active December 25, 2016 23:24
Simple jQuery snippet to set the title attribute of an <img> as a caption
$(document).ready(function() {
$("img").each(function () {
var $this = $(this);
var title = $this.attr("title");
$this.after('<div class="caption">'+ title +'</div>');
});
});
@chris-jamieson
chris-jamieson / Validate URL
Created April 30, 2013 10:52
Simple PHP snippet to validate a URL using preg_match
<?php
function isValidURL($url){
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
// usage
if(!isValidURL($url)){
$message = 'Please enter a valid URL';
echo $message;
@chris-jamieson
chris-jamieson / add-printer.md
Last active February 17, 2021 18:16
Install Epson AL-M1200 printer on Ubuntu

Ubuntu seems to have trouble talking to the Epson AL-M1200 printer. These instructions will get it working. Based on a set of instructions found here.

  1. Download epsoneplijs-0.4.1.tgz -file from here
  2. cd Downloads (or whatever directory you downloaded the file to)
  3. tar zxvf epsoneplijs-0.4.1.tgz
  4. cd epsoneplijs-0.4.1
  5. ./configure --prefix=/usr
  6. sudo make install
  7. Download PPD file from here or here
  8. Connect your printer to your computer and turn it on. (You can do it in the beginning, but at least now you need it connected and powered on.)
@chris-jamieson
chris-jamieson / gist:9251276
Created February 27, 2014 14:35
Record a GIF screencast with Byzanz
byzanz-record --duration=20 --delay=5 x=0 --y=0 --width=1024 --height=800 output.gif
@chris-jamieson
chris-jamieson / gist:391fac04e764d6710292
Created June 12, 2014 14:22
Drupal display errors (add to index.php)
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
@chris-jamieson
chris-jamieson / gist:f762dd9c82e00699bb43
Created June 15, 2014 21:43
Drupal commerce hide billing address fields when giftcard added to make order free
/**
* function to remove billing fields from display if giftcard / coupon makes order total £0.00
*/
$(document).ready(function(){
// on change due to ajax
$( document ).ajaxComplete(function() {
console.log( "Triggered ajaxComplete handler." );
var orderTotal = $('.page-checkout .view-id-commerce_cart_summary .field-name-commerce-order-total .component-type-commerce-price-formatted-amount .component-total').text();
if(orderTotal == '£0.00'){
console.log('Order total is zero (var: ' + orderTotal + ')');
@chris-jamieson
chris-jamieson / custom_video_helper.info
Last active August 29, 2015 14:04
Custom video helper - hide the "Upload" option for media module
name = Custom video helper
description = Provides some custom hooks that help video uploads
core = 7.x
package = Media
@chris-jamieson
chris-jamieson / gist:e10676442c9a0aae09ec
Created August 12, 2014 11:26
Disable pingbacks for Wordpress (SQL query)
UPDATE wp_posts SET ping_status='closed' WHERE post_status = 'publish' AND post_type = 'post';
UPDATE wp_posts SET ping_status='closed' WHERE post_status = 'publish' AND post_type = 'page';