Skip to content

Instantly share code, notes, and snippets.

View MatthewDaniels's full-sized avatar

Matthew Daniels MatthewDaniels

  • Brisbane, Qld, Australia
View GitHub Profile
#!/bin/bash
aws route53 list-hosted-zones | jq -c '.HostedZones | .[]' | while read i; do
name=$(echo $i | jq -r .Name)
id=$(echo $i | jq -r .Id)
aws route53 list-resource-record-sets --hosted-zone-id "${id}" | jq -r '.ResourceRecordSets[] | [.Name, .Type, (.ResourceRecords[]? | .Value), .AliasTarget.DNSName?] | @csv' > "${name//./_}DNS_Zone.csv"
done
@MatthewDaniels
MatthewDaniels / composer-command.sh
Created September 16, 2022 23:05
Use this script to quickly and easily run composer commands without the need for it being installed on the host machine.
#!/bin/bash
# use this to run composer commands in a container (rather than on the host machine)
# to execute:
# ./composer-command.sh {{ composer commands }}
# the {{ composer commands }} above get passed to composer for execution (eg: "install")
#
# ./composer-command.sh install --dev
#
# Install Laravel (run this from a parent directory)
@MatthewDaniels
MatthewDaniels / RFC3339_PolyFill.js
Last active September 21, 2021 05:44
Polyifill the JS Date object to have a strict RFC 3339 string method
if (!Date.prototype.toRFC3339String) {
(function () {
function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
@MatthewDaniels
MatthewDaniels / get-dom-element-byattr-regex.js
Last active October 16, 2020 00:16
Gets a DOM element by attribute, matching to regular expression to allow for more complex selectors.
/**
* Get Dom Element with Regex - matches regular expression against the attribute value.
*
* @param regex Regex The regular expression to match the attribute value on
* @param selectorStr String An optional string to further refine the initial selector (used in the querySeelctorAll) - @default *
*
* @return array of objects containing the element, the attriube name and value OR null if none are matched.
*/
function getDomElementWithRegex(regex, selectorStr) {
if(!regex) return null;
@MatthewDaniels
MatthewDaniels / gcp-bulk-billing-update.sh
Last active August 19, 2022 00:39
Use this script to update the billing account on one or more GCP projects. You can either set an individual project or specify a list file.
#!/bin/bash
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo
echo
echo -e "${GREEN}╭──────────────────────────────────────────────────────────────╮${NC}"
@MatthewDaniels
MatthewDaniels / get-bq-schema.sh
Last active September 4, 2020 06:17
Google BigQuery - Get Table or View Schema & optionally output to a file
#!/bin/bash
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo
echo
echo -e "${GREEN}╭──────────────────────────────────────────────────────────────────────╮${NC}"
@MatthewDaniels
MatthewDaniels / dl-bq-schema.sh
Created October 16, 2019 10:09
Downloads a BQ Table's defined schema and places it into a JSON file. Note: Remove the "> github-commits-schema.json" to show it on screen.
#!/bin/bash
bq show --format=prettyjson bigquery-public-data:github_repos.commits | jq '.schema.fields' > github-commits-schema.json
@MatthewDaniels
MatthewDaniels / delete-all-the-tables.sh
Last active November 5, 2023 04:48
Delete all the tables within a Dataset in BigQuery using the bq command line utility.
#!/bin/bash
# VARS
PROJECT=my-project
DATASET_NAME=Datisan_TEST
# tables will have the structure day_tables_prefix_yyyyMMdd (sharded daily tables)
TABLE_PREFIX=day_tables_prefix
# make sure we are on the right project
@MatthewDaniels
MatthewDaniels / GA-Get-Dimension-list.js
Last active March 10, 2020 00:41
Iterates all of the dimensions in the edit dimensions list in Google Analytics (only accounts for users with edit rights) & outputs the list, MINUS the dimension number
// Iterates all of the dimensions in the edit dimensions list in Google Analytics (only accounts for users with edit rights) & outputs the list, MINUS the dimension number
let list = document.querySelectorAll('.ID-editDimension > a');
list.forEach((value,key) => { let r = /(?:\d+\. )?(.*)/i; let b = r.exec(value.text); if(b) console.log(b && b[1]) });
sudo apt-get -y install php7.2 php7.2-dev php7.2-mysql php-apcu php7.2-gd php7.0-mcrypt php-memcache php7.2-curl php7.2-tidy php-xml php-json php7.2-mbstring php-gettext libmcrypt-dev mcrypt php-gd libmcrypt4 libmhash2 libtidy5 libxslt1.1 php-apcu-bc php-pear php7.2-mbstring php7.2-xml php7.2-fpm php7.2 php-mongodb
# remove apache
update-rc.d -f apache2 remove
apt-get remove apache2
sudo update-rc.d -f php7.2-fpm default
sudo service php7.2-fpm restart