Skip to content

Instantly share code, notes, and snippets.

@jamigibbs
jamigibbs / calcfunctions.js
Last active Sep 3, 2021
Calculating With Functions. eg. seven(times(five()));
View calcfunctions.js
function makeNum(num, func) {
if (func === undefined) {
return num;
} else {
return func(num);
}
}
function zero(func) {
return makeNum(0,func);
@jamigibbs
jamigibbs / pubsub.js
Last active Apr 26, 2021
pubsub for Experience Builder sites
View pubsub.js
/**
* Copyright (c) 2021. 7Summits Inc. All rights reserved.
*/
/**
* A basic pub-sub mechanism for sibling component communication.
* To be replaced by messageService when out of beta in experience builder:
*
* https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_message_channel
*
View PageLayout_Template.cmp
<!--
- Use this component as a template for custom page layouts
- siteforceContentArea, slds-col_padded & com-layout-column are Customer Service (Napili) classes that match
- page layout classes in that OTB theme
-->
<aura:component description="Peak_PageLayout_Template" implements="forceCommunity:layout" access="global">
<aura:attribute name="ContentHeader" type="Aura.Component[]" />
<aura:attribute name="ContentSubHeader" type="Aura.Component[]" />
@jamigibbs
jamigibbs / gist:c563c1c3fe49883cbc0d70450fceb313
Created Mar 29, 2021
Google Calendar last day of month repeat event
View gist:c563c1c3fe49883cbc0d70450fceb313
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20210430
DTEND: 20210430
RRULE:FREQ=MONTHLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYSETPOS=-1;WKST=SU
SUMMARY:Payday
END:VEVENT
END:VCALENDAR
View gist:ae47a4614bdcbcdcf06a330787ce067b
get targetValue() {
if (isNaN(requestedAmount)) return 0;
if (isNan(otherRequestedAmount)) return 0;
return requestedAmount + otherRequestedAmount;
}
@jamigibbs
jamigibbs / feeditem-soql-query.cls
Last active Aug 26, 2020
SOQL query for profile image from FeedItem
View feeditem-soql-query.cls
feedItemsList = [
SELECT Id, Body, Title, Parent.Name, CreatedDate,
TYPEOF InsertedBy WHEN User THEN Name, MediumPhotoUrl END
FROM FeedItem
WHERE CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
];
@jamigibbs
jamigibbs / bad-feeditem-soql-query.cls
Last active May 21, 2020
Bad Feed Item SOQL query for profile image
View bad-feeditem-soql-query.cls
feedItemsList = [
SELECT Id, Body, Title, CreatedDate, Parent.Name, Parent.MediumPhotoUrl
FROM FeedItem
WHERE CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
];
feedItemsList = [
SELECT Id, Body, Title, CreatedDate, Parent.Name, Parent__r.MediumPhotoUrl
FROM FeedItem
@jamigibbs
jamigibbs / bad-feeditem-soql-query-3.cls
Last active May 21, 2020
Bad Feed Item SOQL query for profile image 3
View bad-feeditem-soql-query-3.cls
feedItemsList = [
SELECT Id, Body, Title, CreatedDate, Parent.Name, InsertedBy.MediumPhotoUrl
FROM FeedItem
WHERE CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
];
feedItemsList = [
SELECT Id, Body, Title, CreatedDate, Parent.Name, InsertedBy__r.MediumPhotoUrl
FROM FeedItem
@jamigibbs
jamigibbs / bad-feeditem-soql-query-2.cls
Last active May 21, 2020
Bad Feed Item SOQL query for profile image 2
View bad-feeditem-soql-query-2.cls
feedItemsList = [
SELECT Id, Body, Title, CreatedDate, Parent.Name, Parent.Photo.mediumPhotoUrl
FROM FeedItem
WHERE InsertedBy = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
];
@jamigibbs
jamigibbs / websocketChat.js
Last active Mar 31, 2020
Enter and leave chat
View websocketChat.js
handleEnterChat() {
setUserChatActive()
.then((res) => {
this.isChatActive = res.Chat_Active__c;
this._socket.emit('userEnteredChat');
return refreshApex(this.wiredChatUsers);
})
.catch(error => {
// eslint-disable-next-line no-console
console.error('handleEnterChat error', error);