Skip to content

Instantly share code, notes, and snippets.

View AWSTranscribeExample.cls
public class AWSTranscribeExample extends AWS {
public override void init() {
endpoint = new Url('https://transcribe.us-west-2.amazonaws.com/');
resource = '/';
region = 'us-west-2';
service = 'transcribe';
accessKey = 'my-key-here';
method = HttpMethod.XPOST;
payload = Blob.valueOf('{"LanguageCode": "en-US","Media": {"MediaFileUri": "S3 audio file link"},"MediaFormat": "mp4","MediaSampleRateHertz": 44100,"TranscriptionJobName": "SampleRestJob7"}');
setHeader('x-amz-target','Transcribe.StartTranscriptionJob');
@brianmfear
brianmfear / q292183.app
Created Feb 13, 2020
Demo of using @AuraEnabled without getter/setter in both Aura and LWC (SFSE: 292183)
View q292183.app
<aura:application controller="q292183">
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:attribute name="data" type="Map" />
{!v.data.a} {!v.data.b} {!v.data.c}
<hr />
<c:q292183lwc />
</aura:application>
@brianmfear
brianmfear / executeAnonymous.java
Created Apr 6, 2019
Example Reference and Heap Usage
View executeAnonymous.java
// Technical Note: We can't add any strings to the debug logs
// because strings go in to a "string pool", which affects
// heap size for each non-unique string.
// Base heap
System.debug(Limits.getHeapSize());
// The "symbol table" has a new entry added, +0 heap
// i is defined, no value (heap does not change)
Integer i;
@brianmfear
brianmfear / DebugLog.txt
Last active Mar 13, 2019
Can anyone replicate this error?
View DebugLog.txt
45.0 APEX_CODE,FINEST;APEX_PROFILING,FINEST;CALLOUT,FINEST;DB,FINEST;NBA,INFO;SYSTEM,FINEST;VALIDATION,FINEST;VISUALFORCE,FINEST;WAVE,INFO;WORKFLOW,FINEST
Execute Anonymous: class kkkkkkk {
Execute Anonymous: void method1() { }
Execute Anonymous: }
Execute Anonymous: new kkkkkkk().method1();
00:25:56.1 (1554571)|USER_INFO|[EXTERNAL]|00550000000wTdS|<redacted>|(GMT-04:00) Eastern Daylight Time (America/Indiana/Indianapolis)|GMT-04:00
00:25:56.1 (1597258)|EXECUTION_STARTED
00:25:56.1 (1605985)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
00:25:56.1 (1913868)|HEAP_ALLOCATE|[72]|Bytes:3
00:25:56.1 (1984554)|HEAP_ALLOCATE|[77]|Bytes:152
@brianmfear
brianmfear / WizardDemoController.cls
Created Feb 6, 2019
Demo Two Page VF Wizard With Components And Data Sharing
View WizardDemoController.cls
public class WizardDemoController {
public WizardDemoController getSelf() {
return this;
}
public String message { get; set; }
public Integer pageNumber { get; set; }
public WizardDemoController() {
pageNumber = 1;
}
public void nextPage() {
@brianmfear
brianmfear / executeAnonymous.script
Created Jan 8, 2019
Let's Use 51 MB of Heap Without LimitException
View executeAnonymous.script
string[] s = new string[0];
for(integer i = 0; i < 10100; i++) {
s.add('*'.repeat(i));
}
system.debug(Limits.getHeapSize());
@brianmfear
brianmfear / demo1.app
Last active Dec 23, 2018
aura:if breaks again.
View demo1.app
<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 / samplecombobox.app
Created Oct 9, 2018
Sample combobox Lightning
View samplecombobox.app
<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 / DemoBundle.cmp
Created Sep 18, 2018
Disable button when all select options selected (Lightning)
View DemoBundle.cmp
<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 / TriggerDmlHelper.apex
Created Aug 27, 2018
Example of mapping related records to report errors on (Apex Code)
View TriggerDmlHelper.apex
// 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) {
You can’t perform that action at this time.