Skip to content

Instantly share code, notes, and snippets.

View Avinava's full-sized avatar

Avi Avinava

View GitHub Profile
@Avinava
Avinava / debounce.js
Last active July 7, 2022 10:04
Debouncing in LWC
/* eslint-disable @lwc/lwc/no-async-operation */
export default class Debounce extends LightningElement {
doApiCallDebounced;
connectedCallback() {
// generate the debounce handler
this.doApiCallDebounced = this.debounce(this.doApiCall, 1000);
}
@Avinava
Avinava / HTTPUtil.cls
Last active March 28, 2023 02:40
Generic http class that can be used in apex REST callouts
/**
* @description The HTTPUtil class provides a set of methods to perform HTTP requests to a given endpoint
* with specified headers, url parameters, and payload. It also allows encoding of url parameters,
* getting the response object, and getting the response headers
**/
public with sharing class HTTPUtil {
public transient HttpResponse response;
private String currentEndpoint;
private String baseEndpoint;
private Map<String, String> headers;
@Avinava
Avinava / LightningComponentController.js
Last active August 25, 2023 10:59
Using Promises In Lightning
{
doInit : function(component, event , helper){
var action = cmp.get("c.getCurrentUser");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
component.set("v.user", response.getReturnValue());
}
else {
@Avinava
Avinava / VFAngularSRemoteUpdate.page
Last active August 29, 2015 14:23
Angular JS & SObject Remote : Part 2 Updating Data from Page #NoControllers
<apex:page >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"/>
<c:sObjectRemote />
<script>
var vfApp = angular.module('vfApp',[]);
vfApp.controller('vfappController',function($scope){
$scope.accounts = []
$scope.getAccounts = function(){
sObject.query('SELECT Id,Name,Site,Type,Phone FROM Account LIMIT 100',function(result){
$scope.accounts = result;
@Avinava
Avinava / VFAngularSRemote.page
Created April 3, 2015 11:19
Angular JS & SObject Remote : Part 1 Bringing Data to Page #NoControllers
<apex:page >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"/>
<c:sObjectRemote />
<script>
var vfApp = angular.module('vfApp',[]);
vfApp.controller('vfappController',function($scope){
$scope.accounts = []
$scope.getAccounts = function(){
sObject.query('SELECT Id,Name,Site,Type,Phone FROM Account LIMIT 100',function(result){
$scope.accounts = result;
@Avinava
Avinava / customrtf.page
Last active August 29, 2015 14:14
Using customrtf visualforce component in a page
<apex:page standardStylesheets="true" docType="html-5.0" sidebar="false">
<apex:form >
<c:customrtf targetclass="mytextarea" rendered="true" toolbar="full"/>
<apex:inputTextarea styleClass="mytextarea" richText="false"/>
</apex:form>
</apex:page>
@Avinava
Avinava / PBE1KRemoting.page
Created October 21, 2014 10:52
Display more than 1K Records Using JSRemoting with JSRender
<apex:page controller="PBE1KRemoting_Con">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
<apex:includeScript value="https://rawgithub.com/BorisMoore/jsrender/master/jsrender.min.js"/>
<script>
function getContacts(callback){
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.PBE1KRemoting_Con.getContacts}',
function(result, event){
<c:textscanner value="{!TEXT_TO_SCAN}"/>
<apex:page standardController="Case" sidebar="false">
<c:textscanner value="{!Case.Description}"/>
</apex:page>
@Avinava
Avinava / VSModals.page
Last active August 29, 2015 14:02
Creating new records using Visualstrap Modals. Demo : http://blogforce9dev-developer-edition.ap1.force.com/VSModals
<apex:page controller="VSModals_Con">
<vs:importvisualstrap />
<apex:form >
<vs:visualstrapblock >
<vs:pageheader title="Cases" subtitle="Cases List" icon="file"/>
<vs:panel title="All Cases" type="primary" id="allCases">
<vs:well styleclass="well-sm" style="text-align:center">
<a class="btn btn-success btn-md" onclick="$('#newCase').modal('show');return false;">New Case</a>
</vs:well>
<apex:dataTable value="{!cases}" var="case" styleClass="table table-bordered table-hover">