Skip to content

Instantly share code, notes, and snippets.

@robballou
robballou / gist:2703698
Created May 15, 2012 17:53
Custom Module basic block hooks
<?php
/**
* Implements hook_block_info
*/
function custom_module_block_info() {
$blocks['custom_module_my_block'] = array(
'info' => t('My block'),
'cache' => DRUPAL_CACHE_PER_PAGE,
);
@robballou
robballou / gist:2704120
Created May 15, 2012 18:48
Custom Module block code
<?php
// hook_block_info
/**
* Our block specific code
*/
function custom_module_block_view($delta = '') {
if ($delta == ''){
// current node
@robballou
robballou / myip.sh
Created May 25, 2012 20:42
What is my IP?
#!/bin/bash
IP=`curl -s http://whatismyip.org/`
echo $IP
<?php
function my_module_form($form, &$form_state) {
$form['sample_field'] = array(
'#type' => 'checkboxes'
'#title' => 'Sample',
'#options' => array('test' => 'Test')
);
$form['select_box'] = array(
@robballou
robballou / move_feature.sh
Created June 7, 2012 17:35
Move a feature tar file into the drupal directory
#!/bin/bash
#
# Move the feature tar file contents into your site and remove it
#
# Usage:
# move_feature.sh [feature file] [drupal directory]
#
#
@robballou
robballou / workTime.py
Created June 20, 2012 21:47
Calculate the hours from the start of the work day
#!/usr/bin/env python
"""
workTime.py
Coded by: Rob Ballou ([email protected])
Calculates the number of hours that have passed
in a work day (starting at 8:30).
The start time can be changed by passing the hour and min
@robballou
robballou / gist:3189989
Created July 27, 2012 19:23
Re-attaching Drupal behaviors to an element
// remove the ajax-processed class from the element so that
// attachBehaviors() will update the element
$('#my-element-id').removeClass('ajax-processed');
// now re-attach the behaviors to this element
Drupal.attachBehaviors($('#my-element-id'));
<div class="container">
<div class="section-header"><h3>Header</h3></div>
<div class="section-item">...</div>
<div class="section-item">...</div>
<div class="section-item">...</div>
<div class="section-header"><h3>Header</h3></div>
<div class="section-item">...</div>
<div class="section-item">...</div>
(function($){
$(document).ready(function(){
$('.section-header').each(function(){
var $this = $(this);
// use .add() and .nextUntil() to get both the .section-header
// and .section-item elements into a single set for our .wrapAll() call
$this.add($this.nextUntil('.section-header', '.section-item'))
.wrapAll('<div class="section-container"></div>');
(function($){
$(document).ready(function(){ });
})(jQuery);