Skip to content

Instantly share code, notes, and snippets.

View beveradb's full-sized avatar

Andrew Beveridge ☄️ beveradb

View GitHub Profile
@beveradb
beveradb / midicobackup.sh
Created February 7, 2024 02:59
MidiCo Settings and Preferences Backup Script
#!/bin/bash
# Base directories for backup and application settings
backupDir=~/MidiCoSettingsBackup
libraryDir=~/Library
# Application-specific paths relative to ~/Library
paths=(
"Caches/com.ggs.midico"
"Containers/com.ggs.midico"
@beveradb
beveradb / twilio-catfacts.js
Created May 20, 2023 03:47
Cat facts SMS text number Twilio function, for random fun stickers around Austin!
const request = require('request');
const responsePrefix = "Here's your random cat fact! - ";
const responseSuffix = " - For more cat facts, text again! To learn more, or if you're interested in learning to code, text Andrew on 803-636-3267."
const catFacts = [
"Cats have been domesticated for over 4,000 years.",
"The average lifespan of a cat is around 15 years.",
"Cats use their whiskers to determine if they can fit through a space.",
"A group of cats is called a clowder.",
"Cats have five toes on their front paws and four on their back paws.",
@beveradb
beveradb / remove_emojis.py
Last active May 6, 2023 18:56
Remove emojis from all filenames in current directory
#!/usr/bin/env python3
# One-liner install to /usr/local/bin/remove_emojis
# sudo curl -L https://gist.githubusercontent.com/beveradb/421e1653c056ee5b6770f7d1f05aa760/raw/remove_emojis.py -o /usr/local/bin/remove_emojis && sudo chmod +x /usr/local/bin/remove_emojis
import os
import re
import sys
def remove_emojis(filename):
@beveradb
beveradb / reverse-proxied-iframe-example-for-s8.html
Created April 7, 2022 19:15
reverse-proxied-iframe-example-for-s8.html
<iframe src="/showcase/" id="showcaseiframe"></iframe>
<script>
// Resize iframe to fit contents on load so there's no inner scrollbar
var frame = document.getElementById("showcaseiframe");
frame.onload = function() {
frame.style.height = frame.contentWindow.document.body.scrollHeight + 'px';
frame.style.width = frame.contentWindow.document.body.scrollWidth+'px';
}
</script>
@beveradb
beveradb / direct-load-HTML-example-for-s8.html
Created April 7, 2022 19:13
direct-load-HTML-example-for-s8.html
<div id="embed-showcase"></div>
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>
<script type="text/javascript">
// On page load, fetch HTML from /showcase proxied path and load into div above
jQuery(function() {
jQuery('#embed-showcase')
.load("/showcase/");
});
</script>
@beveradb
beveradb / testing-nginx-reverse-proxy-to-showcase-for-s8.conf
Created April 7, 2022 19:12
Nginx reverse proxy to third party website with rewritten content and working booking process (with limitations) - demo for s8
# Set up the s8.beveradb.com subdomain by default as a reverse proxy to andrew's website with rewrite rule for links, assets etc.
location / {
proxy_ssl_server_name on;
proxy_pass https://andrewbeveridge.co.uk/;
sub_filter_types *;
sub_filter_once off;
sub_filter 'andrewbeveridge.co.uk' 's8.beveradb.com';
}
@beveradb
beveradb / gitsearch.sh
Created March 28, 2022 21:53
Grep the git history for a batch of repos in bulk, to see if a string has ever been referenced in any of the repos
#!/bin/bash
# Usage: gitsearch.sh stringToSearchFor *
#
# If you have a lot of repos to search, you might want to run this in a tmux session and pipe the results into a logfile with tee, e.g.
#
# cd folderWithLotsOfReposInIt
# gitsearch.sh stringToSearchFor * | tee /tmp/gitsearch-stringToSearchFor.log
#
@beveradb
beveradb / bimtwin-local-dev-workflow.md
Created March 2, 2021 06:58
BIM Twin (custom fork of Snipe IT) dev / staging workflow

3 codebases to clone:

On all, switch to the bimtwin-mvp branch where relevant changes are being made.

Local dev:

function printModifiedValue(something){
console.log(something);
something = "world";
console.log(something);
}
function doLogicalThing(inputThing){
console.log(inputThing);
@beveradb
beveradb / selenium_curl_demo.sh
Created September 27, 2019 16:54
Demonstrate controlling Selenium directly via HTTP requests made with curl to a Selenium Grid Hub
# Set hostname and port of Selenium Grid Hub:
GRID_HOST="localhost"
GRID_PORT=4444
# Create new session, by specifying capabilities (in this case, just Chrome) to get a connection to a browser on a selenium node
# Store this session ID in a variable so we can use it for the other commands
SESSION_ID=`curl -X POST http://$GRID_HOST:$GRID_PORT/wd/hub/session -d '{"desiredCapabilities":{"browserName":"chrome"}}'| grep '"sessionId"' | sed 's/.*sessionId": "\(.*\)".*/\1/g'`
# Tell the browser to load the URL for LMGTFY
curl -X POST http://$GRID_HOST:$GRID_PORT/wd/hub/session/$SESSION_ID/url -d '{"url":"https://lmgtfy.com"}'