Skip to content

Instantly share code, notes, and snippets.

Avatar

Pat Patterson metadaddy

View GitHub Profile
@metadaddy
metadaddy / sync-deletes.py
Created Jul 19, 2022
Delete all files in a destination bucket that do not exist in a source bucket
View sync-deletes.py
import os
import sys
import boto3
from botocore.config import Config
from dotenv import load_dotenv
# Use -d command line option for a dry run - i.e. don't actually delete files
dry_run = len(sys.argv) == 2 and sys.argv[1] == '-d'
@metadaddy
metadaddy / b2_multipart.php
Last active May 24, 2022
PHP sample code for a multipart file upload to Backblaze B2. Usage: php php_multipart.php [-v] <bucket_name> <local_file>
View b2_multipart.php
<?php
// PHP sample code to show multipart file upload using the B2 Native API
// User supplies optional -v for verbose output from curl, then bucket name
// and path to local file
$rest_index = null;
$opts = getopt("v::", [], $rest_index);
$args = array_slice($argv, $rest_index);
@metadaddy
metadaddy / Purge All Deleted Objects.js
Last active Feb 25, 2022
UserScript to erase all the deleted custom objects from a Salesforce org with one click. In Classic UI, go to Setup | Create | Objects | Deleted Objects and the script should be available.
View Purge All Deleted Objects.js
// ==UserScript==
// @name Purge All Deleted Objects
// @description Erase all deleted custom objects from the Salesforce org
// @include https://*.salesforce.com/p/setup/custent/DeletedEntitiesList?*
// ==/UserScript==
// UserScripts: https://github.com/quoid/userscripts
// Sometimes, when you're testing Salesforce metadata operations, you end up with a
// lot of deleted custom objects in your org. There's no API to erase a deleted object,
@metadaddy
metadaddy / setup.sh
Last active Dec 10, 2021
Setup a SalesforceDX scratch org, open an IP range, check we can log in
View setup.sh
#! /bin/bash
#
# Requires jq - see https://stedolan.github.io/jq/
#
# Assumes that the following env vars are set:
#
# CLIENT_ID - the client ID for your OAuth 2 app
# JWT_KEY_FILE - path to the private key for creating a JWT
# HUB_USERNAME - authentication username
@metadaddy
metadaddy / GoogleInternalRegHandler.cls
Created Sep 12, 2013
Simplest possible registration handler for OpenID Connect login from Google.
View GoogleInternalRegHandler.cls
global class GoogleInternalRegHandler implements Auth.RegistrationHandler{
global User createUser(Id portalId, Auth.UserData data){
User u = [SELECT Id FROM user WHERE GoogleID__c =: data.identifier];
return u;
}
global void updateUser(Id userId, Id portalId, Auth.UserData data){
}
}
@metadaddy
metadaddy / CitrixAuth.psm1
Last active Apr 14, 2021
Wrapper on Invoke-WebRequest to handle Citrix Cloud authentication, including token expiry
View CitrixAuth.psm1
<#
MIT License
Copyright 2021, Citrix Systems, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
View TestRestApi.page
<apex:page >
<apex:includeScript value="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"/>
<script>
jQuery(document).ready(function($) {
$('#queryform').submit(function(){
$.ajax($('#query').val(),
{
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
},
@metadaddy
metadaddy / Validate JSON Data.json
Created May 9, 2019
StreamSets Data Collector 3.8.0 pipeline to Validate JSON against a schema
View Validate JSON Data.json
{
"pipelineConfig" : {
"schemaVersion" : 6,
"version" : 12,
"pipelineId" : "ValidateJSONDatab0dfa94e-faf3-42ec-9a02-5122d048fe4c",
"title" : "Validate JSON Data",
"description" : "",
"uuid" : "d504e9d3-d4ea-4d52-8fd8-565592400d2e",
"configuration" : [ {
"name" : "executionMode",
@metadaddy
metadaddy / S3 to Azure Synapse.json
Last active Nov 7, 2019
Use StreamSets Cloud to read data from Amazon S3 and write to Azure Synapse (formerly SQL DW)
View S3 to Azure Synapse.json
{
"ciConfig" : null,
"currentExternalCIStatus" : null,
"currentRules" : {
"commitId" : "55b9a63d-8712-4a8d-96bf-511618889159:dpmfrancois",
"definitionRemoveMessage" : null,
"definitionRemoveTime" : 0,
"definitionRemover" : null,
"id" : "d53e9e53-eb4c-4204-9227-fd40d3a1b440:dpmfrancois",
"message" : "Committed with pipeline",
@metadaddy
metadaddy / portalauth.php
Created May 24, 2012
Calling Force.com SOAP API on behalf of a portal user
View portalauth.php
<?php
require_once ('soapclient/SforcePartnerClient.php');
function get_resource($url, $access_token) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Authorization: OAuth $access_token"));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);