Skip to content

Instantly share code, notes, and snippets.

View rattfieldnz's full-sized avatar

Rob Attfield rattfieldnz

View GitHub Profile
########################## 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:
@wanmigs
wanmigs / Testcase.php
Last active October 18, 2023 10:42
Create, Update, Delete and Fetch TestCase
<?php
namespace Tests;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
@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 <emailme@robertattfield.com> <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
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 23, 2024 06:15
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@veb
veb / fizzbuzz2.php
Created June 29, 2015 03:38
fizzbuzz2.php
<?php
/*
* Task:
* Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".
* For numbers which are multiples of both three and five print "FizzBuzz".
*
* Instructions:
* This file (fizzbuzz.php) can be uploaded to a webserver that's running PHP4+ and executed with "php fizzbuzz.php" from the command line.
* Alternatively, this file can be accessed directly (if webserver permissions allow) via your browser.