Skip to content

Instantly share code, notes, and snippets.

View colinjoy's full-sized avatar

Colin Joy colinjoy

View GitHub Profile
@colinjoy
colinjoy / q_example.js
Created April 11, 2016 06:35 — forked from jeffcogswell/q_example.js
Here's another chaining example on using q.js. This doesn't have any error handling, as I just want to demonstrate the chaining concept. Please read the comments carefully, as I start out with a non-q example, to show the order of flow. Please post comments if there's anything that isn't clear and I'll try to revise it as needed.
// Q sample by Jeff Cogswell
/*===========
We want to call these three functions in sequence, one after the other:
First we want to call one, which initiates an ajax call. Once that
ajax call is complete, we want to call two. Once two's ajax call is
complete, we want to call three.
BUT, we don't want to just call our three functions in sequence, as this quick
@colinjoy
colinjoy / bugzilla_bodyclasses.pl
Created August 26, 2015 07:01
Add some contextual classes to the <body> tag of bugzilla using hook template_before_process
sub template_before_process {
my ($self, $args) = @_;
my ($file, $vars) = @$args{qw(file vars)};
if($file eq 'global/header.html.tmpl') {
$vars->{bodyclasses} = [] unless ref($vars->{bodyclasses});
my $caller = $vars->{component}->{caller};
my @classes;
$caller =~ s/\.html\.tmpl//; # strip file extension
@colinjoy
colinjoy / gist:f07cd272bd19a260e085
Created November 9, 2014 15:53
drupal string placeholders
@variable: Escaped to HTML using check_plain(). Use this as the default choice for anything displayed on a page on the site.
%variable: Escaped to HTML and formatted using drupal_placeholder(), which makes it display as <em>emphasized</em> text.
!variable: Inserted as is, with no sanitization or formatting. Only use this for text that has already been prepared for HTML display (for example, user-supplied text that has already been run through check_plain() previously, or is expected to contain some limited HTML tags and has already been run through filter_xss() previously).
@colinjoy
colinjoy / gist:873ac0c9e729d7968a9c
Last active August 29, 2015 14:04
A list of Drupal Core access arguments (version 7.30)

Drupal Core access arguments

Block

  • Administer blocks: "administer blocks"

Comment

  • Administer comments and comment settings: "administer comments"
  • View comments: "access comments"
  • Post comments: "post comments"
  • Skip comment approval: "skip comment approval"
@colinjoy
colinjoy / drupal commerce submit button
Created November 11, 2013 21:57
Style/Iconfont Friendly Submit Buttons for Drupal Commerce
// add css classes to the form submit element
function HOOK_form_alter(&$form, &$form_state, $form_id) {
if (commerce_form_callback($form_id, $form_state)) { // is this a commerce form?
if(in_array('commerce-add-to-cart', $form['#attributes']['class'])) { // target a specific button, here: "add to cart"
// add classes
$form['submit']['#attributes'] = array(
'class' => array('add-to-cart', 'icon-basket-alt') // a class for easy selection in css, then the icon font class
@colinjoy
colinjoy / gist:6827633
Created October 4, 2013 15:15
Query to look up the size of MySQL databases
SELECT table_schema AS "Databases",
sum( data_length + index_length ) / 1024 / 1024 AS "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema;
@colinjoy
colinjoy / gist:6692782
Created September 24, 2013 23:28
Recursively delete Dropbox conflicted files [by @tjluoma]
find . -name \*\'s\ conflicted\ copy\ \* -exec mv -v {} ~/.Trash/ \;