Skip to content

Instantly share code, notes, and snippets.

@summersab
summersab / IAMCredentials.json
Last active March 12, 2019 04:39
Notes for getting started with bref.sh
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@summersab
summersab / FC.utils.errors.custom.js
Created April 7, 2019 21:19
FoxyCart Custom Error Logic
(function (FC, $) {
FC.util.notifyErrors = function() {
var $notifier = $("[data-fc-error-notifier]")
, $textEl = $notifier.find("[data-fc-notifier-text]")
, messagesWithContext = function() {
var count = 0;
return FC.json.messages.errors.forEach(function(error) {
"" !== error.context && (count += 1)
}),
count
@summersab
summersab / FC.field-length.js
Created April 7, 2019 21:21
FoxyCart Field Length Logic
/*
* Requires https://gist.github.com/summersab/ac6f801c8249d6940ca74d3f4634daf9
* Put this in your footer JS section to prevent customers from entering fields over 35 characters (UPS limit)
*/
$('#shipping_first_name, #shipping_last_name, #shipping_company, #shipping_address1, #shipping_address2').on('input',function(){
checkLengths();
});
$("body").on("focusout.fc", function() {
// I'm sure there's a better way to do this, but this makes sure to run the length validation logic AFTER the default FC validations. Otherwise, the custom error field highlighting briefly disappears.
var delay = setTimeout(function() {
@summersab
summersab / find-wp-functions.sh
Last active November 3, 2019 04:18
Shell script to find all WordPress functions used in a directory
#!/bin/bash
if [ ! -e "$1" ]
then
echo Invalid file or directory.
exit
fi
i=0
@summersab
summersab / find-php-functions.sh
Last active November 3, 2019 05:58
A dirty script to help find functions defined in PHP scripts or a directory tree containing PHP files.
#!/bin/bash
PATHNAME=""
FUNCTION="[a-zA-Z0-9_-]+"
PRIVATE=0
TYPE=""
while getopts ":hf:p:" opt; do
case ${opt} in
h )
@summersab
summersab / github-emails-bookmarklet.js
Last active December 26, 2019 17:34
Quickly find emails for a GitHub user
javascript:(function()%7B%2F%2FTurn this into a bookmarklet using a tool like https%3A%2F%2Fwww.shareprogress.org%2Fbookmarklet%2F%0Aemails %3D %5B%5D%3B%0Axhr %3D new XMLHttpRequest()%3B%0A%0Axhr.onload %3D () %3D> %7B%0A%09if (xhr.status %3D%3D 200) %7B%0A%09%09var result %3D JSON.parse(xhr.response)%3B%0A%09%09result.forEach(function(obj) %7B%0A%09%09%09if (obj.type %3D%3D %27PushEvent%27) %7B%0A%09%09%09%09email %3D obj.payload.commits%5B0%5D.author.email%3B%0A%09%09%09%09if (email.includes(%27noreply%27) %7C%7C email.includes(%27no-reply%27)) %7B%0A%09%09%09%09%09%2F%2FI know there%27s a better way to do this%2C but I%27m too lazy. This works.%0A%09%09%09%09%7D%0A%09%09%09%09else if (!emails.includes(email)) %7B%0A%09%09%09%09%09emails.push(email)%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D)%3B%0A%09%09if (emails.length > 0) %7B%0A%09%09%09output %3D emails.join(%27%2C%27)%3B%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09output %3D "No emails found."%3B%0A%09%09%7D%0A%09%09var textnode %3D document.createT
@summersab
summersab / cors.php
Last active September 4, 2020 01:41
CORS Function
<?php
$allowedOrigins = [
'https://domain.com',
'https://www.domain.com',
'https://subdomain.domain.com',
'*',
];
$origin = cors($allowedOrigins, 'GET, POST');
@summersab
summersab / Contract.md
Last active July 29, 2020 06:11 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Easy-To-Understand Freelance Developer Contract

Based on the popular open-source "Contract Killer" for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Modified by Platypus Innovations, LLC: July 29, 2020
  • Original post

@summersab
summersab / Foxy_url_params.js
Created August 13, 2020 17:15
Quick JS script to dump products in a Foxy session to URL params
// These are the bare minimum fields that you should exclude from the URL params:
//skip = ['id', 'item_number', 'sub_enddate', 'sub_nextdate', 'sub_startdate'];
// You can exclude these without problems - keeps things shorter:
skip = ['id', 'item_number', 'downloadable_id', 'expires', 'height', 'is_parent', 'length', 'multiship', 'parent_code', 'price_each', 'price_each_is_fractional', 'price_is_fractional', 'quantity_max', 'quantity_min', 'shipto', 'sub_enddate', 'sub_frequency', 'sub_frequency_raw', 'sub_nextdate', 'sub_startdate', 'url', 'weight', 'weight_each', 'width'];
FC.json.items.forEach(function(item) {
var urlArr = {};
Object.keys(item).forEach(function(el) {
if (!skip.includes(el)) {
@summersab
summersab / signifyd-webhook.java
Last active October 16, 2020 15:34
SignifyD Webhook JSON Validation (Java)
// Use JDK 1.8.0_66
// Test here to make life easy: https://www.jdoodle.com/online-java-compiler/
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import javax.xml.bind.DatatypeConverter;
public class Main {