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 / bitbucket-pipelines.yml
Last active June 29, 2022 04:54
A small script to run as part of your bitbucket pipelines to deploy code from the Bitbucket repository into an external git repository, tested with Acquia so far. Configure SSH keys and the DEPLOY_URL variable in the BitBucket UI to make it work. Assumes a Drupal install in /docroot and node stuff in /app
image: node:7.4
# Yes, you do need this in order to be able to do onward pushes.
clone:
depth: full
pipelines:
default:
# Don't forget caches as well.
- step:
@angry-dan
angry-dan / callFunctionDependencyTree.php
Last active April 26, 2017 09:30
A function that executes a list of functions, gathering necessary dependencies as it goes.
<?php
public static function callFunctionDependencyTree($functions) {
do {
$funcDidExecute = FALSE;
$functions = array_map(function ($spec) use ($functions, &$funcDidExecute) {
if (array_key_exists('value', $spec)) {
return $spec;
@angry-dan
angry-dan / callFunctionDependencyTree.php
Created April 26, 2017 09:29
A function that executes a list of functions, gathering necessary dependencies as it goes.
<?php
public static function callFunctionDependencyTree($functions) {
do {
$funcDidExecute = FALSE;
$functions = array_map(function ($spec) use ($functions, &$funcDidExecute) {
if (array_key_exists('value', $spec)) {
return $spec;
JSON.stringify(Array.prototype.slice.call(document.querySelectorAll('.todos .content > a')).map(({innerText, href}) => ({status: (innerText.match(/\[([^\]]+)\]/) || [])[1], href, title: innerText.trim()})))
brew tap caskroom/cask
brew install git git-flow-avh bash-completion patchutils
brew cask install node virtualbox phpstorm vagrant vagrant-manager
<?php
// When updating a user role, the role export module can be a bit funny.
db_query("DELETE FROM {role} where name = 'NEW NAME' and rid != EXISTING_RID");
db_query("UPDATE {role} set name = 'NEW NAME' where rid = EXISTING_RID");
.panel-title {
.glyphicon.pull-right {
line-height: inherit;
}
.glyphicon-chevron-down {
transition: transform 0.6s ease 0s;
transform: rotateX(180deg);
}
@angry-dan
angry-dan / drupal_run_as.php
Created October 24, 2015 13:25 — forked from anonymous/drupal_run_as.php
Safely run a function in Drupal as another user.
<?php
function drupal_run_as($user, $func, $arg1) {
global $user;
$original_user = $user;
$old_state = drupal_save_session();
drupal_save_session(FALSE);
$args = func_get_args();
$user = array_shift($args);
@angry-dan
angry-dan / Configuring Jenkins.md
Last active August 29, 2015 14:27
Configuring Jenkins/CI for Drupal
  1. Create a project using the VDD site machine name

  2. Tick "discard old builds"

  3. Set strategy to "Log rotation" and keep 10 builds.

  4. Set source management to git and enter the repository URL.

  5. Checkout develop or master (develop for dev, master for stage).

  6. Set the build to be a shell command and use the following commands:

     ln -s docroot public_html
     echo "This project is managed by Jenkins" > README-jenkins
    

rsync -va --delete --exclude=sites/default/files --exclude=.git . /var/www/vhosts/[site]

@angry-dan
angry-dan / benchmark-drupal-bootstrap.php
Created April 16, 2015 10:27
Benchmark the Drupal bootstrap phases. Since this is something that happens on every page load it needs to be really fast. You should probably be worried if bootstrap is taking more than 300ms per page load.
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
$phases = array(
'CONFIGURATION' => DRUPAL_BOOTSTRAP_CONFIGURATION,
'PAGE_CACHE' => DRUPAL_BOOTSTRAP_PAGE_CACHE,
'DATABASE' => DRUPAL_BOOTSTRAP_DATABASE,