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 / mac-linux-nfs.md
Last active April 13, 2024 14:36
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 / lower-case-first-letter-regex.md
Created July 7, 2016 20:56
Lowercase first letter of word regex

Find ([A-Z])([a-zA-Z]*) replace \L$1$2

@betweenbrain
betweenbrain / custom-joomla-custom-field.md
Last active March 11, 2023 03:26
Developing a custom Joomla custom field plugin

Anatomy of a custom form field

fields
  |
  -- fieldName.php
language
  |
  -- en-GB
    |
 -- en-GB.plg_fields_fieldName.ini
@betweenbrain
betweenbrain / gist:5405671
Created April 17, 2013 16:26
Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed
<?php
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://blogs.guggenheim.org/map/feed/',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
@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 / wp-flash.php
Last active July 17, 2022 18:16
WordPress Flash Messaging
<?php
/**
* Triggers validation when a post is saved.
*/
add_action(
'save_post',
'validate_post',
10,
3
@betweenbrain
betweenbrain / gist:2645141
Created May 9, 2012 14:59
Get category ID of Joomla article
JModel::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel');
$model = JModel::getInstance('Article', 'ContentModel');
$article=$model->getItem();
foreach($article as $key => $value) {
if ($key = 'catid') {
echo "catid $value";
}
break;
}
@betweenbrain
betweenbrain / gist:6440817
Created September 4, 2013 18:25
PHP usort anonymous function alphabetize
usort($this->item->tags, function ($a, $b) {
return strcmp(strtolower($a->name), strtolower($b->name));
});
@betweenbrain
betweenbrain / read-files.js
Created December 5, 2016 22:35
Node.js read multiple files, write into one
var fs = require('fs');
var Promise = require('promise');
var promises = [];
var readline = require('readline');
var readFile = function (file) {
return new Promise(function (resolve, reject) {
var lines = [];
var rl = readline.createInterface({
input: fs.createReadStream('./logs/' + file)
@betweenbrain
betweenbrain / gist:4731411
Created February 7, 2013 14:54
git archive only changes made between two commits
git archive --output=<file> HEAD $(git diff --name-only commit1SHA commit2SHA)