Skip to content

Instantly share code, notes, and snippets.

Matt Thomas betweenbrain

Block or report user

Report or block betweenbrain

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
@betweenbrain
betweenbrain / vue-attribute.md
Created Nov 19, 2019
Vue alter attribute(s) of elements in component
View vue-attribute.md

Using querySelectorAll

const inits = this.$el.querySelectorAll('[ga-init]');
inits.forEach(elem => {
  elem.removeAttribute('ga-init');
  elem.removeAttribute('data-ga');
});

Using $children

View wpgraphql-hooks-filters.md
add_action(
	'graphql_return_response', function( $filtered_response, $response, $schema, $operation, $query, $variables ) {

		return $filtered_response;
	}, 10, 6
);

add_action(
	'do_graphql_request', function( $query, $operation, $variables, $params ) {
@betweenbrain
betweenbrain / mac-linux-nfs.md
Last active Oct 8, 2019
Mac backup to Linux NFS via Time Machine
View mac-linux-nfs.md

Host

$ sudo apt update
$ sudo apt install nfs-kernel-server
$ sudo mkdir /mnt/nfs -p
$ sudo chown nobody:nogroup /mnt/nfs
$ sudo chmod 777 /mnt/nfs
$ sudo nano /etc/exports
  • add something like /mnt/nfs 192.168.1.101(rw,sync,no_root_check,no_subtree_check)
@betweenbrain
betweenbrain / browser-language.js
Created Aug 12, 2019
Browser language detection
View browser-language.js
// Returns first configured browser language.
const lang = navigator.language || navigator.userLanguage;
return lang.split('-').shift();
// Returns comma separated list of languages.
let lang = (navigator.languages && 0 !== navigator.languages.length
? navigator.languages
: [navigator.language || navigator.userLanguage || 'en']);
@betweenbrain
betweenbrain / vue-route-guard-apollo-query.js
Last active Jul 10, 2019
Vue Apollo query from within Vue router route guard
View vue-route-guard-apollo-query.js
router.beforeEach((to, from, next) => {
function delay(time) {
return new Promise(resolve => {
setTimeout(function() {
resolve();
}, time);
});
}
setTimeout(async function() {
@betweenbrain
betweenbrain / wp-flash.php
Last active Apr 2, 2019
WordPress Flash Messaging
View wp-flash.php
// Somewhere in your code.
set_transient( 'myflash', 'Hi mom!' );
// In a plugin.
function sample_admin_notice__success() {
$msg = get_transient( 'myflash' );
if ( $msg ) {?>
<div class="notice notice-success is-dismissible">
<p><?php echo $msg; ?></p>
</div>
@betweenbrain
betweenbrain / fieldmanager-hooks.md
Created Feb 11, 2019
WordPress Fieldmanager Hooks
View fieldmanager-hooks.md

A non-authoritative, possibly incomplete list of hooks registered by Fieldmanager for WordPress v1.0.0.

  • fieldmanager_draggablepost_li_content
  • fm_element_markup_start: After starting the field, apply a filter to allow other plugins to append functionality.
  • fm_element_markup_end: Before closing the field, apply a filter to allow other plugins to append functionality.
  • fm_element_classes
  • fm_preload_alter_values: Alter values before rendering.
  • fm_process_index_value: Alter handling of an individual index value, which may make sense to change per field type.
  • fm_presave_alter_values: Alter or respond to all the values of a particular element.
  • fieldmanager_media_preview
View vue-createElement.lighthouse.report.json
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/71.0.3559.0 Mobile Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","benchmarkIndex":1150},"lighthouseVersion":"3.2.0","fetchTime":"2019-01-14T21:40:48.244Z","requestedUrl":"http://dev-with-matt.pantheonsite.io/vue-create-element/","finalUrl":"http://dev-with-matt.pantheonsite.io/vue-create-element/","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Does not use HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your
View vue-jsx.lighthouse.report.json
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/71.0.3559.0 Mobile Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","benchmarkIndex":1322},"lighthouseVersion":"3.2.0","fetchTime":"2019-01-14T22:15:21.320Z","requestedUrl":"http://dev-with-matt.pantheonsite.io/vue-jsx/","finalUrl":"http://dev-with-matt.pantheonsite.io/vue-jsx/","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Does not use HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, a
View vue-template.lighthouse.report.json
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/71.0.3559.0 Mobile Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","benchmarkIndex":1322},"lighthouseVersion":"3.2.0","fetchTime":"2019-01-14T22:32:33.466Z","requestedUrl":"http://dev-with-matt.pantheonsite.io/vue-template/","finalUrl":"http://dev-with-matt.pantheonsite.io/vue-template/","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Does not use HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and you
You can’t perform that action at this time.