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 / GenericDelete.cls
Last active January 23, 2020 16:20
Generic method to delete a bunch of records while respecting profile and sharing access
/************************************************************
*** @author: Suraj Pillai
*** @group: Utils
*** @date: 01/2020
*** @description: A class for deleting a bunch of records after checking for delete access for each sobject, given a list of recordIds
*/
public with sharing class GenericDelete {
@surajp
surajp / findAuraEnabled.apex
Created February 20, 2020 15:10
Find all aura enabled methods in an org
find {AuraEnabled} in ALL FIELDS RETURNING ApexClass (Name)
@surajp
surajp / goauth.js
Last active December 28, 2020 21:11
Google OAuth using LWC + VF
import { LightningElement } from 'lwc';
const BASE_URL='https://accounts.google.com/o/oauth2/v2/auth';
export default class Goauth extends LightningElement {
doAuth(){
let client_id='<your client id>';
@surajp
surajp / uniq.js
Last active March 31, 2020 21:07
Remove duplicate values from an object array with an accessor function to identify dupes
/** Example 1: uniq([
{name:'John',id:1},
{name:'Jane',id:2},
{name:'John',id:3},
{name:'Jack',id:4}
],e=>e.name)= [
{name:'John',id:3},
{name:'Jane',id:2},
{name:'Jack',id:4}
]
@surajp
surajp / CheckFeatureController.cls
Created April 3, 2020 01:40
Check Feature in lwc
public with sharing class CheckFeatureController {
@AuraEnabled
public static boolean checkFeature(String featureName){
return FeatureManagementCheckerFactory.getFeatureManagementChecker().checkPermission(featureName);
}
}
@surajp
surajp / CSVColIterator.cls.java
Created April 10, 2020 00:12
CSV Column Iterator
public class CSVColIterator implements Iterator<String> {
private String colDelimiter=',';
private String textQualifier='"';
private String row='';
private Integer currentIndex=0;
public CSVColIterator(String row){
this.row = row;
}
@surajp
surajp / DeleteLogsAnon.java
Last active May 11, 2024 03:17
Delete Apex Logs
HttpRequest request = new HttpRequest();
request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
request.setMethod('DELETE');
Http sender = new Http();
for(ApexLog log: [Select Id from ApexLog]){
request.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v36.0/tooling/sobjects/ApexLog/'+log.Id+'/');
sender.send(request);
}
@surajp
surajp / 15to18.js
Last active May 7, 2020 21:59
Convert SF 15 char to 18 char id
(inp) =>
((elements) =>
inp.length != 15
? Error("invalid id")
: inp +
Object.values(elements)
.map((a) => "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".charAt(a))
.join(""))(
inp.split("").reduce(
(op, curr, index) => {
<template>
<div class="slds-p-around_small">
<lightning-input label="Object Name" onchange={changeName}></lightning-input>
<lightning-input label="My Domain" onchange={changeDomain}></lightning-input>
<lightning-helptext content="Use document.cookie.match(/sid=([^;]*)/)[1] in the browser console after logging into SF" class="slds-p-right_xx-small"></lightning-helptext>
<lightning-input label="SessionId" onchange={changeSessionId}>
</lightning-input>
<lightning-textarea label="CSV Data"></lightning-textarea>
<lightning-button onclick={upload} label="upload"></lightning-button>

Keybase proof

I hereby claim:

  • I am surajp on github.
  • I am surajp (https://keybase.io/surajp) on keybase.
  • I have a public key whose fingerprint is E697 5288 01FE 150B 3247 E81C A286 046F 8195 E8D9

To claim this, I am signing this object: