Skip to content

Instantly share code, notes, and snippets.

@mattbloomfield
mattbloomfield / push_files.sh
Created April 2, 2021 14:43
Custom `push` command to sync your local files to a remote env.
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Custom `pull` command to sync your local files with a remote env.
## Usage: fin sync_files
@mattbloomfield
mattbloomfield / logs.sh
Created April 2, 2021 14:42
Tails the logs output by CraftCMS
#!/usr/bin/env bash
## Tails the logs output by CraftCMS
## Usage: fin logs
# Forces whole job to error on failure
set -e
fin exec "tail -f storage/logs/*"
@mattbloomfield
mattbloomfield / init.sh
Created April 2, 2021 14:40
Removes any previous containers this project may have created, then starts and executes npm install/composer install
#!/bin/sh
BLUE=\\x1B[34m
YELLOW=\\x1B[33m
GREEN=\\x1B[32m
RED=\\x1B[31m
RESET=\\x1b[0m
## Removes any previous containers this project may have created, then starts and executes npm install/composer install
## Usage: fin init
@mattbloomfield
mattbloomfield / db_dump.sh
Created April 2, 2021 14:39
Saves the local DB to a file. If not supplied with a path, stored in /tmp/ with current timestamp
#!/bin/bash
## Saves the local DB to a file. If not supplied with a path, stored in /tmp/ with current timestamp
## Usage: fin db_dump [path]
# Forces whole job to error on failure
set -e
TRANSACTION_ID=$(date +"%Y-%m-%d_%H-%M-%S")
SAVE_PATH=$1
@mattbloomfield
mattbloomfield / craftcms_db_backup.sh
Created April 2, 2021 12:24
A shell script for automating backups from CraftCMS to Amazon S3
#!/bin/sh
set -e
SITE_ALIAS="arbitrary_name" # in case of multiple
# The amazon S3 bucket to save the backups to (must already exist)
S3BUCKET="my-craftcms-backups"
# Optionally specify bucket region
S3BUCKETREGION="us-east-1"
@mattbloomfield
mattbloomfield / trigger_cypress_testing.js
Last active March 26, 2021 13:58
Platform.sh Activity Script - Hook on Code Push event to trigger Github Action with Github Source Branch
/**
* This activity script gets
* the URL of the new environment from PSH,
* then requests the originating branch from the Github API (Github is largely unaware of PR branches it seems)
* then triggers a Github Action to build a linux container that runs cypress tests against the PR environment
*/
const ghUser = 'github user that owns the repo'; // found in the url e.g. github.com/ghUser/ghRepo
const ghRepo = 'repo name';
@mattbloomfield
mattbloomfield / cypress.yml
Created March 26, 2021 12:40
Github Action to Trigger Cypress Test in its own environment using inputs from remote source
# .github/workflows/cypress.yml
name: Manually Triggered Cypress Tests with installation job
on:
workflow_dispatch:
inputs:
baseUrl:
description: 'Testing Domain'
required: true
@mattbloomfield
mattbloomfield / Save_Small_Biz_Zip_Checker.html
Last active April 15, 2020 22:57
A dropin widget for checking eligible zip codes
<style>
#WhoQualifies {
width: 250px;
padding: 8px;
border: 3px solid rgb(36, 59, 52);
background: #fff;
}
#ZipCode {
font-family: Mate;
font-variant: inherit;
Qualtrics.SurveyEngine.addOnReady(function() {
"use strict";
// user configurable options
var goal = 100; // how many characters are you shooting for?
var encouragements = [
"More is always better",
"Nice!",
"Keep it up",
@mattbloomfield
mattbloomfield / qualtrics_modern_theme_text_entry.js
Last active February 21, 2020 16:44
A JavaScript to fix the annoying text box behavior on Qualtrics' Modern theme
Qualtrics.SurveyEngine.addOnReady(function () {
var questionId = this.questionId;
var placeholderText = 'Please type reason here...';
jQuery('#' + questionId + ' .TextEntryBox').each(function () {
var $textEntryBox = jQuery(this);
// set placeholder text and hide textboxes
$textEntryBox.attr('placeholder', placeholderText);
hideTextBox($textEntryBox);