Skip to content

Instantly share code, notes, and snippets.

View betweenbrain's full-sized avatar
🎯
Focusing

Matt Thomas betweenbrain

🎯
Focusing
View GitHub Profile
@betweenbrain
betweenbrain / unity-mac.md
Last active December 24, 2020 13:44
Unity 3D on Mac

OmniSharp.MSBuild.ProjectManager Attempted to update project that is not loaded:

From https://stackoverflow.com/a/63603883/901680

  1. Go to settings. (Preferences -> Settings on Mac)
  2. Search "omnisharp".
  3. Find the section "Omnisharp: Use Global Mono".
  4. Set it to "always".
  5. Reload the window.
@betweenbrain
betweenbrain / wp-graphql.php
Created August 4, 2020 22:00
WP GraphQL register interface and to types
<?php
/**
* From https://wp-graphql.slack.com/archives/C3NM1M291/p1592854006371300?thread_ts=1592852289.366600&cid=C3NM1M291
*/
add_action( 'graphql_register_types', function() {
register_graphql_interface_type( 'MyNewInterface', [
'fields' => [
'myNewField' => [
'type' => 'String',
@betweenbrain
betweenbrain / error-reporting.php
Created August 4, 2020 21:22
WordPress error reporting
<?php
/*
Plugin Name: PHP - Strict Error Reporting
Description: Enable strict error reporting for testing PHP.
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
@betweenbrain
betweenbrain / git-recipes.md
Last active May 4, 2020 20:42
GIT Recipes

List only SHA1 of commits in current branch.
$ git log --format=format:%H --walk-reflogs {branch name}

<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
@betweenbrain
betweenbrain / load.php
Created February 15, 2020 00:39
WordPress load template part based on request (pseudo code)
global $wp;
$current_url = add_query_arg( array(), $wp->request );
// echo '<pre>' . print_r($wp->request, true) . '</pre>';
// Add logic here:
$load = locate_template( 'archive-activity.php', true );
if ( $load ) {
// just exit if template was found and loaded
exit();
@betweenbrain
betweenbrain / vue-attribute.md
Created November 19, 2019 21:53
Vue alter attribute(s) of elements in component

Using querySelectorAll

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

Using $children

@betweenbrain
betweenbrain / wpgraphql-hooks-filters.md
Created October 29, 2019 18:52
WPGraphQL Hooks and Filters
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 November 19, 2024 05:53
Mac backup to Linux NFS via Time Machine

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 August 12, 2019 15:20
Browser language detection
// 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']);