Skip to content

Instantly share code, notes, and snippets.

@summersab
summersab / appstore.php
Last active Feb 19, 2021
Add app and category whitelisting and blacklisting to Nextcloud
View appstore.php
<?php
/**
* @copyright Copyright (c) 2021, Platypus Innovations LLC
*
* @author Andrew Summers
*
* This snippet provides a way to implement app and category whitelists/
* blacklists on Nextcloud. This is accomplished by creating a dummy
* "appstore" on the local system:
* - Download the official listings from the Nextcloud servers
@summersab
summersab / FoxyCustomClient.php
Last active Feb 14, 2021
Extension of the FoxyCart PHP SDK to include auto-debugging
View FoxyCustomClient.php
<?php
require './vendor/autoload.php';
use Foxy\FoxyClient\FoxyClient;
class FoxyCustomClient extends FoxyClient {
private $parent_class_filename = "";
private $last_function_line = "";
private $last_function = "";
@summersab
summersab / signifyd-webhook.php
Last active Oct 19, 2020
SignifyD Webhook JSON Validation (PHP)
View signifyd-webhook.php
<?php
function validatePostedJson() {
$json = file_get_contents('php://input');
if ($json == null) {
header('HTTP/1.1 400 Bad Request', true, 400);
die('No Data Found');
}
//Check the Hash
@summersab
summersab / signifyd-webhook.java
Last active Oct 16, 2020
SignifyD Webhook JSON Validation (Java)
View signifyd-webhook.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 {
@summersab
summersab / Foxy_url_params.js
Created Aug 13, 2020
Quick JS script to dump products in a Foxy session to URL params
View Foxy_url_params.js
// 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 / Contract.md
Last active Jul 29, 2020 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers
View Contract.md

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 / cors.php
Last active Sep 4, 2020
CORS Function
View cors.php
<?php
$allowedOrigins = [
'https://domain.com',
'https://www.domain.com',
'https://subdomain.domain.com',
'*',
];
$origin = cors($allowedOrigins, 'GET, POST');
@summersab
summersab / github-emails-bookmarklet.js
Last active Dec 26, 2019
Quickly find emails for a GitHub user
View github-emails-bookmarklet.js
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 / find-php-functions.sh
Last active Nov 3, 2019
A dirty script to help find functions defined in PHP scripts or a directory tree containing PHP files.
View find-php-functions.sh
#!/bin/bash
PATHNAME=""
FUNCTION="[a-zA-Z0-9_-]+"
PRIVATE=0
TYPE=""
while getopts ":hf:p:" opt; do
case ${opt} in
h )
@summersab
summersab / find-wp-functions.sh
Last active Nov 3, 2019
Shell script to find all WordPress functions used in a directory
View find-wp-functions.sh
#!/bin/bash
if [ ! -e "$1" ]
then
echo Invalid file or directory.
exit
fi
i=0