Skip to content

Instantly share code, notes, and snippets.

View scottmcclung's full-sized avatar

Scott McClung scottmcclung

View GitHub Profile
@scottmcclung
scottmcclung / README.md
Created August 19, 2024 01:52 — forked from thoroc/README.md
Dockerizing all the things: Running Ansible inside Docker container

Automating things in software development is more than useful and using Ansible is one way to automate software provisioning, configuration management, and application deployment. Normally you would install Ansible to your control node just like any other application but an alternate strategy is to deploy Ansible inside a standalone Docker image. But why would you do that? This approach has benefits to i.a. operational processes.

Although Ansible does not require installation of any agents within managed nodes, the environment where Ansible is installed is not so simple to setup. In control node it requires specific Python libraries and their system dependencies. So instead of using package manager to install Ansible and it’s dependencies we just pull a Docker image.

By creating an Ansible Docker image you get the Ansible version you want and isolate all of the required dependencies from the host machine which potentially might break things in other area

@scottmcclung
scottmcclung / processlist.sql
Created July 12, 2024 15:46 — forked from romuald/processlist.sql
Show PostgreSQL current (running) process list;
SELECT user, pid, client_addr, waiting, query, query_start, NOW() - query_start AS elapsed
FROM pg_stat_activity
WHERE query != '<IDLE>'
-- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
ORDER BY elapsed DESC;
@scottmcclung
scottmcclung / add_picklist_entries_task.yml
Created February 26, 2023 16:09 — forked from Julian88Tex/add_picklist_entries_task.yml
Example of CumulusCI add_picklist_entries Task as Flow Steps
5:
task: add_picklist_entries
options:
picklists: npsp__DataImport__c.npsp__Status__c
entries:
- fullName: Ready To Process
- fullName: Imported
- fullName: Dry Run - Validated
- fullName: Dry Run - Error
- fullName: Failed
@scottmcclung
scottmcclung / Aggregate.cls
Created February 17, 2022 02:04
AggregateResult Proxy class for mocking
/**
* Proxy class for AggregateResult that allows summary data to be mocked in unit tests
* Derived from Adrian Larson's answer here: https://salesforce.stackexchange.com/questions/173193/is-there-a-way-i-can-mock-an-aggregateresult
*
* Usage:
* To create data for the following query
* [SELECT AccountId, COUNT(Id) opportunities FROM Opportunity GROUP BY AccountId]
*
* List<Aggregate> mockData = new Aggregate[]{
* new Aggregate()

Salesforce OAuth 2.0 JWT Bearer Token Flow Walk-Through

This document will walk you through how to create or configure a Salesforce application for use with JWT authentication. These configuration steps and the example code works as of Salesforce API version 42.0.

Prerequisites

Create an RSA x509 private key/certification pair

Salesforce OAuth 2.0 JWT Bearer Token Flow Walk-Through

This document will walk you through how to create or configure a Salesforce application for use with JWT authentication. These configuration steps and the example code works as of Salesforce API version 42.0.

Prerequisites

Create an RSA x509 private key/certification pair

@scottmcclung
scottmcclung / History|-57c7183c|entries.json
Last active February 13, 2023 13:30
My VSCode Configuration
{"version":1,"resource":"file:///Users/scott/Downloads/docker-compose.yml","entries":[{"id":"qW7u.yml","source":"textFileCreate.source","timestamp":1673063148429},{"id":"yQXP.yml","timestamp":1673063285289},{"id":"ZAUZ.yml","timestamp":1673063395253},{"id":"irZb.yml","timestamp":1673063494046},{"id":"hlqs.yml","timestamp":1673063758386},{"id":"X8jN.yml","timestamp":1673063827088},{"id":"pw3F.yml","timestamp":1673064535470},{"id":"cseX.yml","timestamp":1673064550438},{"id":"DNzp.yml","timestamp":1673065194592},{"id":"bg0Z.yml","timestamp":1673065427122}]}
@scottmcclung
scottmcclung / TestUtility.cls
Created November 20, 2017 15:41
Apex method to generate fake record ids in tests.
/**
* Apex method to generate fake record ids in tests
* Created by Stephen Willcock
* https://foobarforce.com/2013/08/15/apex-method-of-the-day-string-repeat/
*/
public class TestUtility
{
static Integer s_num = 1;
public static String getFakeId(Schema.SObjectType sot)
@scottmcclung
scottmcclung / makecert.sh
Created October 26, 2017 13:33
Bash script for generating self signed ssl certificates.
#!/bin/bash
# Simple script to generate self signed certificates
# Creates SHA256 certs
#
# Example usage:
# makecert <dir>
# makecert my_certificate_directory/
#
#
@scottmcclung
scottmcclung / sfdeploy.sh
Last active April 26, 2023 12:17
Shell script to deploy metadata from a Salesforce DX project to a sandbox or production org.
#!/bin/bash
# Script to simplify the sfdx process of creating and deploying a metadata package
# from an SFDX project. The script expects to be placed in the SFDX project root directory.
#
# Example usage:
# sfdeploy <mode> <target> <tests>
# sfdeploy test uat local
# sfdeploy test uat all
# sfdeploy test uat test1,test2,test3