Skip to content

Instantly share code, notes, and snippets.

View xtfer's full-sized avatar

Christopher Skene xtfer

View GitHub Profile
@xtfer
xtfer / gist:5432342
Created April 22, 2013 03:52
Fix for PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.type' in 'field list': SELECT base.fid AS fid, base.uid
$spec = array(
'description' => 'The type of this file.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
// If the FILE_TYPE_NONE constant ever changes, then change the value here
// too, and add an update function to deal with existing records. The
// constant isn't used here, because there may be cases where this function
// runs without the module file loaded.
'default' => 'undefined',
@xtfer
xtfer / gist:6127781
Last active January 30, 2019 22:19
Sanitize a Drupal 7 database adapted from http://drupalscout.com/knowledge-base/creating-sanitized-drupal-database-backup This sets all passwords to "password". I run this using Sequel Pro, which will continue to run when errors occur, as it treats each line as a separate transaction.
UPDATE users SET mail = CONCAT(name, '@localhost'), init = CONCAT(name, '@localhost'), pass = '$S$Cd059Vsxc8berFeg6hspaa7ejx2bSxyUisvCbT4h9o8XIgSUtPKz';
UPDATE comment SET mail = CONCAT(name, '@localhost');
UPDATE authmap SET authname = CONCAT(aid, '@localhost');
UPDATE webform_submitted_data set data='scrubbed';
TRUNCATE accesslog;
TRUNCATE cache;
TRUNCATE cache_block;
TRUNCATE cache_bootstrap;
@xtfer
xtfer / gist:6289172
Last active December 21, 2015 09:59
Place at the end of your config.rb file, to move generated CSS files into new locations. Based on http://css-tricks.com/compass-compiling-and-wordpress-themes/
require 'fileutils'
on_stylesheet_saved do |file|
if File.exists?(file) && File.basename(file) == "nsw_styles.css"
puts "Moving: #{file}"
FileUtils.mv(file, File.dirname(file) + "/../agov_nsw/css/styles.css")
end
end
<?php
/**
* Trim all odd characters.
*
* Character Decimal Use
* "\0" 0 Null Character
* "\t" 9 Tab
* "\n" 10 New line
* "\x0B" 11 Vertical Tab
* "\r" 13 New Line in Mac
@xtfer
xtfer / gist:49ff89ae3be666dcfd05
Last active July 20, 2016 02:42
Ghost:PageController example
<?php
/**
* @file
* Contains an example PageController.
*/
namespace Drupal\ghost_examples\Page;
use Drupal\ghost\Page\PageController;
use Drupal\ghost\Page\PageControllerInterface;
@xtfer
xtfer / gist:789fd7c6f4ccc265e1eb
Last active July 20, 2016 02:46
Ghost: Page Controller hook_menu example
<?php
/**
* @file
* Page Controller example for Ghost
*
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Chris Skene chris at previousnext dot com dot au
* @copyright Copyright(c) 2014 Previous Next Pty Ltd
*/
@xtfer
xtfer / gist:2063d158deafce34cc06
Created August 5, 2014 03:11
Ghost: FormController example
<?php
/**
* @file
* Contains a FormExample
*
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Chris Skene chris at previousnext dot com dot au
* @copyright Copyright(c) 2014 Previous Next Pty Ltd
*/
@xtfer
xtfer / gist:f2a152be9aa8bcd8b163
Created August 5, 2014 03:12
Ghost: Calling Form Controllers
<?php
/**
* How to call a form within a function.
*/
function ghost_examples_form_controller() {
$form = drupal_get_form('ghost_form', 'Drupal\ghost_examples\Form\ExampleForm');
$output = drupal_render($form);
return $output;
@xtfer
xtfer / gist:83444a9ed503a4feb826
Created August 5, 2014 03:21
Ghost: Block Plugin example
<?php
/**
* @file
* Contains a BlockPluginExample
*
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Chris Skene chris at previousnext dot com dot au
* @copyright Copyright(c) 2014 Previous Next Pty Ltd
*/
<?php
/**
* @file
* Examples for the Ghost Logger.
*
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Chris Skene chris at previousnext dot com dot au
* @copyright Copyright(c) 2014 Previous Next Pty Ltd
*/