Skip to content

Instantly share code, notes, and snippets.

@brianmfear
brianmfear / PageController.apxc
Created October 3, 2017 02:55
Example Image Uploader in Visualforce
public class PageController {
// Transient so we don't exceed view state limits
public transient String fileType { get; set; }
public transient Blob fileBody { get; set; }
ApexPages.StandardController controller;
public PageController(ApexPages.StandardController controller) {
this.controller = controller;
}
@brianmfear
brianmfear / README-Template.md
Created February 21, 2018 16:16 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@brianmfear
brianmfear / BoundVsUnbound.app
Created May 1, 2018 21:31
Demonstration of one-way binding vs two-way binding
<aura:application >
<aura:attribute name="demo" type="Boolean" default="{!true}" />
<aura:if isTrue="{#v.demo}">
Unbound Set
<aura:set attribute="else">
Unbound Unset
</aura:set>
</aura:if>
<hr />
<aura:if isTrue="{!v.demo}">
@brianmfear
brianmfear / Debug.output
Created July 14, 2018 19:13
System.debug Fixes Your HashCodes
USER_DEBUG [5]|DEBUG|null
USER_DEBUG [6]|DEBUG|{Account:{Name=Test, Id=0015000001wL7JRAA0}=42}
USER_DEBUG [7]|DEBUG|42
@brianmfear
brianmfear / TriggerDmlHelper.apex
Created August 27, 2018 23:08
Example of mapping related records to report errors on (Apex Code)
// Help report errors to parent/child object on failed DML update
// For use in Trigger contexts only.
// This version is for demonstration purposes only, and should not
// be considered production ready without additional modifications.
//
// Example trigger:
//
// trigger updateContactPhone on Account(after update) {
// Id[] updates = new Id[0];
// for(Account record: Trigger.new) {
@brianmfear
brianmfear / DemoBundle.cmp
Created September 18, 2018 16:50
Disable button when all select options selected (Lightning)
<aura:application >
<aura:attribute name="opts" type="String[]" default="['A','B','C']" />
<aura:attribute name="disableButton" type="Boolean" default="false" />
<select aura:id="picklist" onchange="{!c.updateButtonState}" multiple="multiple">
<aura:iteration items="{!v.opts}" var="opt">
<option value="{!opt}">{!opt}</option>
</aura:iteration>
</select>
<lightning:button label="Test Button" disabled="{!v.disableButton}" />
</aura:application>
@brianmfear
brianmfear / samplecombobox.app
Created October 9, 2018 20:08
Sample combobox Lightning
<aura:application extends="force:slds">
<aura:attribute name="contactFields" type="Contact" default="{sobjectType:'Contact',Gender__c:'Male',Partner_Gender__c:'Female'}" />
<aura:attribute name="genderOptions" type="List" default="[{label:'Male',value:'Male'},{label:'Female',value:'Female'},{label:'Not Specified/Other',value:'Not Specified/Other'}]" />
<lightning:combobox name="applicantgender" label="Applicant Gender" value="{!v.contactFields.Gender__c}" placeholder="Select Gender" options="{! v.genderOptions }" />
<lightning:combobox name="partnergender" label="Partner Gender" value="{!v.contactFields.Partner_Gender__c}" placeholder="Select Gender" options="{! v.genderOptions }" />
Applicant Gender: {!v.contactFields.Gender__c}<br />
Partner Gender: {!v.contactFields.Partner_Gender__c}
</aura:application>
@brianmfear
brianmfear / demo1.app
Last active December 23, 2018 08:05
aura:if breaks again.
<aura:application >
<aura:attribute name="value1" type="String" access="private" />
<aura:attribute name="value2" type="String" access="private" />
<lightning:input value="{!v.value1}" label="Value 1" placeholder="Enter 'a'" />
<aura:if isTrue="{!v.value1 eq 'a'}">
<lightning:input value="{!v.value2}" label="Value 2" placeholder="Enter 'b'" />
<aura:if isTrue="{!v.value2 eq 'b'}">
<lightning:input label="Value 3" value="{!join(' ',v.value1,v.value2)}" />
</aura:if>
</aura:if>
@brianmfear
brianmfear / executeAnonymous.script
Created January 8, 2019 05:14
Let's Use 51 MB of Heap Without LimitException
string[] s = new string[0];
for(integer i = 0; i < 10100; i++) {
s.add('*'.repeat(i));
}
system.debug(Limits.getHeapSize());