Skip to content

Instantly share code, notes, and snippets.

View rattfieldnz's full-sized avatar

Rob Attfield rattfieldnz

View GitHub Profile
// Wait for the DOM to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
// Initialize Lucide icons
if (typeof lucide !== 'undefined') {
lucide.createIcons();
}
// State management
let currentTheme = localStorage.getItem('theme') || 'light';
var Rc = e => {
throw TypeError(e)
};
var xl = (e, t, n) => t.has(e) || Rc("Cannot " + n);
var N = (e, t, n) => (xl(e, t, "read from private field"), n ? n.call(e) : t.get(e)),
Z = (e, t, n) => t.has(e) ? Rc("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n),
B = (e, t, n, r) => (xl(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n),
Pe = (e, t, n) => (xl(e, t, "access private method"), n);
var Si = (e, t, n, r) => ({
set _(o) {

Keybase proof

I hereby claim:

  • I am rattfieldnz on github.
  • I am robattfield (https://keybase.io/robattfield) on keybase.
  • I have a public key ASBz9Mhe7tnsydOJphvktGhNe8Y-JYirpP0nfzqiy690Lgo

To claim this, I am signing this object:

########################## Add Chia Nodes ##########################
# This script adds a list of Chia nodes to the currently installed #
# Chia client on your Windows 10 system. #
# #
# See more info on Chia at https://chia.net. #
# #
# You can download the latest Windows version of Chia from #
# https://github.com/Chia-Network/chia-blockchain/releases. #
# #
# You are using this script at your own risk. I am unable to #
@rattfieldnz
rattfieldnz / run_phpunit
Created October 17, 2019 09:21
Script to run PHPUnit tests in a Laravel-based project, with keys not stored in phpunit.xml.
#!/bin/bash
clear;
if [ -z "$1" ] && [ -z "${GOOGLE_API_KEY}" ]; then
echo 'Please provide a Google API key.'
exit
fi
if [ -z "$2" ] && [ -z "${CODECOV_TOKEN}" ]; then
@rattfieldnz
rattfieldnz / config.yml
Last active November 2, 2019 06:24
Sample CircleCI config of my latest Laravel project, stored in a private BitBucket repository.
version: 2
jobs:
build:
docker:
- image: circleci/php:7.3-fpm
parallelism: 4
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_HOST: 127.0.0.1
steps:
@rattfieldnz
rattfieldnz / mysql.sh
Last active October 16, 2019 05:05 — forked from mahemoff/mysql.sh
circleci mysql upgrade
#!/bin/bash
set -x
set -e
export DEBIAN_FRONTEND=noninteractive
sudo apt-get --purge autoremove -y mysql-server-5.6
sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8C718D3B5072E1F5
@rattfieldnz
rattfieldnz / GoogleApiException.php
Last active August 26, 2017 09:58
Return a Google_Service_Exception as a collection (good for API usage with Laravel framework)
/**
* Return a Google_Service_Exception as a collection (good for API usage with Laravel framework).
*
* This example is used in a Laravel (v 5.4.34) app with spatie/analytics package.
*
* @param \Google_Service_Exception $e
*
* @see https://github.com/spatie/laravel-analytics
* @see https://github.com/google/google-api-php-client/blob/master/src/Google/Service/Exception.php
* @see https://developers.google.com/analytics/devguides/reporting/core/v3/errors
@rattfieldnz
rattfieldnz / Http.php
Created August 6, 2017 10:49
A class containing a function which checks if a URL can be shown in iframes. Revisions, suggestions, and optimization tips are very welcome!
<?php
/**
* Class Http
*
* A class to manage HTTP-related functionality.
*
* @author Rob Attfield <[email protected]> <http://www.robertattfield.com>
*
* @package App\Helpers\Functions
@rattfieldnz
rattfieldnz / cspheader.php
Created August 6, 2017 10:07 — forked from phpdave/cspheader.php
CSP Header for PHP or Apache or .htaccess - Content Security Protocol
<?
//CSP only works in modern browsers Chrome 25+, Firefox 23+, Safari 7+
$headerCSP = "Content-Security-Policy:".
"connect-src 'self' ;". // XMLHttpRequest (AJAX request), WebSocket or EventSource.
"default-src 'self';". // Default policy for loading html elements
"frame-ancestors 'self' ;". //allow parent framing - this one blocks click jacking and ui redress
"frame-src 'none';". // vaid sources for frames
"media-src 'self' *.example.com;". // vaid sources for media (audio and video html tags src)
"object-src 'none'; ". // valid object embed and applet tags src
"report-uri https://example.com/violationReportForCSP.php;". //A URL that will get raw json data in post that lets you know what was violated and blocked