Skip to content

Instantly share code, notes, and snippets.

@lkatney
lkatney / DetectWifiSignal.page
Last active August 9, 2018 22:28
Visualforce page to detect wifi signal of machine - Salesforce
<apex:page controller="DetectWifiSignalController">
<style>
body{
text-align:center;
}
h1{
font-size : 20px
}
#status-section{
font-size : 18px;
public With Sharing class CustomDashboardController {
private static final String folderName = 'ESH Community Reports';
private Map<String, Report> reportsMap = new Map<String, Report>();
public Report report{get;set;}
public String reportId{
get;
set{
reportId = value;
@lkatney
lkatney / CustomDashboard.html
Created May 4, 2016 10:45
Custom dashboard VF page with report charts
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0" controller="CustomDashboardController">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="{!URLFOR($Resource.SLDS, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
.reportCharts img, .reportCharts .analyticsEmbeddedReportChart, .reportCharts .outerbound, .reportCharts .asOfDateContainer, .reportCharts .refreshButtonContainer{
<apex:page showHeader="true" sidebar="false" standardStylesheets="false" controller="DataCategorySidebarController">
<apex:stylesheet value="{!URLFOR($Resource.jqtree, 'jqtree.css')}"/>
<apex:includeScript value="https://code.jquery.com/jquery-1.11.3.min.js"/>
<apex:includeScript value="{!URLFOR($Resource.jqtree, 'tree.jquery.js')}"/>
<div id="sidebar"></div>
<script>
var $$ = jQuery.noConflict();
var data = JSON.parse('{!sidebarData}');
@lkatney
lkatney / CanvasVoteController.cls
Last active August 29, 2015 14:24
Accessing canvas signed request while using VF page as Canvas app
public with sharing class CanvasVoteController {
public String ideaId {get;set;}
public CanvasVoteController() {
System.debug(ApexPages.CurrentPage().getParameters());
String signed_request = ApexPages.CurrentPage().getParameters().get('signed_request');
system.debug(signed_request);
if(String.isNotBlank(signed_request)){
String jsonData = EncodingUtil.base64Decode(signed_request.replace('.',':').split(':')[1]).toString();
system.debug(jsonData);
<apex:page >
<!-- USE YOUR OWN BUTTON & DEPLOYMENT CODE HERE -->
<!-- button code -->
<img id="liveagent_button_online_573280000008OUC" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChatWithWindow('573280000008OUC', 'chat-window')" src="https://lakshay37demo-developer-edition.ap2.force.com/resource/1430373426000/Online_Chat_Button" /><img id="liveagent_button_offline_573280000008OUC" style="display: none; border: 0px none; " src="https://lakshay37demo-developer-edition.ap2.force.com/resource/1430373447000/Offline_Chat_Button" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573280000008OUC', document.getElementById('liveagent_button_online_573280000008OUC'));
liveagent.showWhenOffline('573280000008OUC', document.getElementById('liveagent_button_offline_573280000008OUC'));
});
<!--twitter -->
<a class="icon icon-social-twitter" href="https://twitter.com/intent/tweet?url={{url absolute="true"}};text={{title}} » " alt="Tweet '{{title}}'" target="_blank">
</a>
<!-- Facebook -->
<a class="icon icon-social-facebook" href="https://www.facebook.com/sharer/sharer.php?u={{url absolute="true"}}" alt="Share '{{title}}'" target="_blank">
</a>
<!-- Linkedin -->
<a class="icon icon-social-linkedin" href="https://www.linkedin.com/shareArticle?mini=true&url={{url absolute="true"}}&title={{title}}&summary={{meta_description}}" alt="Share '{{title}}'" target="_blank">
</a>
<!-- Google+ -->
@lkatney
lkatney / callout method.cls
Last active August 29, 2015 14:15
Method to make callouts handling PATCH request
/*********************************************************************************
@description : method to make https callouts
@param : url, method, body , headers
@return : HttpResponse
**********************************************************************************/
public static HttpResponse makeCallout(String url, String method, String body, Map<String,String> headers){
HttpRequest req = new HttpRequest();
HTTPResponse res = new HTTPResponse();
Http http = new Http();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Prior 32.0v
String comment = 'Click to vote/demote this idea';
// Create feed item input
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
feedItemInput.body = new ConnectApi.MessageBodyInput();
// Create text segment to hold the message body
List<ConnectApi.MessageSegmentInput> segments = new List<ConnectApi.MessageSegmentInput>();
ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
@lkatney
lkatney / Email Address Check - Regex.cls
Created November 18, 2014 08:58
Method with regex to check email format - Apex
public Boolean checkValidUsername(String emailAddress){
String emailRegex = '([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})';
Pattern MyPattern = Pattern.compile(emailRegex);
Matcher MyMatcher = MyPattern.matcher(emailAddress);
if(MyMatcher.matches()){
return true;
}else{
return false;