Skip to content

Instantly share code, notes, and snippets.

View codefriar's full-sized avatar

Kevin Poorman codefriar

View GitHub Profile
@codefriar
codefriar / MonitorAsyncUsage.cls
Created November 30, 2023 19:01 — forked from brianmfear/MonitorAsyncUsage.cls
Notify Admin when approaching Async Apex usage limit
public class MonitorAsyncUsage implements Schedulable {
public class ResourceInfo {
public Integer Max;
public Integer Remaining;
}
public class LimitsAPI {
public ResourceInfo DailyAsyncApexExecutions;
}
public with sharing class WeekFiveClassExercises {
public static void allAboutSets() {
//Let's make a set
Set<String> cuisineTypes = new Set<String>();
//Why a set instead of a list? Usually because we need each entry in the collection to be unique.
//Perhaps we're creating a list of cuisines and it's possible we'll encounter the same one twice, but we don't want it to appear twice
/**
* ContactTriggerHandler description
* @description this class is responbile for...
* @author Kevin Poorman
* @updated 8/26/19
*/
public with sharing class CommentingOnCodeExercise {
/**
public with sharing class WeekFiveHomework {
public static void setsReview(){
//Your assignment: Play with Sets!
// 1. Create a set of Strings and add at least 5 entries
Set<String> Colors = new Set<String>();
Colors.add('Pink');
public with sharing class WeekFourHomework {
//Let's practice calling different methods by writing our very own methods. You will write and save methods in the space below
//that call the existing methods you see already written here. Ready? Let's Go!
//Sample: Here is a public method that calls the getfavoriteColorsMethod below and prints the results to our debug log
public static void printOutFavoriteColorsDemo() {
List<String> favoriteColors = getFavoriteColors();
System.debug('Here are the favorite colors: ' + favoriteColors);
/**
* Promise v2.0 - Kevin Poorman
* Thanks to Chuck Jonas!
* This class exists to demonstrate the usage of the Promise library.
*
*/
Public Class Demo_PromiseUse {
// This execute method optionally accepts a string param that is used to pass data into
// the intial promise step.
Public Void execute(String param) {
@codefriar
codefriar / Log.cls
Created March 28, 2017 16:57
Log.cls is a standardized log formatter for putting data into salesforce debug logs in a clean and efficient manner. The idea, is to make the debug data easy to find in the 1+ mb of text that each apex execution context can produce.
/**
* Created by kpoorman on 3/25/17.
* Log provides standardized methods for logging data to
* debug logs in a structured, easy to find way.
* All methods are static by design. This should be 0 setup
* or at least 0 in code setup.
*
* Future versions may pull configuration from
* custom metadata #safeHarbor
*/
public with sharing class ExampleCode {
public class exampleCodeException extends Exception {}
Public Integer add(Integer one, Integer two){
return one + two;
}
Public Decimal divide(Integer one, Integer two){
if(two == 0){
throw new exampleCodeException('Dividing by Zero makes Astro Cry');
@codefriar
codefriar / Invocable_TriggerMCEvent.cls
Last active January 30, 2024 06:21
MCMessagingUtils is an Apex class used to trigger journey builder actions and push messages from Salesforce service and sales cloud.
public with sharing class Invocable_TriggerMCEvent {
@InvocableMethod(label='Send Message with new Comment to Reporter' description='Send Message with new Comment to Reporter')
public static void TriggerMCEvent(List<String> contactKey) {
MCMessagingUtils.triggerMCInteractionEvent(contactKey[0]);
}
}
@codefriar
codefriar / DestroyAllTheThings.cls
Created April 12, 2016 10:21 — forked from joshbirk/DestroyAllTheThings.cls
Simple class to try and destroy all records in a Salesforce instance. Does not currently destroy Apex, or Visualforce, or Lightning components. It probably will never do the latter, I'm not sure I want it to do the former. Does not destroy custom metadata, but I'm looking into it. TODO: Parameters to avoid limits.
public class DestroyAllTheThings {
public DestroyAllTheThings() {}
public void destroySimpleCRMStuff() {
//First clear out known dependents, leads and cases etc.