Skip to content

Instantly share code, notes, and snippets.

View surajp's full-sized avatar
😄
Focusing

Suraj Pillai surajp

😄
Focusing
View GitHub Profile
@surajp
surajp / get-privileged-users.soql
Created June 16, 2026 19:11
Get details of users with privileges that need phishing resistant 2FA
SELECT Assignee.Id,
Assignee.Name,
Assignee.Email,
Assignee.Username,
Assignee.IsActive,
PermissionSet.Name,
PermissionSet.Profile.Name,
PermissionSet.PermissionsModifyAllData,
PermissionSet.PermissionsViewAllData,
PermissionSet.PermissionsCustomizeApplication,
@surajp
surajp / setup-sso.sh
Last active June 17, 2026 05:32
Set up SAML sso between 2 salesforce orgs
#!/usr/bin/env bash
#
# setup-sso.sh
# Sets up a Salesforce spoke org with SAML SSO from a hub org (acting as IdP).
#
# Usage: ./setup-sso.sh <spoke_org> <hub_org> <saml_metadata_file_path>
set -euo pipefail
readonly API_VERSION="66.0"
@surajp
surajp / md-server.js
Created February 6, 2026 20:25
Simple markdown server with support for Mermaid diagrams
const http = require("http");
const fs = require("fs");
const path = require("path");
const { exec } = require("child_process");
const PORT = 3000;
// Get file from command line arguments
const filePath = process.argv[2];
let initialContent = "";
@surajp
surajp / generateCoverageHtml.sh
Created June 27, 2025 16:11
Generate a formatted html code coverage report from apex code coverage json
#!/usr/bin/env bash
jq -r '
def uncovered_lines:
[.lines | to_entries[] | select(.value == 0) | .key] | sort_by(tonumber) | join(", ");
"<!DOCTYPE html>
<html>
<head>
<meta charset=\"UTF-8\">
@surajp
surajp / sfschema.txt
Created April 19, 2025 04:57
sf standard schema 2025
EntityName,FieldName
AIPredictionEvent,ReplayId
AIPredictionEvent,CreatedDate
AIPredictionEvent,CreatedById
AIPredictionEvent,EventUuid
AIPredictionEvent,PredictionEntityId
AIPredictionEvent,InsightId
AIPredictionEvent,TargetId
AIPredictionEvent,Confidence
AIPredictionEvent,FieldName
@surajp
surajp / LimitsIllustratorTest.cls
Last active March 20, 2025 17:51
Demonstrates increased limits in Apex tests
@IsTest
public class LimitsIllustratorTest {
private static final Integer RECORDS_TO_INSERT_PER_ITERATION = 9000;
private static final INTEGER SOQL_QUERIES_PER_ITERATION = 40;
private static final Integer FUTURE_METHOD_ITERATIONS = 3; //you can go upto 50 here theoretically, but Salesforce will kill the test after a while
@TestSetup
private static void setup() {
Test.startTest();
for (Integer i = 0; i < FUTURE_METHOD_ITERATIONS; i++) {
LimitsIllustratorTest.insertAccounts(i);
@surajp
surajp / postman-sf-auth-collection.json
Last active March 5, 2025 05:39
Get access token in Postman from the Salesforce cli via a node server
{
"info": {
"_postman_id": "35d1388c-2a10-4698-9cd6-6fb250c2b458",
"name": "Local SF Auth",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "1474473",
"_collection_link": "https://team-sf.postman.co/workspace/Salesforce~e589a405-8419-4e78-9608-343f0d307f55/collection/1474473-35d1388c-2a10-4698-9cd6-6fb250c2b458?action=share&source=collection_link&creator=1474473"
},
"item": [
{
@surajp
surajp / createTestSuite.cls
Last active June 21, 2025 14:06
Anonymous apex to create test suite. Deletes test suite with the same name if it exists
class Membership {
Id apexClassId;
Id apexTestSuiteId;
public Membership(Id suiteId, Id classId) {
this.apexTestSuiteId = suiteId;
this.apexClassId = classId;
}
}
private static final String API_VERSION = 'v63.0';
@surajp
surajp / dynaComp.html
Created August 15, 2023 17:27
Custom Elements in LWC
<template>
<h2>Dynamic Component</h2>
<div lwc:dom="manual" class="container"></div>
</template>
@surajp
surajp / sfRestApi.sh
Last active February 9, 2023 19:15
A script for invoking SF REST APIs from the command line using session id from sfdx
#!/usr/bin/env bash
set -euo pipefail
# A script for invoking SF REST APIs using session id from sfdx
if [[ $1 = "-h" || $1 = "-help" ]]; then
echo "Usage: $(basename $0) <org username/alias> <path starting from version number> <additional request info>"
exit 1
fi