Skip to content

Instantly share code, notes, and snippets.

@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 / 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",
@lukethacoder
lukethacoder / file.cls
Created August 1, 2022 05:29
APEX: Image content from URL
String extFileUrl = 'https://images.unsplash.com/photo-1592746455916-7ac99236b6d6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80';
Http h = new Http();
HttpRequest req = new HttpRequest();
// Replace any spaces in extFileUrl with %20
extFileUrl = extFileUrl.replace(' ', '%20');
// Set the end point URL
req.setEndpoint(extFileUrl);
req.setMethod('GET');
@lukethacoder
lukethacoder / head.css
Created June 1, 2022 07:03
Salesforce Community Error Debug Community Head Custom CSS
/* 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 / 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 / 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 / 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 / files-to-root.cmd
Created March 21, 2021 09:54
Windows CMD: Pull all files from sub folders into root folder
for /r %d in (*) do copy "%d" "C:\Documents\PATH\TO\SOURCE"
@lukethacoder
lukethacoder / get-time-between-two-dates.cls
Created January 29, 2021 06:10
APEX: Get time between two Datetime instances
Long dt1Long = DateTime.now().addDays(-1).getTime();
Long dt2Long = DateTime.now().getTime();
Long milliseconds = dt2Long - dt1Long;
Long seconds = milliseconds / 1000;
Long minutes = seconds / 60;
Long hours = minutes / 60;
Long days = hours / 24;