Skip to content

Instantly share code, notes, and snippets.

View peterknolle's full-sized avatar
💭
🎅

Peter Knolle peterknolle

💭
🎅
View GitHub Profile
@peterknolle
peterknolle / BubbleChart2Controller.cls
Created February 9, 2014 19:17
Analytics API in Apex and Google Visualization API - Bubble Chart
public with sharing class BubbleChart2Controller{
public String deafultFromDate { get; set; }
public String defaultThroughDate { get; set; }
private static final String REPORT_ID = '00Ox0000000hEzq';
public BubbleChart2Controller() {
// Default to the current year.
// These instance variables are only used to
// populate the default values on the inputs.
@peterknolle
peterknolle / JoinController.cls
Created May 7, 2014 02:20
Google Visualization API Joins in Visualforce
public with sharing class JoinController {
// The from and through dates are hard-coded for simplicity's sake.
// Should change to parameters or input or something else.
public String getPageViewsJson() {
List<Page_View_Summary__c> pvs = [
SELECT Date__c, Number_of_Views__c
FROM Page_View_Summary__c
WHERE Date__c >= 2014-04-01
AND Date__c <= 2014-04-30
@peterknolle
peterknolle / CORS_MessageService.cls
Last active August 29, 2015 14:05
Accessing Apex REST from Site.com
@RestResource(urlMapping='/v1.0/messages')
global class MessageService {
@HttpGet
global static void getMessages() {
// buildMessages gets FeedItems
List<Message> messages = buildMessages();
RestResponse res = RestContext.response;
@peterknolle
peterknolle / RerenderNoAction.cls
Last active December 12, 2015 08:18
Some Visualforce and Apex experimentation with rerendering
public with sharing class RerenderNoAction {
public RerenderNoAction() {
viewMeCnt = 0;
}
public Integer viewMeCnt { get; set; }
public String parentOpt { get; set; }
public List<SelectOption> getParentOptions() {
List<SelectOption> opts = new List<SelectOption>();
@peterknolle
peterknolle / AnalyticsController.cls
Created January 25, 2014 22:59
Apex Analytics API and Report Chart Component
public with sharing class AnalyticsController{
public List<SelectOption> availableReports { get; set; }
public Id reportId { get; set; }
public Map<String, List<SelectOption>> availableDataTypeFilterOperators { get; set; }
public List<ColumnFilter> availableColumnFilters { get; set; }
public AnalyticsController() {
availableReports = retrieveAvailableReports();
availableDataTypeFilterOperators = retrieveAvailableDataTypeFilterOperators();
@peterknolle
peterknolle / remoteAutocomplete.page
Created October 1, 2014 01:06
Remote Objects Autocomplete
<apex:page >
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
<apex:remoteObjects >
<apex:remoteObjectModel name="Contact" fields="Name,Id,Email,MobilePhone,Phone"/>
</apex:remoteObjects>
@peterknolle
peterknolle / ContactsController.cls
Last active March 30, 2017 10:20
Remote Objects Infinite Scroll
public with sharing class ContactsController {
@RemoteAction
public static Map<String, Object> retrieveContacts(String type, List<String> fields, Map<String, Object> criteria) {
// Retrieve using the standard retrieve
Map<String, Object> result = RemoteObjectController.retrieve(type, fields, criteria);
// Add in the total record count for the current user.
// This is needed to know when to stop scrolling.
@peterknolle
peterknolle / remoteObjectNodes.page
Last active August 7, 2018 09:07
Visualforce Remote Objects and jsTree jQuery plugin
<apex:page >
<!-- download the jstree from jstree.com and upload the dist directory as a static resource -->
<link href="{!URLFOR($Resource.jsTree, 'themes/default/style.min.css')}" rel="stylesheet" />
<script src="{!URLFOR($Resource.jsTree, 'libs/jquery.js')}"></script>
<script src="{!URLFOR($Resource.jsTree, 'jstree.min.js')}"></script>
<script src="{!URLFOR($Resource.jsTree, 'jstree.min.js')}"></script>
<!--
Change the remoteObjectModel name="Account and
/**
* Everything is pass by value in Apex.
* When a method is called the runtime pushes a stackframe on the stack and params
* are created as local vars, including ref vars.
* The object that the ref var points to lives on the heap and can be modified if not immutable.
* The param itself is the ref var and is by value like all params in Apex.
*/
public class A {
public String val { get; set; }
}
@peterknolle
peterknolle / inputRating.cmp
Last active June 25, 2019 16:03
Input Rating Lightning Component
<aura:component >
<ltng:require scripts="/resource/rating/vendor/jquery.js,/resource/rating/lib/jquery.raty.js"
styles="/resource/rating/lib/jquery.raty.css"
afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
<aura:attribute name="value" type="Integer" required="true"/>
<aura:attribute name="ready" type="Boolean" default="false"/>
<div aura:id="rating"></div>
</aura:component>