Skip to content

Instantly share code, notes, and snippets.

View dhaniksahni's full-sized avatar

Dhanik Lal Sahni dhaniksahni

View GitHub Profile
@dhaniksahni
dhaniksahni / DataDisplayController.cls
Created May 16, 2018 13:53 — forked from toanshulverma/DataDisplayController.cls
Sample Code to Generate PDF from Lightning components with in-memory data
public class DataDisplayController {
public String PDFData {get; set;}
public DataDisplayController(){
PDFData = '';
}
public PageReference downloadPDF(){
System.PageReference pageRef = new System.PageReference('/apex/PDFGenerator');
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.SignaturePad=e()}(this,function(){"use strict";function t(t,e,i){this.x=t,this.y=e,this.time=i||(new Date).getTime()}function e(t,e,i,o){this.startPoint=t,this.control1=e,this.control2=i,this.endPoint=o}function i(t,e,i){var o,n,s,r=null,h=0;i||(i={});var a=function(){h=!1===i.leading?0:Date.now(),r=null,s=t.apply(o,n),r||(o=n=null)};return function(){var c=Date.now();h||!1!==i.leading||(h=c);var d=e-(c-h);return o=this,n=arguments,d<=0||d>e?(r&&(clearTimeout(r),r=null),h=c,s=t.apply(o,n),r||(o=n=null)):r||!1===i.trailing||(r=setTimeout(a,d)),s}}function o(t,e){var n=this,s=e||{};this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.throttle?this._strokeMoveUpdate=i(o.prototype._strokeUpdate,this.throttle):this._strokeMo
@dhaniksahni
dhaniksahni / CaptureScreen.cmp
Last active January 30, 2020 13:42
CaptureSignature
<aura:component controller="CommandController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="commandText" type="string" />
<lightning:card title="Capture Screen">
<p>
<button id="start" onclick="{! c.takeScreenShot }">Start Capture</button>&nbsp;
<button id="stop">Stop Capture</button>
</p>
<div style="display: none;">
<video id="video" autoplay="true"></video>
@dhaniksahni
dhaniksahni / WhatsAppMessageService.apxc
Last active June 29, 2023 12:10
Twilio WhatsApp Message Integration in Salesforce Apex
public class WhatsAppMessageService {
@AuraEnabled
public static void sendMessage(string mobileno,string message)
{
errorResponseWrapper erw;
final String fromNumber = '+14155238886';
String account = 'ACa2e448aaa0e51ed81a56ff55b6635cca';
String token = '<your token>';
HttpRequest req = new HttpRequest();
@dhaniksahni
dhaniksahni / WhatsAppSender.cmp
Created September 6, 2019 15:33
Send WhatsApp Message using Lightning Component
<aura:component controller="WhatsAppMessageService" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
<lightning:notificationsLibrary aura:id="notifLib"/>
<div class="row">
<lightning:input aura:id="mobileNumber" name="mobileNumber" label="Mobile Number" />
<lightning:input aura:id="message" name="message" label="Message" />
</div>
<div class="row">
<lightning:button variant="brand" label="Send Message" title="Send Message" onclick="{! c.handleClick }" />
</div>
@dhaniksahni
dhaniksahni / captureImageWebCam.cmp
Last active April 7, 2021 19:56
Capture Image using WebRTC in Lightning Component
<aura:component controller="ImageController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<lightning:card title="Capture Screen">
<lightning:layout horizontalAlign="spread">
<lightning:layoutItem padding="around-small">
<h1>
MDN - WebRTC: Still photo capture demo
</h1>
<div class="camera">
<video id="video">Video stream not available.</video>
<button id="startbutton" onclick="{!c.doInit}">Take photo</button>
public class StackExchangeAccess {
@AuraEnabled
public static StackExchangeUserWrapper getUsers(integer pageNumber,integer pageSize,string sortdirection, string sortName, string sitename)
{
string url='page='+pageNumber+'&pagesize='+ pageSize+'&order='+sortdirection+'&sort='+sortName+'&site='+sitename;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.stackexchange.com/2.2/users?'+url);
request.setMethod('GET');
HttpResponse response = http.send(request);
public class StackExchangeUserWrapper {
@AuraEnabled
public List<Items> items;
@AuraEnabled
public Boolean has_more;
@AuraEnabled
public Integer quota_max;
@AuraEnabled
public Integer quota_remaining;
@dhaniksahni
dhaniksahni / stackoverflowExplorer.css
Created October 2, 2019 13:37
Salesforce Stack Exchange Explorer
.divcenter {
text-align: center;
font-weight: bold;
font-size: 15px;
}
@dhaniksahni
dhaniksahni / paginator.html
Created October 2, 2019 13:40
Paginator Lightning Web Component
<template>
<lightning-layout>
<lightning-layout-item>
<lightning-button label="Previous" icon-name="utility:chevronleft" onclick={previousHandler}></lightning-button>
</lightning-layout-item>
<lightning-layout-item flexibility="grow"></lightning-layout-item>
<lightning-layout-item>
<lightning-button label="Next" icon-name="utility:chevronright" icon-position="right" onclick={nextHandler}></lightning-button>
</lightning-layout-item>
</lightning-layout>