Skip to content

Instantly share code, notes, and snippets.

@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 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 / 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{
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 / 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;
@lkatney
lkatney / NamedCredentailsExample.cls
Last active January 26, 2022 12:23
NamedCredentailsExample is in Source org with named credentials to hit target salesforce org. NamedCredentailsLogCapture is in target org to handle incoming requests
public class NamedCredentailsExample {
public static String oAuth_flow(){
return makeCallout('OAuth_flow_Demo/services/apexrest/namedcredentials/demo','GET', null,null);
}
public static String oAuth_flow_Post(String body){
return makeCallout('OAuth_flow_Demo/services/apexrest/namedcredentials/demo','POST', null,body);
}
@lkatney
lkatney / arrowKeys.js
Created September 11, 2017 08:43
Directive to use arrow keys on forms or tables to quickly jump on to input boxes
angular.module('app.directives')
.directive('arrowKeysIndex', function() {
return {
restrict: 'A',
require: '^ngModel',
link: function (scope, element, attrs) {
element.on('keydown', function(event) {
let currentIndex = attrs.arrowKeysIndex;
let nextIndex;
@lkatney
lkatney / focusElement.js
Created September 11, 2017 08:59
Directive to focus an element on pages with an example to use it.
angular.module('app.directives')
.directive('focusElement', ['$timeout', function($timeout) {
return {
link: function(scope, element, attrs) {
scope.$watch(attrs.focusElement, function(value) {
if(value === true) {
$timeout(function () {
element[0].focus();
});
String csvLine = 'Test,Check,[email protected], "19, Link road, A1SH10, India", companyName, "companyStreet, CompanyCity, CompanyCountry"';
String prevLine = csvLine;
Integer startIndex;
Integer endIndex;
while(csvLine.indexOf('"') > -1){
if(startIndex == null){
startIndex = csvLine.indexOf('"');
csvLine = csvLine.substring(0, startIndex) + ':quotes:' + csvLine.substring(startIndex+1, csvLine.length());
@lkatney
lkatney / formattedDate.filter.js
Last active January 5, 2018 10:52
custom asynchronous filter to format date into appropriate format
(function() {
'use strict';
angular
.module('app.directives')
/**
* @ngdoc filter
* @name filter:formattedDate
* @description