Skip to content

Instantly share code, notes, and snippets.

View nicksantamaria's full-sized avatar

Nick Santamaria nicksantamaria

View GitHub Profile
@nicksantamaria
nicksantamaria / mydumper-install-ubuntu14.04.sh
Created December 29, 2015 23:40
Install mydumper / myloader from source on Ubuntu 14.04
# Switch to root user.
sudo su -
# Update apt repositories and install dependencies.
apt-get update
apt-get install libglib2.0-dev libmysqlclient15-dev zlib1g-dev libpcre3-dev libssl-dev cmake
# Download mydumper source and move to appropriate directory.
cd /usr/local/share
wget https://launchpad.net/mydumper/0.9/0.9.1/+download/mydumper-0.9.1.tar.gz
@nicksantamaria
nicksantamaria / example.module
Created October 28, 2014 04:28
Stupid panels content categories getting you down?
<?php
/**
* @file
*
* Replaces all of the panels content categories with a single "All" tab.
*
* To enable, simply do the following:
* - Search & replace "example" with your module name.
* - Run `drush vset example_panels_all_category 1`
@nicksantamaria
nicksantamaria / gist:3952025
Created October 25, 2012 11:07
Disabling checkout submit form when ajax request in progress
/**
* Disable the continue buttons in the checkout process once they are clicked
* and provide a notification to the user.
*/
Drupal.behaviors.aibmCommerceCheckout = {
attach: function (context, settings) {
...
var creditCardSelection = $('#edit-commerce-payment-payment-details-credit-card-type', context);
if (creditCardSelection.length) {
@nicksantamaria
nicksantamaria / gist:3949612
Created October 24, 2012 23:34
redis config
<?php
// Redis configuration
$redis_path = 'profiles/aibm_profile/modules/contrib/redis';
$conf['cache_backends'][] = $redis_path .'/redis.autoload.inc';
$conf['redis_client_interface'] = 'PhpRedis';
$conf['cache_prefix'] = array(
'default' => 'pantheon-redis',
);
$conf['cache_default_class'] = 'Redis_Cache';
@nicksantamaria
nicksantamaria / gist:2785770
Created May 25, 2012 04:29
Updating 4 field machine names in Drupal 7
<?php
function er_migration_update_7003() {
// Changing the names of the porfolio field prefixes from modelp to portfolio
$fields = array(
'field_modelp_title' => array(
'data_col_suffix' => array(
'value' => 'LONGTEXT',
'format' => 'VARCHAR(255) DEFAULT NULL',
),
),
@nicksantamaria
nicksantamaria / gist:1530610
Created December 29, 2011 00:11
Screwing around with 'An illegal choice has been detected. Please contact the site administrator.' error messages in Drupal
<?php
/**
* Validation handler for blah_node_form
*/
function wpf_ui_blah_node_form_validate(&$form, &$form_state) {
$errors = form_set_error();
// This ensures that empty select responses are dealt with correctly
$error_text = 'An illegal choice has been detected. Please contact the site administrator.';
@nicksantamaria
nicksantamaria / render.php
Created September 20, 2011 05:04
Function to render custom panel panes.
<?php
/**
* Render a Ctools custom content pane.
*
* Mostly useful for when you need to render custom content panes
* outside of panels.
*
* @param $id
* Custom content pane machine name.
* @return
function melba_uc_init() {
...
if ($_GET['q'] == 'cart' && !empty($_POST)) {
// This is a continuation of a monstrosity born in
// sites/all/themes/melba/tempalates/views-view-table--cart-page.tpl.php
$cart_id = uc_cart_get_id(FALSE);
if (!empty($_POST['delete'])) {
// delete items from cart
foreach (array_keys(array_filter($_POST['delete'])) as $nid) {
melba_uc_cart_item_remove($nid);
<?php
function artroom_cron_send_mail($items){
if(empty($items))
return;
$link = url("user/login", array("absolute" => true));
@nicksantamaria
nicksantamaria / gist:1013816
Created June 8, 2011 05:06
Psuedo-code for getting the parent page's title when using urls as hierarchy
<?php
// Get the requested URL alias and explode into array
$q = trim($_SERVER['REQUEST_URI'], '/');
$arg = explode('/', $q);
// Shorten the URL by 1 argument
$newArg = array_slice($arg, 0, (count($arg) - 1));
// Get the menu item for the new URL