This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_theme(). | |
*/ | |
function EXAMPLE_theme() { | |
$path = drupal_get_path('module', 'EXAMPLE'); | |
$hooks = array( | |
'iu_license' => array( | |
'template' => 'iu-license', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $call) { | |
watchdog('backtrace', $call['function']); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check arguments and requirements. | |
if [ ${#@} -lt 1 ]; then | |
echo "This script expects one argument (site machine name)." | |
exit 1 | |
fi | |
if [ -x ${HOME}/.my.cnf ]; then | |
echo "This script requires ${HOME}/.my.cnf." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Array of type => format. | |
$formats = array( | |
'day_monthname_year' => 'j \d\e F \d\e Y', | |
'weekday_day_monthname_year' => 'l j \d\e F \d\e Y', | |
); | |
$query_types = db_insert('date_format_type')->fields(array('type', 'title')); | |
$query_formats = db_insert('date_formats')->fields(array('format', 'type')); | |
foreach ($formats as $type => $format) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: UTF-8 -*- | |
# set the minimum disk space available to alert on (in GB). | |
minimum = 5 | |
# disk space variation (in GB) threshhold. 'delta GB have been consumed between the last two checks'. | |
delta = 1 | |
import commands | |
import pickle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Field handler to present an edit link to a cart line item. | |
*/ | |
class MODULENAME_handler_field_cart_line_item_link_edit extends commerce_cart_handler_field_cart_line_item_link_edit { | |
function render($values) { | |
$text = !empty($this->options['text']) ? $this->options['text'] : t('edit'); | |
$line_item_id = $this->get_value($values, 'line_item_id'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_commerce_order_update(). | |
*/ | |
function HOOK_commerce_order_update($order) { | |
// Detect a status change. | |
if ($order->status != $order->original->status) { | |
$status = commerce_order_status_load($order->status); | |
$state = commerce_order_state_load($status['state']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Menu callback. | |
*/ | |
function this_is_a_menu_callback() { | |
$header = array('nid' => 'ID', 'title' => 'Title'); | |
$query = db_select('node', 'n', array('fetch' => PDO::FETCH_ASSOC)) | |
->fields('n', array('nid', 'title')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$URL = 'http://example.com/login.php'; | |
$user = 'USER'; | |
$pass = 'PASS'; | |
$cookie_path = dirname(__FILE__).'/cookie.txt'; | |
/** | |
* Hace login en la web enviando un POST con el usuario y contraseña. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form_FORM_ID_alter() for node type 'test'. | |
* | |
* Hide field_texto. | |
*/ | |
function fieldautovalue_form_test_node_form_alter(&$form) { | |
$form['field_texto']['#access'] = FALSE; | |
} |