Skip to content

Instantly share code, notes, and snippets.

View callaginn's full-sized avatar
😎
Coding

Stephen Ginn callaginn

😎
Coding
View GitHub Profile
@callaginn
callaginn / less-scss-migration.md
Created August 7, 2023 18:33
Less to SCSS Migration

Migrate CR Border Radius

Find: @include\s*(cr-border-radius)\(([^;]+)\);
Replace: $1: $2;

@callaginn
callaginn / dreamweaver-twig-migration.md
Created August 7, 2023 18:30
Dreamweaver to Twig Migration

1. Replace ssi include with twig include:

Find: <!--#include virtual="\/includes\/(.+).ssi" -->
Replace: {% include '$1.twig' %}

Modification of that, which supports file includes as well:

Find: <!--#include (?:virtual|file)="(.+).ssi" -->
Replace: {% include '$1.twig' %}

You can always go back later and replace the following with a blank string:

Find: (?&lt;={% include ')\/?includes\/

@callaginn
callaginn / dreamhost.js
Last active November 5, 2021 05:36
Fetch and Download Dreamhost Domain Info
/*/
Fetch Dreamhost Domain Info
The Dreamhost API command domain-list_domains was retired on Nov 2nd 2021. This function is a makeshift replacement for that.
Usage:
1. Log into your Dreamhost account and click Domains / Manage Domains
2. Paste this entire gist into the console
3. Press enter and wait for "sites.json" to be downloaded
Let me know if this helps anyone else or if you have any suggestions.
@callaginn
callaginn / sphp.sh
Created September 23, 2021 06:03
Easy Brew PHP version switching (with M1 Mac Support)
#!/bin/bash
# Creator: Phil Cook
# Modified: Andy Miller
osx_major_version=$(sw_vers -productVersion | cut -d. -f1)
osx_minor_version=$(sw_vers -productVersion | cut -d. -f2)
osx_patch_version=$(sw_vers -productVersion | cut -d. -f3)
osx_patch_version=${osx_patch_version:-0}
osx_version=$((${osx_major_version} * 10000 + ${osx_minor_version} * 100 + ${osx_patch_version}))
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
@callaginn
callaginn / sshlogin.exp
Created September 17, 2021 02:11
Expect script to supply root/admin password for remote ssh server and execute command.
#!/usr/bin/expect -f
# Expect script to supply root/admin password for remote ssh server
# and execute command.
# This script needs three argument to(s) connect to remote server:
# password = Password of remote UNIX server, for root user.
# ipaddr = IP Addreess of remote UNIX server, no hostname
# scriptname = Path to remote script which will execute on remote server
# For example:
# ./sshlogin.exp password 192.168.1.11 who
# ------------------------------------------------------------------------
@callaginn
callaginn / formcarry.js
Last active December 4, 2020 17:08
FormCarry Fetch Submission with Custom Response
// jshint strict:false, undef:false, unused:false
/*/
FormCarry Ajax Functions
Last Updated 2020-12-04
// How to Initialize
ajaxFormInit().then(json => {
console.log(json.form);
console.log(json.response);
@callaginn
callaginn / setup.sh
Last active August 27, 2020 21:10
Creates new SSH key, copies it to Github, and clones private config repo.
#!/bin/bash
#hey
br=$'\n'
b=$(tput bold)
c=$(tput sgr0)
yellow=$(tput setaf 11)
ssh_title="$(scutil --get ComputerName) ($(date +'%Y-%m-%d'))"
alert () { echo "${b}${yellow}$1${c}"; }
@callaginn
callaginn / mjml-to-html.php
Last active July 7, 2020 18:06
Convert MJML to HTML With PHP (Zero Fuss Method)
<?php
$home = `printf ~`;
putenv("HOME=$home");
putenv('PATH=$PATH:/bin:/usr/bin:/usr/local/bin:$HOME/bin');
function mjml2html($mjml) {
$temp = tempnam('', '');
file_put_contents($temp, $mjml);
$html = shell_exec('. ~/.bashrc; mjml ' . $temp . ' --config.minify true');
@callaginn
callaginn / random.liquid
Last active June 4, 2020 05:14
Shopify Liquid Randomly Shuffle Array
{%- comment -%}
Randomly Shuffle Liquid Array
Author: Stephen Ginn at cremadesignstudio.com
Credits: Random Number function from @131_studio
Usage: {%- include 'random' with 'a,b,c,d,e' -%}
This snippet does the following:
1. Creates a new array with the provided string
2. Calculate X amount to loop, based on array size times 10.
@callaginn
callaginn / ajax-contact-form.js
Last active May 3, 2024 16:38
Shopify Ajax Contact Form
// Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha
// for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page.
// Retrieves input data from a form and returns it as a JSON object:
function formToJSON(elements) {
return [].reduce.call(elements, function (data, element) {
data[element.name] = element.value;
return data;
}, {});
}