Skip to content

Instantly share code, notes, and snippets.

View paulhhowells's full-sized avatar

Paul H Howells paulhhowells

  • Shepperton, U.K.
View GitHub Profile
@paulhhowells
paulhhowells / tinymce-drupal.css
Last active December 10, 2015 12:38
Tinymce css for drupal tinymce wysiwyg profile. (Uses base64 encoded images, so replace with urls that point to image files if your intended user's browsers are old enough to not support base64). Utilises edeverett’s idea of illustrating to rich text editor users the markup they are creating or editing.
/*
* wysiwyg tinymce css for use in Drupal 7
* with the addition of styles based on a great idea by edeverett http://edeverett.co.uk/
* and diagnostic css from Eric Meyer http://meyerweb.com/eric/tools/css/diagnostics/
*
* requires a modern browser (more recent than IE7 anyway ;-) for the base64 encoded images
*
*/
p,
@paulhhowells
paulhhowells / Per node background colour. Drupal 7.
Last active December 12, 2015 03:48
Set a (whole) page’s background colour on a per node basis. A Drupal 7 theme function that adds a class to the body tag.
/*
* Implements template_preprocess_html
*
* requires:
* the content type to have a List[text] field called 'field_bg_colour'
* using Display Suite the field may be Hidden but not Disabled
*/
function THEMENAME_preprocess_html(&$variables) {
// if a background colour has been set within the node,
@paulhhowells
paulhhowells / Theme Bean Block & Display Suite Combo.php
Last active April 6, 2017 20:36
Enable bean blocks to be themed (using a .tpl file) according to bean-type: i.e. block__bean__BEAN-TYPE.tpl
Enable bean blocks to be themed (using a .tpl file) according to bean-type:
i.e. block__bean__BEAN-TYPE.tpl
Why? Combine a Bean Block with Display Suite and the innards of the block will match the DS layout
used, however the outer wrapping of the block must be themed separately. However if you write a
.tpl that matches the block it will take precedence and the DS layout will be lost. This prevents
using a DS layout for each type of Bean while simultaneously having full control over the Bean
Block’s mark-up.
This solution adds a theme hook suggestion so that .tpl files may be written for each type of Bean.
@paulhhowells
paulhhowells / Render Tabs D7.php
Last active December 12, 2015 05:38
Render Tabs — don’t print them if you don’t need ’em. Drupal 7.
add to template.php:
/*
* Implements template_preprocess_page
*/
function THEMENAME_preprocess_page(&$variables, $hook) {
// create $render_tabs & $show_render_tabs for page.tpl
$render_tabs = render($variables['tabs']);
$variables['render_tabs'] = $render_tabs;
@paulhhowells
paulhhowells / array_numbered_key_elements.drupal.php
Created April 16, 2013 14:49
array_numbered_key_elements() Many Drupal 7 arrays mix numeric and associate keys, and you often need to separate the numerically keyed children from the associatively keyed arrays. This function returns an array containing only the numbered keys ready to be iterated through.
/*
* returns: an array containing only the numbered keys
*
* notes: array_intersect_key() is faster than array_intersect()
*/
function array_numbered_key_elements($array) {
return array_intersect_key($array, element_children($array));
}
@paulhhowells
paulhhowells / metamorphosis pattern .js
Last active December 16, 2015 12:39
Douglas Crockford’s Module pattern, but it starts (and finishes) as an object rather than a function. A publicly accessible object metamorphoses into an object with public methods and variables, and private methods and variables.
metamorphosis = {
defaults : {
thing : 4
},
init : function (options) {
var
the = this,
o, // private object
p; // public object
<?php
/**
* @file
* Default theme implementation to display the basic html structure of a single
* Drupal page.
*
* Variables:
* - $css: An array of CSS files for the current page.
* - $language: (object) The language the site is being displayed in.
@shiffman
shiffman / ProcessingLive.md
Last active December 20, 2015 13:38
Signup for "Processing Live" test broadcast.

Last week I tested broadcasting live from my office and answering questions about Processing via google hangout. You can watch an archive of the broadcast. There are also beginner and advanced video lessons that I'm making with this system.

While I haven't sorted out the exact technology I'll use, I'm planning on making this a regular weekly live broadcast starting this fall. To be ready, I'd like to do one more test next Wednesday, August 7th at 3 PM EST (7 PM UTC).

I'd like to get four programming questions (1 hour show, 15 minutes each) signed up in advance. I'll then invite you to the hangout around 2:45 and we'll begin broadcasting at 3. If you'd like to participate, please write a question below with a link to any additional info (sketches, videos, git repos, etc.) I'm not sure exactly what I'm looking for, but I'm hoping to learn about what works best through

What is dgeni?

dgeni is a documentation generator developed by the Angular team. Ironically it lacks documentation right now, so we try to develop a very simple step-by-step-guide here, until a better documentation is available. Please share and fork this Gist.

dgeni is currently used in these project

Why should I use dgeni?

@yanniboi
yanniboi / d8_reset.sh
Created October 3, 2014 14:18
Reinstall a clean drupal 8 site
#!/bin/sh
# Removes an existing Drupal 8 install, then install again.
# Requires Drush 7 - https://github.com/drush-ops/drush
#
# Run this script from the docroot of a Drupal 8 checkout.
# Installs to mysql://localhost/drupal, user 1 user/pass is admin/admin.
if [ ! -e ./core/core.services.yml ]
then