Skip to content

Instantly share code, notes, and snippets.

View BrianHenryIE's full-sized avatar
🇮🇪

Brian Henry BrianHenryIE

🇮🇪
View GitHub Profile
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'WP-Rocket' ) === false ) {
if ( strpos( $_SERVER['HTTP_X_ROCKET'], 'WP-Rocket' ) === false ) {
die( 'BAD_UA_XR: ' . ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) : 'not set' ) . ' & ' . ( isset( $_SERVER['HTTP_X_ROCKET'] ) ? htmlspecialchars( $_SERVER['HTTP_X_ROCKET'] ) : 'not set' ) );
}
$user_agent = $_SERVER['HTTP_X_ROCKET'];
}
@anthonyeden
anthonyeden / AWS_S3_Presign_Download.php
Last active December 5, 2023 09:48
AWS S3: Pre-sign Upload & Download Requests [PHP]
<?php
function AWS_S3_PresignDownload($AWSAccessKeyId, $AWSSecretAccessKey, $BucketName, $AWSRegion, $canonical_uri, $expires = 8400) {
// Creates a signed download link for an AWS S3 file
// Based on https://gist.github.com/kelvinmo/d78be66c4f36415a6b80
$encoded_uri = str_replace('%2F', '/', rawurlencode($canonical_uri));
// Specify the hostname for the S3 endpoint
if($AWSRegion == 'us-east-1') {
@mariodian
mariodian / HD.php
Last active June 25, 2023 17:56
Derive wallet addresses from xpub, ypub and zpub with Bit-Wasp/Bitcoin-php
<?php
require_once('vendor/autoload.php');
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address\AddressCreator;
use BitWasp\Bitcoin\Key\Deterministic\HdPrefix\GlobalPrefixConfig;
use BitWasp\Bitcoin\Key\Deterministic\HdPrefix\NetworkConfig;
use BitWasp\Bitcoin\Network\Slip132\BitcoinRegistry;
use BitWasp\Bitcoin\Key\Deterministic\Slip132\Slip132;
@dduan
dduan / XCTest+Eventually.swift
Last active January 11, 2023 00:26
A simple "eventually" method to aide asynchronous testing with XCTest
import XCTest
extension XCTestCase {
/// Simple helper for asynchronous testing.
/// Usage in XCTestCase method:
/// func testSomething() {
/// doAsyncThings()
/// eventually {
/// /* XCTAssert goes here... */
@Mte90
Mte90 / php-error-in-wp.php
Last active April 14, 2020 06:09
PHP error in WordPress backend wrapped as native notice. Refer/screenshot on https://core.trac.wordpress.org/ticket/35155
<?php
/*
Plugin Name: Error For WP backend
Plugin URI: https://github.com/Mte90/
Description: Wrap the PHP errors in the WP admin backend with the native notice
Author: Mte90
Version: 1.0.0
*/