Skip to content

Instantly share code, notes, and snippets.

View only-cliches's full-sized avatar

Scott Lott only-cliches

View GitHub Profile
@only-cliches
only-cliches / cookie-banner-style.js
Last active August 14, 2024 01:28
UserCentrics Web CMP v2 custom styling
@only-cliches
only-cliches / backup_script.sh
Last active June 6, 2024 02:41
MacOS Automated Time Machine Reconnect
#!/bin/bash
# Place this file in /usr/local/sbin/backup-script.sh
# Add passwords with:
# security add-generic-password -s "password_label" -a "username" -w "your_password_here"
SAMBA_PASS=$(security find-generic-password -s "samba_pass" -a "username" -w)
BACKUP_PASS=$(security find-generic-password -s "backup_pass" -a "username" -w)
# Configuration
@only-cliches
only-cliches / class-acf-field-date_time_picker_v2.php
Last active February 16, 2023 10:50
Advanced Custom Fields Date/Time Picker V2
<?php
/*
!!!!! README !!!!
v1.3, released 2/15/23
Tested with ACF 5.12.3 and ACF Pro 5.12.3
Screenshot: https://i.imgur.com/IJlvzVp.png
How is this different from the default in date/time picker?
@only-cliches
only-cliches / alpine-setup.sh
Last active June 22, 2021 18:13
Alpine Linux Setup Script
#!/bin/ash
# This script takes a bare Alpine install and installs/configures all the apps required by my use case.
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo "Update"
@only-cliches
only-cliches / hubspot_email.php
Last active February 6, 2024 14:47
Hubspot Import Marketing Emails
// Parse an HTML from hubspot and get a clean HTML representation.
function get_email_html($email) {
$html = "";
// The email HTML comes in via an array of widgets
$widgets = array();
foreach($email->widgets as $widget) {
$widgets[] = $widget;
}
// The wdigets must be sorted to get the content in order
@only-cliches
only-cliches / uuidv4.rs
Last active March 2, 2020 06:00
UUID v4 in Rust
use rand::Rng;
fn calc_uuid() -> String {
let mut result: String = "".to_owned();
let mut rng = rand::thread_rng();
for x in 0..16 {
let rand_value = if x == 6 {
@only-cliches
only-cliches / default-blocks.php
Last active March 2, 2020 20:48
WP Grid Builder Add Meta Filter
// frontend -> templates -> blocks -> default-blocks.php
/**
* Retrieve the post meta-data key value
*
* @since 1.0.0
*
* @param string $key Meta-data key.
*/
function wpgb_get_metadata( $key = '' ) {
@only-cliches
only-cliches / print-backup-times.js
Last active December 3, 2019 23:44
Tower of Hanoi Backup
// given a number of intervals and number of backup slots, console log out each backup slots age for every interval
const printBackupIntervals = (intervals, backupSlots) => {
let points = {};
const pad = String(Math.pow(2, backupSlots - 1)).split("").map(c => "0").join("");
for (let i = 1; i < intervals; i++) {
Object.keys(points).forEach(k => points[k]++);
const k = tower(i, backupSlots).charCodeAt(0);
points[k] = 1;
console.log("Day " + i + ": " + Object.keys(points).map(p => {
@only-cliches
only-cliches / pixibackground.js
Last active March 14, 2024 12:07
PixiJS Background Cover & Background Container
/*
* PixiJS Background Cover/Contain Script
* Returns object
* . {
* container: PixiJS Container
* . doResize: Resize callback
* }
* ARGS:
* bgSize: Object with x and y representing the width and height of background. Example: {x:1280,y:720}
* inputSprite: Pixi Sprite containing a loaded image or other asset. Make sure you preload assets into this sprite.