Skip to content

Instantly share code, notes, and snippets.

View fredbradley's full-sized avatar

Fred Bradley fredbradley

View GitHub Profile
@fredbradley
fredbradley / README.md
Last active August 11, 2017 09:34
I'd like a bit of help refactoring a couple of bash scripts

Backup Script

What is this?

These two files are what I use to create regular backups on our websites. They create a sql dump of the database, and then a tarball of the directory structure.

Specific Help required

This is all fine, but I want to find a way that a message will be sent to slack if one of the other commands (or the whole script) fails. EG - tar failed because filesystem run out of space; or mysqldump failed because wrong password? or simply 'couldn't find folder!?, etc!

@fredbradley
fredbradley / cors-policy-oddities.md
Last active June 26, 2017 14:12
Can you help? I have a CDN which hosts some CSS files that references some

There are seemingly two ways to allow Cross Origin domains...

OPTION ONE

My preferred way of doing it, because it locks access down to only the specified domains that I allow.

  1. Set Origin Environment
SetEnvIf Origin "http(s)?://(www\.)?(([a-z0-9-]+).domain1.org|([a-z0-9-]+).domain2.org|test.devserver.org)$" AccessControlAllowOrigin=$0
  1. Use that Environment variable to add the header dynamicially
@fredbradley
fredbradley / .htaccess
Last active November 3, 2016 14:58
I'm really hoping someone with more htaccess knowledge than me can help me out!
######
# Ok I'm hoping someone might be able to help. Here's the final require scenario
# 1. If someone tries to visit either www.domain1.org/ar or www.domain2.org/ar it should take them to www.domain3.org/specificpage
# 2. But only if they're from two certain IP ranges (our internal IP ranges).
# 3. It might only be if it's like 'www.domain1.org/ar'... if the user requests something further like 'www.domain1.org/archie-is-cool' it needs to go that that page.
# Background
# It's on a Wordpress Multisite install hence why there's more than one domain that could be request to the same doc_root
# I'm putting this above the Wordpress htaccess stuff, so that it picks it up before trying to compute Wordpress redirects.
<center>
<a target="_blank" href="https://www.cranprep.org/photos?utm_source=iSAMS&utm_campaign=October_Email&utm_medium=iSAMS&utm_content=button_click" style="color:#0c223f;background-color:#ffc627;border-color:#f3b300;padding:5px 10px;font-size:1.2em;line-height:1.5;border-radius: 3px;display: inline-block;text-align: center; border-width: 1px;border-style: solid;text-decoration:none;vertical-align: middle;">Visit: cranprep.org/photos</a>
</center>
@fredbradley
fredbradley / SRAMail
Created November 22, 2013 21:27
Proposed New SRA Mailing Design
<div class="no-format" id="header">
<div class="text-center">
<p>BLAH BLAH BLAH</p>
</div>
</div>
<div class="container" id="emailWrapper">
<div class="row" id="header">
<div class="col-md-5">
SRA LOGO
</div>
@fredbradley
fredbradley / Need some help with Wordpress Custom Tax Query and Group Taxomonies
Created October 6, 2013 14:09
I need to create a page that shows all the posts that are tagged with "video". It's not working like I expect. It's only showing the normal blog posts - not the other custom post types that are also tagged with 'video'. Below is the code that I've got. For reference the function get_bonn_post_types is an array of all the post types on my install…
<?php
/*
Hello!
This has been bugging me for the best part of a day now, so I'm appealing to help in order to calm my nerves.
I run a site that has many custom post types. Every post type shares the use of the post_tag taxonomy.
I need to create a page that shows all the posts that are tagged with "video". It's not working like I expect. It's only showing the normal blog posts - not the other custom post types that are also tagged with 'video'.
@fredbradley
fredbradley / nextPlayFunction.php
Created April 11, 2013 17:31
Can anyone spot any errors with the code below? I need it to display an output that matches with this document from the client (see screenshot here: https://twitter.com/fredbradley/status/322399388146216961/photo/1 )
<?php
/*
* FOR THE PHP GEEKS!
------------------
Can anyone spot any errors with the code below?
I need it to display an output that matches with this document from the client (see screenshot here: https://twitter.com/fredbradley/status/322399388146216961/photo/1 )
// Database Connection Stuff
define('DB_HOST', 'localhost');
define('DB_USER', 'user');
define('DB_PASSWORD', 'password');
define('DB_NAME', 'databasename');
// Global Definitions that are needed for both entry and judging system
define('GROUP_INCLUDES_PATH', '/var/www/html/webvid-awards/group-includes/');
define('PATH_TO_JUDGING', '/var/www/html/judging/');
define('PATH_TO_ENTRIES', '/var/www/html/entries-dev/');
if ($_POST['email']) {
$email = $_POST['email'];
$message = "Hello this is a test! It worked!";
mail($email, 'My Subject', $message);
echo 'Mail Should Now Be Sent!';
}
<input type="hidden" name="instId" value="213881">
<input type='hidden' name='accId1' value='CATCH'>
<input type="hidden" name="cartId" value="1430823944"><!-- This is a unique identifier It's actually a UNIX Timestamp! -->
<input type="hidden" name="award_id" value="21" />
<input type="hidden" name="invoice_amount_inc_tax" value="342" />
<input type="hidden" name="invoice_amount_ex_tax" value="285" />
<input type="hidden" name="MC_entries[]" value="e87z0xvf" />
<input type="hidden" name="amount" value="342" />
<input type="hidden" name="currency" value="GBP"><!-- Choose appropriate currency that you would like to use -->
<input type="hidden" name="desc" value="Entry/Entries for The PR Week Awards 2015" />