Skip to content

Instantly share code, notes, and snippets.

View paullinney's full-sized avatar

Paul Linney paullinney

View GitHub Profile
@paullinney
paullinney / redirect.vcl
Created June 15, 2014 02:53
Varnish redirect based on cookie
vcl_recv {
if (!req.http.cookie ~ "site_intro" && !req.url ~ "^/intro" && !req.http.user-agent ~ "(?i)\biPhone.*Mobile.MobileDetect") {
error 750 "Moved Temporarily";
}
...
}
vcl_error {
<?php
$args = array( 'post_type' => 'MYPOSTTYPE', 'posts_per_page' => 1 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
include 'single-MYPOSTTYPE.php';
endwhile;
?>
/**
* Add a node, using a panel node template override, into Search index
* - search_api
* - search_api_solr
*/
/**
* Implements hook_entity_property_info_alter().
*/
function MY_SEARCH_entity_property_info_alter(&$info) {
@paullinney
paullinney / gist:24b8c27d17c188d620e2
Created October 23, 2014 10:44
Drush Alias Ignore Tables
'source-command-specific' => array (
'sql-sync' => array (
'no-cache' => TRUE,
'structure-tables-key' => 'common',
),
),
'command-specific' => array (
'sql-sync' => array (
'structure-tables' => array(
'common' => array('cache', 'cache_block', 'cache_content', 'cache_filter', 'cache_form', 'cache_menu', 'cache_page', 'cache_rules', 'cache_update', 'cache_views', 'cache_views_data', 'ctools_css_cache', 'ctools_object_cache', 'search_dataset', 'search_index', 'search_node_links', 'search_total', 'accesslog', 'history', 'watchdog')
drush @source sql-dump --database=remote_one_legacy --skip-tables-list=cache,cache_path,cache_form | drush @target sql-cli --database=remote_two_legacy
@paullinney
paullinney / mymodule.insall.php
Last active September 4, 2015 08:36
change text field length when data is present
/*
* Utility to change the max length of a text field
* @see http://nathan.rambeck.org/blog/42-modify-drupal-7-text-field-maximum-length
*
* @param string the field name to update
* @param integer the new field length
*/
function mymodul_change_text_field_max_length($field_name, $new_length) {
$field_table = 'field_data_' . $field_name;
$field_revision_table = 'field_revision_' . $field_name;
@paullinney
paullinney / gist:fb638dbb84149cbe0a0e
Created December 15, 2015 12:19 — forked from fabriceleal/gist:7803969
Decent enough macro for exporting csvs from Excel.
' http://support.microsoft.com/kb/291296/en-us
' http://superuser.com/questions/130592/how-do-you-force-excel-to-quote-all-columns-of-a-csv-file
' - change integer to long indexing
' http://stackoverflow.com/questions/2524703/save-text-file-utf-8-encoded-with-vba
' - output utf8 content
Sub QuoteCommaExport()
' Dimension all variables.
Dim DestFile As String
Dim FileNum As Integer
function __the_end(){
if(($err=error_get_last()))
die('<pre>'.print_r($err,true).'</pre>');
}
register_shutdown_function('__the_end');
/*
* Facets Widgets
**/
function HOOK_facetapi_facet_info() {
$facets = array();
$facets['ss_company_facet'] = array(
'field' => 'ss_company',
'label' => t('Company'),
ps -e -orss=,args= | sort -b -k1,1n