Skip to content

Instantly share code, notes, and snippets.

View rwprodev's full-sized avatar

Carl Newlands rwprodev

View GitHub Profile
@rwprodev
rwprodev / gh-deploy-clone.sh
Created February 2, 2020 00:16 — forked from blvz/gh-deploy-clone.sh
Creates a deploy key and clones the repository.
#!/usr/bin/env bash
read -r -d '' usage << EOM
Usage:
gh-deploy-clone user/repo [ENVIRONMENT]
EOM
[ -z "$1" ] && echo && echo "$usage" && echo && exit 1
@rwprodev
rwprodev / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
Created February 2, 2020 00:33 — forked from gubatron/multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers. You want to perform git pull origin master for example, and you want this to happen without asking for a password.

@rwprodev
rwprodev / clear-git-history.md
Last active February 5, 2020 11:29
Steps to clear out the history of a GitHub repository
git checkout --orphan newBranch
git add -A  # Add all files and commit them
git commit
git branch -D master  # Deletes the master branch
git branch -m master  # Rename the current branch to master
git push -f origin master  # Force push master branch to github
git gc --aggressive --prune=all     # remove the old files
@rwprodev
rwprodev / upgrade_sendy.sh
Last active May 29, 2021 09:19
Script to upgrade Sendy to a new version
#!/usr/bin/sh
if [ "$#" -ne 2 ]; then
echo "Usage: $0 OLD_VERSION NEW_VERSION" >&2
exit 1
fi
export OLD=$1
export NEW=$2
@rwprodev
rwprodev / trap_focus.js
Created January 3, 2021 16:44 — forked from myogeshchavan97/trap_focus.js
Code for trapping focus inside modal
// add all the elements inside modal which you want to make focusable
const focusableElements =
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
const modal = document.querySelector('#exampleModal'); // select the modal by it's id
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
const focusableContent = modal.querySelectorAll(focusableElements);
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
@rwprodev
rwprodev / gist:ec6a212efc952742efe23d748a0b0188
Last active April 11, 2021 09:40
Total CMS - Toggle Switches to Radio Switches
document.addEventListener("DOMContentLoaded", function(event) {
$('.heroToggle .switch-input').attr('type','radio').attr('group','heroToggle')
$('input[group="heroToggle"]').on('click change', function(){
$('input[group="heroToggle"]').not(this).prop('checked', false).each(function(){
var form = $(this).closest('form.total-form'),
slug = $('input[name=slug]', form).val();
type = 'toggle';
$.ajax({
type: "POST",
url: stacks.totalcms.totalapi,
@rwprodev
rwprodev / code.gs
Created November 19, 2023 14:49
Google App Script code for importing Uber family emails from Gmail to Google Sheets.
function findUberTripDetails() {
// Replace with the desired label, Spreadsheet ID, and sheet name.
var labelName = 'Uber/Family/New'; // This label is added when Gmail receives a new email
var newLabelName = 'Uber/Family'; // This is label we will add at the end
var spreadsheetId = 'yourSpreadsheetID'; // You can get this from the Google Sheets URL
var sheetName = 'UberFamily'; // The tab/sheet name
// Open the spreadsheet and get the desired sheet.
var spreadsheet = SpreadsheetApp.openById(spreadsheetId);
var sheet = spreadsheet.getSheetByName(sheetName);