Skip to content

Instantly share code, notes, and snippets.

@sudikrt
sudikrt / SObjectUtil.cls
Created May 28, 2021 19:10
Apex utility class to help deal with dynamic SObjects in Salesforce
/**
* A utility class to help when dealing with SObjects.
*
* @author Logan Moore
*/
public with sharing class SObjectUtil
{
/**
* Given two SObjects and a list of fields to compare, this method tells
* you if the list of fields are the same on both SObjects.
@sudikrt
sudikrt / AWS.cls
Created April 25, 2021 17:14 — forked from brianmfear/AWS.cls
Abstract AWS implementation in Apex Code
/*
// Example implementation as follows:
public class AWSS3_GetService extends AWS {
public override void init() {
endpoint = new Url('https://s3.amazonaws.com/');
resource = '/';
region = 'us-east-1';
service = 's3';
accessKey = 'my-key-here';
method = HttpMethod.XGET;
<div>
<ul id="category">
<li id="laptop">Laptop</li>
<li id="cameras">Camera</li>
<li id="shoes">Shoes</li>
</ul>
</div>
<div id="form">
<input type="text" id="name" data-uppercase/>
<input type="text" id="pan"/>
<div id="grnadParent">
<div id="parent">
<div id="child"></div>
</div>
</div>
<html>
<head>
<title>Some Title</title>
</head>
<body>
<h1>This is hello world</h1>
<input type="text" onkeyup="betterFuntion()"/>
<script src="./index.js"></script>
</body>
</html>
//Function Currying
let multiply = function (x, y) {
console.log (x*y);
}
let multiplyByTwo = multiply.bind (this, 2);
multiplyByTwo (5);
//Function Currying
let nameObj = {
firstName : 'SK',
lastName : 'cool'
}
let printName = function () {
console.log (`${this.firstName} - ${this.lastName}`);
}
//task is to create own implementatio of bind
let printMyName = printName.bind (name)
printMyName();
@sudikrt
sudikrt / call_apply_bind.js
Created July 26, 2020 06:42
call, apply and bind method in JavaScript
let name = {
firstName : 'sudar', lastName : 'Test',
printFullName : function () {
console.log (`${this.firstName}-${this.lastName}`)
}
}
name.printFullName();
//Function Borrowing
let name = {
/*
An utility class to parse XML and create the equivalent JSON
@author - unknown
*/
public class XMLParser {
// To find the root element so that we can enclose it in the curly braces
public static String rootElementName;
/* Method which is parsing the XML content into JSON
if ($A.get("$Browser.formFactor") === 'PHONE') {
$A.createComponent(
"aura:html",
{
"aura:id": "styleTag",
"tag": "style",
"body": '.overLayCustomStyles {overflow : scroll; height:' + ($(window).height() - 173) + 'px;}'
},
function(newHtml, status, errorMessage){
//Add the new button to the body array