Skip to content

Instantly share code, notes, and snippets.

View renatoliveira's full-sized avatar

Renato Oliveira renatoliveira

View GitHub Profile
@renatoliveira
renatoliveira / jwt.apex
Last active May 28, 2025 14:45
JWT Creation and Validation example in Salesforce Apex
// JWT creation and validation example in Apex
String certificateName = 'JWTDemo';
String audience = 'nova';
String issuer = 'something';
String pubKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA26puZ2Bz2py4jJHXsR2bcMeNIFPH+uoXgI3TRMLSAUzWwR3V9Gpy5YFnk6SPJoeiS2IZXpu8+bH+rvwrMgK1vaPBPYlcmNarsmF2MWK41jxpHb2i9VrPcaB6+ckNOcYfdUl9t/BLCXNuuoYx6AIqGylBuZBk3Q/HCDwxtA/Zjze3TrWt40jVNPKEp4t0XwSGg/CXE47qWpzFyXCuE0lEKX8/Kdn7MF1RYbhAKpGLNhpxpnLt89U1IMuqmo2IlC1f404lptYyfyTfWE3SkWX4yONvx1ZMg33QniHpRI4zf+hLKggScOflnxRTh9HC/IHkWC9UvSfkdduiqQpWdzg5YwIDAQAB';
Blob publicKeyBlob = EncodingUtil.base64Decode(pubKey);
Auth.JWT jwt = new Auth.JWT();
jwt.setSub(UserInfo.getUsername());

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
@renatoliveira
renatoliveira / MultiMap.cls
Created September 3, 2024 12:58 — forked from aidan-harding/MultiMap.cls
A MultiMap for Salesforce Apex
/**
* @author [email protected]
* @date 29/08/2024
* @description A map where the items are lists of items and you can provide a function for how values map to keys.
* Oh, if we had generics....
*/
public class MultiMap {
private Map<Object, List<Object>> theMap;
private Type listType;
@renatoliveira
renatoliveira / resume.json
Last active June 17, 2025 12:27
My JSON resume.
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Renato Oliveira",
"label": "Salesforce Developer",
"image": "https://avatars.githubusercontent.com/u/6956403?v=4",
"email": "[email protected]",
"url": "https://github.com/renatoliveira",
"summary": "Renato Oliveira is a seasoned Salesforce Developer, Architect, and Consultant with nearly a decade of hands-on experience in leveraging Salesforce to drive business growth. Starting as a support analyst in 2015, Renato took an unconventional path by mastering the Salesforce Metadata API early in his career, giving him a deep, technical understanding of the platform. Fluent in English and Portuguese, he has collaborated with clients across Brazil, the US, and the UK, delivering scalable solutions tailored to diverse business needs. Renato's expertise spans custom development with Apex and Lightning Web Components, integrations with AW
@renatoliveira
renatoliveira / init.lua
Last active May 24, 2024 14:43
Nvim's Init script for setting up the Apex language server
-- Get the file path to the language server file provided by Salesforce.
local apex_jorje_lsp_file_path = vim.fn.expand("~/Downloads/apex-jorje-lsp.jar")
-- Set up the language server configuration for the Apex language, associating
-- it with the three main file types by extension, disabling telemetry, and
-- specifying the command.
require"lspconfig".apex_ls.setup {
apex_jar_setup = apex_jorje_lsp_file_path,
apex_enable_semantic_errors = false,
apex_enable_completion_statistics = false,
### Keybase proof
I hereby claim:
* I am renatoliveira on github.
* I am thelavasailor (https://keybase.io/thelavasailor) on keybase.
* I have a public key ASCi_4EZpwmK6UrnCFxM7pO72L_xqLu88alhYTzal-cphQo
To claim this, I am signing this object:
@renatoliveira
renatoliveira / MondayApi.cls
Created October 13, 2023 17:31
Apex to MondayAPI
public class MondayApi {
@SuppressWarnings('PMD.ApexSuggestUsingNamedCred')
public static Map<String, Object> execute(String query) {
HttpRequest request = new HttpRequest();
request.setEndpoint('callout:MondayApi');
request.setMethod('POST');
request.setBody(JSON.serialize(new Map<String, Object>{
'query' => query
}));
@renatoliveira
renatoliveira / TransferPermissionScript.cls
Last active September 22, 2023 14:05
Transfer Permissions
// 1. Erases permissions from current user
// 2. Copies permission set licenses and permission sets from another user.
// Rollback available at the end of the script.
Savepoint sp = Database.setSavepoint();
String fromUser = '[from username]';
String toUser = '[to username]';
// clean the user
@renatoliveira
renatoliveira / QuotePDFGenerator.apex
Created April 27, 2021 17:31 — forked from citrus/QuotePDFGenerator.apex
Generate Quote PDF via Salesforce REST API
global class QuotePDFGenerator {
@future(callout=true)
public static void AttachPDFToQuote(String Id) {
try {
CreateQuoteDocumentFromPDF(Id);
} catch(exception ex) {
System.debug('Error: ' + ex);
}
}
@renatoliveira
renatoliveira / main.py
Created December 25, 2019 14:14
Transform a POST call to a PATCH call
# Import the required libraries
# Flask is the web framework for dealing with web stuff (such as serving the app and handling
# the connections) We need to import the main "Flask" to run the app, and also its
# request and Response method and class to handle the request properly
from flask import Flask, Response, request
# requests is a simple http request library to handle... requests.
import requests
# Base64 is a standard module to help us encode/decode Base 64 strings