Skip to content

Instantly share code, notes, and snippets.

View MaffooBristol's full-sized avatar

Matt Fletcher MaffooBristol

  • Maffcorp Ltd
  • Bristol, England
  • 10:56 (UTC +01:00)
View GitHub Profile
@MaffooBristol
MaffooBristol / .eslintrc.yml
Last active December 11, 2021 14:11
React + Typescript + Cypress + Eslint config
plugins:
- react
- '@typescript-eslint'
- '@typescript-eslint/eslint-plugin'
- cypress
- jest
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
@MaffooBristol
MaffooBristol / .eslintrc.yml
Last active December 9, 2021 19:55
Typescript Eslint config files
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking
- plugin:jest/recommended
- airbnb-base
- airbnb-base-typescript
plugins:
- '@typescript-eslint'
@MaffooBristol
MaffooBristol / find-styled.bash
Last active March 10, 2020 09:49
Find all files named StyledFoo.js and then find how many times they're referenced in React files
# Find all files named StyledFoo.js and then find how many times they're referenced in React files
for i in $(find . -name "Styled*.js"); do j=$(basename $i | cut -d. -f1); k=$(grep -IiRn "<$j" src/ | wc -l); echo "$k $i"; done | sort -n
[{"iata":"AAA","name":"Anaa Airport"},{"iata":"AAB","name":"Arrabury Airport"},{"iata":"AAC","name":"El Arish International Airport"},{"iata":"AAE","name":"Annaba Airport"},{"iata":"AAF","name":"Apalachicola Regional Airport"},{"iata":"AAG","name":"Arapoti Airport"},{"iata":"AAH","name":"Aachen-Merzbruck Airport"},{"iata":"AAI","name":"Arraias Airport"},{"iata":"AAJ","name":"Cayana Airstrip"},{"iata":"AAK","name":"Buariki Airport"},{"iata":"AAL","name":"Aalborg Airport"},{"iata":"AAM","name":"Malamala Airport"},{"iata":"AAN","name":"Al Ain International Airport"},{"iata":"AAO","name":"Anaco Airport"},{"iata":"AAQ","name":"Anapa Airport"},{"iata":"AAR","name":"Aarhus Airport"},{"iata":"AAT","name":"Altay Air Base"},{"iata":"AAU","name":"Asau Airport"},{"iata":"AAV","name":"Allah Valley Airport"},{"iata":"AAW","name":"Abbottabad Airport"},{"iata":"AAX","name":"Araxa Airport"},{"iata":"AAY","name":"Al Ghaidah International Airport"},{"iata":"AAZ","name":"Quezaltenango Airport"},{"iata":"ABA","name":"Abakan Airpo
@MaffooBristol
MaffooBristol / blah.sh
Created November 28, 2019 13:23
Find all files, sorted by number of lines changed in Git
for i in *; do (git diff -w -U0 $i | wc -l | tr -d '[:space:]') && echo -e " $i"; done | sort -n
@MaffooBristol
MaffooBristol / halo-features.md
Last active September 15, 2018 10:10
Halo features documentation (WIP)

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

@MaffooBristol
MaffooBristol / index.js
Created November 22, 2016 19:34
Festivitron 3000
const five = require('johnny-five');
const board = new five.Board();
const opts = {
outputPin: 9,
throttleTimeout: 60,
};
let timeout = null;
@MaffooBristol
MaffooBristol / longestfile.sh
Created July 8, 2016 10:36
Find the longest code line in your drupal custom codebase
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 December 15, 2015 16:58
Example of merging commerce orders/carts with hook_commerce_cart_order_convert()
<?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 June 25, 2015 08:13
Find MP3s without a key assigned (such as would be generated by MixedInKey)
find ~/Music/ -name "*.mp3" -exec mdls -raw -name kMDItemKeySignature {} \; -exec echo " : {}" \; | grep 'null'