Skip to content

Instantly share code, notes, and snippets.

@lukethacoder
lukethacoder / set-of-ids-from-list-of-objects.cls
Last active January 17, 2024 20:48
APEX: Get a Set<Id> of Id's from a List<SObject> of Objects
// Query list of Accounts
List<Account> accounts = [
SELECT
Id, Name
FROM
Account
];
// get Set of Ids of the Object
Set<Id> ids = new Set<Id>(new Map<Id, Account>(accounts).keySet());
@lukethacoder
lukethacoder / fflib-at4dx-org-install-script.md
Last active January 11, 2024 10:51
Setup fflib/at4dx via node script

fflib and at4dx should be pulled locally and pushed to your orgs.

They should NOT be backed up in git.

To install the packages run (from within your SFDX Project):

node --harmony setup.mjs e- ORG_ALIAS
@lukethacoder
lukethacoder / content-distribution.cls
Created August 11, 2020 12:39
Check and/or Create a ContentDistribution with a ContentDownloadURL (allows for public links of 'Files' in Salesforce)
String linkedEntityId = 'a05B000000ACLmYIAX';
List<ContentDocumentLink> cdl = [
SELECT
ContentDocument.Id, ContentDocument.Title, ContentDocument.FileType, ContentDocumentId
FROM ContentDocumentLink
WHERE LinkedEntityId =: linkedEntityId
];
ContentDocumentLink cdl1 = cdl[0];
@lukethacoder
lukethacoder / tasks.json
Last active April 27, 2023 06:16
SFDX Project VS Code Tasks. 2023 Updated to the new sf cli. based on https://gist.github.com/douglascayers/097a885727a0afe583122e9dc85dd3a7
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Deploy Current File",
"type": "shell",
"command": "sf",
"args": [
"project",
"deploy",
@lukethacoder
lukethacoder / wtf-sfdx-scratch-org.md
Last active April 12, 2023 02:06
wtf-sfdx-scratch-org

How the heck do I set up a scratch org using sfdx? Well, you're in the right place.

This gist has been moved and published here

@lukethacoder
lukethacoder / session-id.apex
Created December 22, 2022 09:49
APEX: Print the `UserInfo.getSessionId()` to the developer console without it being obfuscated. (Salesforce Apex)
String theToken = '';
for (String idPart : UserInfo.getSessionId().split('')) {
theToken += '"' + idPart + '",';
}
System.debug('[ ' + theToken + '].join(\'\')');
// DEBUG: [ "0", "1", "2", ...].join('')
// the output can be pasted into a browser console to join it back into a single string
@lukethacoder
lukethacoder / community-head-dev.css
Created May 25, 2021 05:23
Show the hidden aura based errors within a Salesforce Community (errors are never logged to the console)
/* Allows devs to see errors that probably should be logged to the console but aren't */
.auraErrorBox {
width: 100%;
}
.auraErrorBox > span {
display: flex;
align-items: center;
font-weight: 700;
margin-bottom: 8px;
}
@lukethacoder
lukethacoder / README.md
Last active November 23, 2022 07:40
Pokemon Pokedex Test Data - handy for quickly testing searching/filtering/paginating things with "real" data

POKEMON TEST DATA

handy for quickly testing searching/filtering/paginating things with "real" data

const BASE_URL = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/'

export const POKEMON_TYPE_COLORS = {
  normal: '#A8A77A',
 fire: '#EE8130',
@lukethacoder
lukethacoder / exercism-dark-mode.css
Last active October 30, 2022 20:02
🌜 Exercism Dark Mode 2022: A potentially buggy but beautifully dark theme
.theme-light {
--backgroundColorA: var(--c-282339);
--backgroundColorA-RGB: 40,35,57;
--backgroundColorB: var(--c-211D2F);
--backgroundColorC: var(--c-302B42);
--backgroundColorD: var(--c-3A3557);
--backgroundColorE: var(--c-4A475F);
--backgroundColorF: var(--c-191525);
--backgroundColorG: var(--c-2F2943);
--borderColor3: var(--c-8480A0);
@lukethacoder
lukethacoder / ID3v1-genres.json
Created October 10, 2022 15:15
ID3v1 Genres
[
"Blues",
"Classic Rock",
"Country",
"Dance",
"Disco",
"Funk",
"Grunge",
"Hip-Hop",
"Jazz",