Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Matt Thomas betweenbrain

💭
I may be slow to respond.
View GitHub Profile
@betweenbrain
betweenbrain / unity-mac.md
Last active Dec 24, 2020
Unity 3D on Mac
View unity-mac.md

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 Aug 4, 2020
WP GraphQL register interface and to types
View wp-graphql.php
<?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 Aug 4, 2020
WordPress error reporting
View error-reporting.php
<?php
/*
Plugin Name: PHP - Strict Error Reporting
Description: Enable strict error reporting for testing PHP.
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
View git-recipes.md

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

View geolocation-test.html
<!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 Feb 15, 2020
WordPress load template part based on request (pseudo code)
View load.php
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 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 Aug 14, 2022
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']);