Skip to content

Instantly share code, notes, and snippets.

Matt Fletcher MaffooBristol

  • Maffcorp Ltd
  • Bristol, England
Block or report user

Report or block MaffooBristol

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MaffooBristol
MaffooBristol / halo-features.md
Last active Sep 15, 2018
Halo features documentation (WIP)
View halo-features.md

Features

By Maff 14/09/2018

Features is a method of synchronising Drupal site settings and structure (eg, content types, views, etc) between different instances, such as the live site, dev site and your local copies.

By generating a feature, you select a portion of the site's settings that exist in the database and copy them to code. This is similar to if you were to programatically generate a content type and put it into a module. The features module will take an existing content type generated through the front-end GUI and replicate it using code. This is also similar to what would happen if you choose "export" from views, as well as many other modules that have similar functionality to this. However, this doesn't apply to generated content such as nodes, users, taxonomy terms, menu links, etc. Certain contrib modules can allow you to do this, for example if your content has a UUID (which means it can be versioned), but it tends to be an anti-pattern. Normally this stuff would be generated manual

View index.js
const five = require('johnny-five');
const board = new five.Board();
const opts = {
outputPin: 9,
throttleTimeout: 60,
};
let timeout = null;
@MaffooBristol
MaffooBristol / longestfile.sh
Created Jul 8, 2016
Find the longest code line in your drupal custom codebase
View longestfile.sh
find sites/all/modules/custom/ -type f -iregex ".*\.\(module\|inc\|php\|install\|info\)" -exec wc -L {} \; | sort -t " " -k1 -g
@MaffooBristol
MaffooBristol / hook_commerce_cart_order_convert_test.php
Last active Dec 15, 2015
Example of merging commerce orders/carts with hook_commerce_cart_order_convert()
View hook_commerce_cart_order_convert_test.php
<?php
// Thanks to http://jasonrichardsmith.org/blog/drupal-commerce-merge-anonymous-carts-when-logging
// for the code on which this is based!
function yourmodule_commerce_cart_order_convert($anon_cart, $account) {
$user_cart = commerce_cart_order_load($account->uid);
if (!$user_cart) {
@MaffooBristol
MaffooBristol / keys.sh
Created Jun 25, 2015
Find MP3s without a key assigned (such as would be generated by MixedInKey)
View keys.sh
find ~/Music/ -name "*.mp3" -exec mdls -raw -name kMDItemKeySignature {} \; -exec echo " : {}" \; | grep 'null'
@MaffooBristol
MaffooBristol / craycray.css
Created May 27, 2014
Cray Cray! The most wacky, crazy, super-mad CSS class... possibly ever?
View craycray.css
body.craycray {
animation: spinright 100s infinite linear;
}
body.craycray > * {
animation: spinleft 100s infinite linear;
}
body.craycray > * > * {
animation: spinright 100s infinite linear;
}
body.craycray > * > * > * {
View jsbin.modot.coffee
# Encapsulate our stuff within an app variable.
app = {}
# Define our model- this will mostly just define default values.
app.model = Backbone.Model.extend
defaults:
coords: {}
sys: {}
weather: {}
# etc
@MaffooBristol
MaffooBristol / index.html
Last active Aug 29, 2015
Backbone/Marionette problem
View index.html
<html>
<head>
<script type="text/javascript" src="bower_components/underscore/underscore.js"></script>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script type='text/javascript' src="bower_components/backbone/backbone.js"></script>
<script type='text/javascript' src='bower_components/marionette/lib/backbone.marionette.min.js'></script>
</head>
<body>
<div id='wrapper'>
View russian-number-quiz.coffee
@nums =
0: "ноль"
1: "один"
2: "два"
3: "три"
4: "четыре"
5: "пять"
6: "шест"
7: "сём"
8: "восем"
@MaffooBristol
MaffooBristol / linked_people.php
Last active Aug 29, 2015
Pseudo-code for MVC linked people logic
View linked_people.php
<?php
function get_people() {
// Do something...
return $all_the_people;
}
function remove_array_values($arr1, $arr2) {
foreach ($arr1 as $key => $item) {
if (in_array($item, $arr2)) {
You can’t perform that action at this time.