Skip to content

Instantly share code, notes, and snippets.

View chrispage1's full-sized avatar

Chris Page chrispage1

View GitHub Profile
@chrispage1
chrispage1 / Vite.php
Created July 16, 2023 17:04
Vite with WordPress
<?php
class Vite {
/**
* Flag to determine whether hot server is active.
* Calculated when Vite::initialise() is called.
*
* @var bool
*/
@chrispage1
chrispage1 / app.js
Created March 6, 2023 16:10
Simple Express File Server
const bearerToken = 'secretTokenGoesHere';
const httpPort = 80;
// load in express & express fileUpload
const express = require('express'),
fileUpload = require('express-fileupload'),
app = express();
// initialise fileUpload plugin
app.use(fileUpload());
@chrispage1
chrispage1 / policies.php
Last active January 5, 2023 10:14
Pure PHP policy management. A basic implementation replicating the functionality of Laravel's policy management
<?php
/**
* A PHP trait which allows us to re-use logic
* across classes. Note that in 'User', we are calling 'use HasPolicies;'
* This allows the User class to utilise these methods.
*/
trait HasPolicies {
/**
* Checks if the user has ALL the passed abilities
@chrispage1
chrispage1 / README.md
Last active February 15, 2023 13:22
Restoring databases using Docker

Restoring databases using Docker

This guide requires you have the original database directories handy. You may also struggle restoring InnoDB instances because of the way they work, however a guide can be found at the bottom of this gist.

Move your backup database folders to an appropriate location, a temporary folder is preferable as MariaDB will put its own data within this directory.

Within the directory, run the following docker command:

@chrispage1
chrispage1 / README.md
Last active December 7, 2020 15:50
Useful MariaDB/Maxscale actions & commands

MariaDB

Backing up MariaDB database using mariadb-backup

# backup to mariadb-bkp directory
mkdir mariadb-bkp && cd mariadb-bkp
mariadb-backup --backup --target-dir=.

# prepare a backup for restore
@chrispage1
chrispage1 / backupDatabase.sh
Created November 8, 2020 12:36
Backup database to multiple SQL files
#!/bin/bash
printf "\n\nPerforming export of all databases to remote host via SSH"
printf "\n\nMySQL username: "
read mysqlUser
printf "MySQL password: "
read -s mysqlPassword
@chrispage1
chrispage1 / sync.sh
Created October 23, 2020 08:57
Synchronise service configurations across servers
#!/bin/bash
# define our parameters
hostArray=("mariadb-90" "mariadb-91" "mariadb-92")
configPath="/etc/maxscale.cnf"
service="maxscale"
# auto variables
currentHost=$(hostname)
@chrispage1
chrispage1 / ANALYTICS.md
Last active May 31, 2022 01:00
Configuring Flutter application with Firebase

Installing Firebase Analytics

Requires the firebase_analytics package.

Android

Add packages to pubspec.yaml

  1. Under dependencies, add the Firebase Analytics package firebase_analytics: ^6.0.0
  2. Run flutter pub get to retrieve the package
@chrispage1
chrispage1 / README.md
Last active September 30, 2020 15:31
Corosync pacemaker maxscale configuration
@chrispage1
chrispage1 / deploy.php
Last active July 29, 2020 09:49
Deployer - deploy Laravel instance with local npm compile (optional) and tag validation for production deployments
<?php
namespace Deployer;
require 'recipe/laravel.php';
// deployment configuration options.
set('repository', 'git@github.com/username/repository.git');
// set('http_user', 'username'); // optionally set file user
// set('bin/php', '/usr/local/bin/ea-php74'); // optionally set PHP path