Skip to content

Instantly share code, notes, and snippets.

View bangpound's full-sized avatar

Benjamin Doherty bangpound

View GitHub Profile
<?php
/**
* Implement hook_form_FORMID_alter().
*/
function MODULE_form_blog_node_form_alter(&$form, &$form_state) {
// Change label of save button.
$form['buttons']['submit']['#value'] = t('Post');
@bangpound
bangpound / README.md
Created January 17, 2012 14:48 — forked from anonymous/README.md
Timed sopa/pipa strike blackout: Same as the sopablackout.org script, but only if today's 2012-18-1

The sopastrike.com script rocks, but you have to get up early on Wednesday and add it to all your sites, so what kind of strike is it if you have to work hard on that day? :)

Just add

<script type="text/javascript" src="//pastebin.com/raw.php?i=bip80DLx"></script>

somewhere between your <head> and </head>, and sleep late on Wednesday.

If you're using wordpress, do that at

@bangpound
bangpound / gist:1506800
Created December 21, 2011 17:09
Make Drupal 7 aggregation efficient again and use Google CDN for jQuery and jQuery UI
<?php
/**
* Implements hook_library().
*/
function MYMODULE_library() {
// jQuery UI from Google.
$libraries['ui'] = array(
'title' => 'jQuery UI: All',
'website' => 'http://jqueryui.com',
@bangpound
bangpound / roadmap.html
Created November 29, 2011 06:24
Roadmap to Dispossession
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href="main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#march li {
@bangpound
bangpound / gist:1390085
Created November 23, 2011 22:15
override media filter to show full file entities not just file field
<?php
/**
* Implement hook_filter_info_alter().
*/
function whatsit_filter_info_alter(&$info) {
$info['media_filter']['process callback'] = 'whatsit_media_filter';
}
@bangpound
bangpound / social_media_share.module.php
Created April 14, 2011 21:55
exposes share links using social media APIs.
<?php
function XXX_node_view($node, $view_mode, $langcode) {
if ($view_mode == 'full' && in_array($node->type, array('blog', 'release', 'report', 'review', 'story'))) {
// http://dev.twitter.com/pages/tweet_button
$links['twitter'] = array(
'title' => t('Tweet'),
'href' => 'http://twitter.com/share',
'attributes' => array(
<?php
/**
*
*/
class tsccivicrm_handler_field_primary_phone extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
<?php
abstract class MigrateFieldHandler extends MigrateHandler {
// abstract function arguments(...)
abstract public function prepare(stdClass $entity, array $field_info, array $instance, array $values);
/**
* Determine the language of the field
*
* @param $entity
@bangpound
bangpound / gist:817801
Created February 9, 2011 03:00
add manage field and display contextual links to nodes.
<?php
/**
* Implement hook_menu_alter().
*/
function bangpound_menu_alter(&$items) {
if (module_exists('field_ui')) {
$items['admin/structure/types/manage/%node_type/fields']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
$items['admin/structure/types/manage/%node_type/display']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
}
@bangpound
bangpound / _bidi-grid.scss
Created January 21, 2011 00:56
Bidirectional Susy grid mixins.
// use with https://github.com/bangpound/compass-susy-plugin/blob/feature%2Frtl/sass/susy/_grid.scss
// html element must have a dir attribute to indicate reading direction.
// e.g. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ar" lang="ar" dir="rtl">
@mixin bidi-columns($n, $context: false) {
[dir="ltr"] & {
@include columns($n, $context, left);
}
[dir="rtl"] & {