This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest class TernaryLazyEvalTest { | |
static Integer counter = 0; | |
static Boolean flag { get; set { counter++; flag = value; } } | |
static Boolean setTrue() { | |
return flag = true; | |
} | |
static Boolean setFalse() { | |
return flag = false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoaderDemoController { | |
@RemoteAction public static String getSalesforce() { | |
Long start = DateTime.now().getTime(); | |
String Salesforce = | |
'data:image/jpeg;base64,'+ | |
EncodingUtil.base64Encode( | |
new ApexPages.PageReference(url.getSalesforceBaseUrl().toExternalForm()+'/img/seasonLogos/Winter_17_175x65.png').getContent() | |
); | |
// minimum 1 second delay... | |
while(DateTime.now().getTime()-start<1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class XmlToJson { | |
// Try to determine some data types by pattern | |
static Pattern | |
boolPat = Pattern.compile('^(true|false)$'), decPat = Pattern.compile('^[-+]?\\d+(\\.\\d+)?$'), | |
datePat = Pattern.compile('^\\d{4}.\\d{2}.\\d{2}$'), | |
timePat = Pattern.compile('^\\d{4}.\\d{2}.\\d{2} (\\d{2}:\\d{2}:\\d{2} ([-+]\\d{2}:\\d{2})?)?$'); | |
// Primary function to decode XML | |
static Map<Object, Object> parseNode(Dom.XmlNode node, Map<Object, Object> parent) { | |
// Iterate over all child elements for a given node | |
for(Dom.XmlNode child: node.getChildElements()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest class CloneExamples { | |
@isTest static void unitTest() { | |
Account a1 = new Account(Name='Test'); | |
Account a2 = a1.clone(); | |
a2.Name = 'Test 2'; | |
// Proof that a1 is not modified with shallow clone | |
System.assert(a1.Name != a2.Name); | |
Contact c1 = new Contact(Account=a1); | |
Contact c2 = c1.clone(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:application > | |
<c:demoGackComponent /> | |
</aura:application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UpdateChangedFieldsController { | |
SObject oldRecord, currentRecord; | |
public UpdateChangedFieldsController(ApexPages.StandardController controller) { | |
oldRecord = controller.getRecord().clone(); | |
currentRecord = controller.getRecord(); | |
} | |
public PageReference saveChanges() { | |
SObject newClone = currentRecord.getSObjectType().newSObject(currentRecord.Id); | |
Map<String, Object> | |
oldValues = oldRecord.getPopulatedFieldsAsMap(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AWS { | |
// Post initialization logic (after constructor, before call) | |
protected abstract void init(); | |
// XML Node utility methods that will help read elements | |
public static Boolean getChildNodeBoolean(Dom.XmlNode node, String ns, String name) { | |
try { | |
return Boolean.valueOf(node.getChildElement(name, ns).getText()); | |
} catch(Exception e) { | |
return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:application > | |
<aura:attribute name="values" | |
type="String[]" | |
access="private" /> | |
<aura:attribute name="dragid" | |
type="Integer" | |
access="private" /> | |
<aura:handler name="init" | |
value="{!this}" | |
action="{!c.doInit}" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class PagingSortingController { | |
@AuraEnabled global static Account[] getAccounts() { | |
return [SELECT Name, Industry, AnnualRevenue FROM Account LIMIT 1000]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServerSide50KPagination { | |
Id[] recordIds; | |
public Integer maxPage { get; set; } | |
public Integer pageNumber { get; set; } | |
public Integer pageSize { get; set; } | |
public Account[] records { get; set; } | |
public ServerSide50KPagination() { | |
recordIds = new Id[0]; | |
for(Account record: [SELECT Id FROM Account ORDER BY Name]) { |