Skip to content

Instantly share code, notes, and snippets.

@brianmfear
brianmfear / GetExtraLimitsForYourUnitTest.apxc
Last active January 11, 2024 05:09
Need more CPU or heap for creating your test data? Make it Queueable.
// Asking for extra CPU time and heap for those really "heavy" orgs
@isTest class GetExtraLimitsForYourUnitTest implements Queueable {
@testSetup static void testSetup() {
Test.startTest(); // TIP: this avoids governor limits for your @isTest methods
System.enqueueJob(new GetExtraLimitsForYourUnitTest()); // We'll get async limits!
// P.S. Did you know that the end of a unit test method triggers async code,
// just as if you called Test.stopTest()?
}
public void execute(QueueableContext context) {
// I now have 60000ms to do my setup, instead of just 10000ms.
@savithruml
savithruml / listener_visa_slots.py
Last active July 16, 2024 00:46
Listens for events on the H1b-visa-slots telegram channel & notifies you (audio and/or msg forwarding)
#!/usr/bin/env python3
# Author: SAVITHRU LOKANATH
# Login to Telegram on web browser https://web.telegram.org
# Install tesseract-ocr: apt-get install tesseract-ocr && pip install pytesseract
# Install Telethon lib: pip install telethon
# Install Text-to-Speech lib if using Windows: pip install pyttsx3
# To run, increase speaker volume to 100% & in your cmd prompt: python3 listener_visa_slots.py
@gbutt
gbutt / retrieve-object-perms.sh
Created May 19, 2019 18:40
SFDX script to retrieve profiles and perm sets with object CRUD and FLS
#!/bin/bash
TARGET_ORG=$1
if ["$TARGET_ORG" == ""]; then
echo Please specify a target username
echo For a list of available usernames use: sfdx force:org:list
exit 1
fi
@gminero
gminero / samplePopover.html
Created April 10, 2019 01:00
Sample slds table with popover of related record
<template>
<div>
<template if:true={ranger} >
<lightning-record-view-form
record-id={ranger}
object-api-name="Contact">
<div class="potato slds-box" style={boxClass}>
<lightning-output-field field-name="Name">
</lightning-output-field>
<lightning-output-field field-name="Email">
@gdoenlen
gdoenlen / AccountSelector.cls
Last active October 19, 2023 11:42
Simple dependency injection within SFDC
/**
* Selector for the `Account` entity
*/
public class AccountSelector {
public static final AccountSelector INSTANCE = new AccountSelector();
/**
* Finds all accounts that are child accounts of
* the given opportunity's account.
@brianmfear
brianmfear / TriggerDmlHelper.apex
Created August 27, 2018 23:08
Example of mapping related records to report errors on (Apex Code)
// Help report errors to parent/child object on failed DML update
// For use in Trigger contexts only.
// This version is for demonstration purposes only, and should not
// be considered production ready without additional modifications.
//
// Example trigger:
//
// trigger updateContactPhone on Account(after update) {
// Id[] updates = new Id[0];
// for(Account record: Trigger.new) {
@brianmfear
brianmfear / TreeNodeDataProvder.apxc
Created February 28, 2018 15:41
Recursive Tree in Lightning Demo
public class TreeNodeDataProvider {
@AuraEnabled public static User[] getUsers() {
return [SELECT Name, ManagerId, SmallPhotoUrl FROM User];
}
}
<aura:application extends="force:slds" controller="AccountListFilterByCity">
<aura:attribute name="cities" type="List" default="[]" />
<aura:attribute name="allAccounts" type="List" default="[]" />
<aura:attribute name="filterAccounts" type="List" default="[]" />
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<lightning:layout>
<lightning:layoutItem size="3">
<aura:iteration items="{!v.cities}" var="cityValue">
@brianmfear
brianmfear / PageController.apxc
Created October 3, 2017 02:55
Example Image Uploader in Visualforce
public class PageController {
// Transient so we don't exceed view state limits
public transient String fileType { get; set; }
public transient Blob fileBody { get; set; }
ApexPages.StandardController controller;
public PageController(ApexPages.StandardController controller) {
this.controller = controller;
}
@mattandneil
mattandneil / build.xml
Last active November 24, 2020 22:37
Salesforce Org Snapshot - Ant Script
<macrodef name="snapshot" description="Snapshots all metadata in an organization - Revision 22">
<attribute name="username" />
<attribute name="password" />
<attribute name="serverurl" default="https://login.salesforce.com" />
<attribute name="outPath" default="temp/snapshot" description="Directory to write snapshot." />
<sequential>
<!-- prompt user to confirm -->