Skip to content

Instantly share code, notes, and snippets.

View lukethacoder's full-sized avatar
🤔
working on non-code projects

Luke Secomb lukethacoder

🤔
working on non-code projects
View GitHub Profile
@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 / insecure-chrome.cmd
Created June 4, 2020 11:40
Run Chrome allowing insecure content
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --allow-running-insecure-content
@lukethacoder
lukethacoder / date.js
Last active July 25, 2020 12:02
JS Dates n Times
let now = new Date()
let yr = now.getFullYear()
let mth = `${
now.getMonth() + 1 < 10 ? `0${now.getMonth() + 1}` : now.getMonth() + 1
}`
let dt = `${date.getDate() < 10 ? `0${date.getDate()}` : date.getDate()}`
let hrs = `${
date.getHours() < 10 ? `0${date.getHours()}` : date.getHours()
}`
let mins = `${
@lukethacoder
lukethacoder / line-awesome-array-objects.json
Last active August 16, 2020 13:53
List Awesome Font Library - class name by unicode, handy for running a custom icon search. https://icons8.com/line-awesome
[
{
"name": "accessible-icon",
"type": "lab",
"unicode": ""
},
{
"name": "american-sign-language-interpreting",
"type": "la",
"unicode": ""
@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 / up-accounts-usage.md
Last active August 12, 2020 11:18
Google Sheets Function for fetching Accounts and their current values

Up Accounts API

  1. Create a new Sheet (or use an existing one)
  2. Tools -> Script Editor
  3. Copy + Paste the attached .js code snippet (Save)
  4. Back on the sheet, paste in =FetchAccounts("up:yeah:THE_REST_OF_YOUR_TOKEN_HERE", 0)
  5. Profit

Don't have an API token, get one here.

@lukethacoder
lukethacoder / remove-duplicates-by-field-name.js
Created August 16, 2020 13:15
Remove duplicate Objects within an array by specific field value
function removeDuplicateObjectsByKey(array, fieldToDuplicateCheck) {
const newArray = []
const arrayKeys = []
array.forEach((item) => {
// check if we don't already have the value within the arrayKeys array
if (!arrayKeys.includes(item[fieldToDuplicateCheck])) {
// push this value to the arrayKeys array
arrayKeys.push(item[fieldToDuplicateCheck])
// push this object to the newArray array
@lukethacoder
lukethacoder / inverse-object-keys-and-values.ts
Created September 10, 2020 03:55
Inverse the Object keys/values
/**
* @description Inverse the Object keys/values
* @param {object} obj
*/
export function inverseObjectKeysAndValues(obj: { [key: string]: any }) {
return Object.keys(obj).reduce(
(acc, curr) => ({
...acc,
[obj[curr].toString()]: curr,
}),
@lukethacoder
lukethacoder / settings.json
Last active May 11, 2021 00:21
Base VS Code Workspace and Tasks for SFDX projects (helps with hiding unnecessary metadata folders and adds handy vs code tasks for CRUD)
{
"search.exclude": {
"**/.localdevserver": true,
"**/.sfdx": true,
"**/node_modules": true,
"force-app\\main\\default\\aura": false,
"force-app\\main\\default\\classes": false,
"force-app\\main\\default\\lwc": false,
"force-app\\main\\default\\pages": false,
"force-app\\main\\default\\staticresources": true
@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",