Skip to content

Instantly share code, notes, and snippets.

View tobyontour's full-sized avatar

Toby Bettridge tobyontour

View GitHub Profile
@tobyontour
tobyontour / gist:e6f6928d3f12b57b03a40d9042f434d9
Created May 29, 2025 13:53
Get the SQL from a Drupal query with parameters embedded
function logDrupalDatabaseQuery($query) {
// Log the query string.
$tmp = $query->__toString();
// Reverse array to avoid a placeholder ending in .._1 replacing placeholders ending in .._1n
foreach (array_reverse($query->getArguments()) as $key => $value) {
if (is_string($value)) {
$value = '"' . $value . '"';
}
$tmp = str_replace($key, $value, $tmp);
set-option -g prefix C-a
bind-key C-a last-window
set -s escape-time 0
bind H resize-pane -L 10
bind J resize-pane -D 10
bind K resize-pane -U 10
bind L resize-pane -R 10
bind | split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
setw -g mode-keys vi
@tobyontour
tobyontour / index.php
Created August 9, 2020 12:51
Drupal index.php to spit out route name.
<?php
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
*/
@tobyontour
tobyontour / ht.router
Created November 6, 2019 16:06
Router for Drupal 7
<?php
/**
* @file
* Router script for the built-in PHP web server.
*
* The built-in web server should only be used for development and testing as it
* has a number of limitations that makes running Drupal on it highly insecure
* and somewhat limited.
*
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PROMPT_DIRTRIM=1
export PS1="\[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
#!/bin/bash
branch=`git branch |egrep "^\*" |tr -d '* '`
msg=`git log |head -n 5 |tail -n 1`
echo "`date` $branch $msg" >>~/gitlog.txt
#!/bin/bash
if [ $3 -eq 1 ]; then
branch=`git branch |egrep "^\*" |tr -d '* '`
echo "`date` -> $branch" >>~/gitlog.txt
fi
@tobyontour
tobyontour / bs.html
Created December 27, 2015 23:23
Show which Bootstrap breakpoint is active.
<div class="visible-xs">XS</div>
<div class="visible-sm">SM</div>
<div class="visible-md">MD</div>
<div class="visible-lg">LG</div>
@tobyontour
tobyontour / lessloop.sh
Created December 27, 2015 20:14
Update a css file from a less file in a loop
#!/bin/bash
if [ ! -f "$1" -o ! -f "$2" ]
then
echo "Run with $0 src.less dest.css"
exit 1
fi
if [ ${1: -5} != ".less" -o ${2: -4} != ".css" ]
then
@tobyontour
tobyontour / template.php
Created December 17, 2015 16:03
Add a special template for an individual page of a multipage webform
function THEME_preprocess_webform_form(&$vars) {
/*
Add a special template for an individual page of a webform.
e.g. for the first page of a webform with a node id of 12: webform-form-12-0.tpl.php
*/
$vars['theme_hook_suggestions'][] = $vars['theme_hook_suggestion'];
$vars['theme_hook_suggestions'][] = 'webform_form_' . $vars['nid'] . '_' . $vars['form']['progressbar']['#page_num'];
// The theme_hook_suggestion would override all suggestions so unset it.
unset($vars['theme_hook_suggestion']);
}