Skip to content

Instantly share code, notes, and snippets.

View angry-dan's full-sized avatar

Dan James angry-dan

  • Kent, United Kingdom
View GitHub Profile
@angry-dan
angry-dan / Redmine_Hours.user.js
Last active December 15, 2015 17:50
Sum of hours in a Redmine task list
// ==UserScript==
// @name Redmine Hour Counter
// @namespace http://projects.deeson.info
// @description Adds up selected hours.
// @include https://projects.deeson.info/*
// @grant none
// ==/UserScript==
/**
* Adds the count icon at the top of the page.
@angry-dan
angry-dan / Drupal_disable_CKEditor_by_default.user.js
Created May 10, 2013 08:27
Disable CKEditor by default on Drupal sites.
// ==UserScript==
// @name Drupal disable CKEditor in Drupal by default
// @namespace https://github.com/dan-sprog
// @description Disable CKEditor by default
// @version 1
// ==/UserScript==
(function(){
if(typeof Drupal !== 'undefined' && typeof CKEDITOR !== 'undefined' && Drupal.behaviors.ckeditor && CKEDITOR.env.isCompatible) {
@angry-dan
angry-dan / element_insert.php
Last active December 25, 2015 16:28
A couple of (hopefully) useful API functions that would have sat well in Drupal 7. Use them to insert an element into an array with string keys (where array_slice won't do)E.g:$element = array('dog' => 'bruce', 'elephant' => 'nelly', 'lion' => 'paws');element_insert_after($element, array('cat' => 'pussy'), 'dog') would give:array('dog' => 'bruce…
<?php
/**
* Insert an element into an associative array after a specified key.
*
* @see _element_insert()
*/
function element_insert_after(&$element, $insert, $key) {
_element_insert(TRUE, $element, $insert, $key);
}
@angry-dan
angry-dan / jquery.scope.js
Created November 13, 2013 19:31
Rescope your jQuery function, for neatness. See http://jsfiddle.net/66dGe/
$.fn.scope = function() {
var scope = this;
return function(selector) {
return $(selector, scope)
}
}
@angry-dan
angry-dan / clear-apc-caches.php
Created November 25, 2013 11:48
Allow Drupal's user 1 to clear the APC cache.
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
if ($user->uid == 1) {
if (function_exists('apc_clear_cache')) {
apc_clear_cache('opcode');
// ==UserScript==
// @name JIRA natural times
// @namespace http://angrydan.example.com
// @description Allows entering times with a colon
// @include https://deeson.atlassian.net/*
// @version 1
// @grant none
// ==/UserScript==
jQuery(function(){
<?php
/**
* Helper for creating new beans.
*
* @see https://gist.github.com/dan-sprog/ae7a7da430288607685f
*/
function my_module_blocks_install_bean($info, $overwrite = FALSE, $needs_revert = FALSE) {
if ($overwrite) {
$bean = bean_load_delta($info['delta']);
@angry-dan
angry-dan / disable-view.php
Created July 17, 2014 15:47
Add to an install/update hook to turn off a view.
<?php
$view = views_get_view('VIEW_NAME');
if (!empty($view)) {
ctools_include('export');
ctools_export_crud_set_status('views_view', $view, TRUE);
}
// ==UserScript==
// @name Disable overlay
// @namespace http://angrydan.example.com
// @description Disable the Drupal overlay
// @include *
// @version 1
// @grant none
// ==/UserScript==
// Drupal.ajaxError was introduced in D7. D6 won't have it.
# Use: red for live, yellow
# Red
PS1='\[\033[0;31m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
# Yellow
PS1='\[\033[0;33m\]\u@\h\[\033[0;34m\] \w \$\[\033[00m\] '
# Green
PS1='\[\033[0;32m\]\u@\h\[\033[0;34m\] \w \$\[\033[00m\] '