Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Coding

Doug Ayers douglascayers

👨‍💻
Coding
Block or report user

Report or block douglascayers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@douglascayers
douglascayers / DemoBatchJob.cls
Last active Jul 4, 2019
Demo of Apex Batch Job's finish method not running if exception occurs in its execute method (API v46.0)
View DemoBatchJob.cls
public class DemoBatchJob implements Database.Batchable<SObject> {
public Database.QueryLocator start( Database.BatchableContext context ) {
System.debug( 'DemoBatchJob.start: ' + context );
return Database.getQueryLocator([ SELECT Id FROM Organization ]);
}
public void execute( Database.BatchableContext context, List<SObject> records ) {
System.debug( 'DemoBatchJob.execute: ' + context );
Integer i = 1 / 0; // cause exception
@douglascayers
douglascayers / event-start-time-utc.txt
Created Jun 23, 2019
Format Event Start Time in UTC in ISO-8601 Format (no dashes)
View event-start-time-utc.txt
TEXT( YEAR( ActivityDate ) ) &
LPAD( TEXT( MONTH( ActivityDate ) ), 2, '0' ) &
LPAD( TEXT( DAY( ActivityDate ) ), 2, '0' ) &
'T' &
LPAD( TEXT( HOUR( TIMEVALUE( ActivityDateTime ) ) ), 2, '0' ) &
LPAD( TEXT( MINUTE( TIMEVALUE( ActivityDateTime ) ) ), 2, '0' ) &
LPAD( TEXT( SECOND( TIMEVALUE( ActivityDateTime ) ) ), 2, '0' ) &
'Z';
@douglascayers
douglascayers / event-end-time-utc.txt
Last active Jun 23, 2019
Format Event End Time in UTC in ISO-8601 Format (no dashes)
View event-end-time-utc.txt
/* 1440 minutes in a day */
TEXT( YEAR( ActivityDate + DurationInMinutes / 1440 ) ) &
LPAD( TEXT( MONTH( ActivityDate + DurationInMinutes / 1440 ) ), 2, '0' ) &
LPAD( TEXT( DAY( ActivityDate + DurationInMinutes / 1440 ) ), 2, '0' ) &
'T' &
LPAD( TEXT( HOUR( TIMEVALUE( ActivityDateTime + DurationInMinutes / 1440 ) ) ), 2, '0' ) &
LPAD( TEXT( MINUTE( TIMEVALUE( ActivityDateTime + DurationInMinutes / 1440 ) ) ), 2, '0' ) &
LPAD( TEXT( SECOND( TIMEVALUE( ActivityDateTime + DurationInMinutes / 1440 ) ) ), 2, '0' ) &
'Z';
@douglascayers
douglascayers / delete-local-branches.sh
Last active Jun 20, 2019
Delete local branches that no longer exist on a remote
View delete-local-branches.sh
# Delete all local branches whose remote branch no longer exists.
git branch -v | grep -E "[0-9a-zA-Z]{7} \[gone\]" | awk '{ print $1 }' | xargs git branch -D $1
# The commmand explained:
#
# List all branches. The -v flag will include "[gone]" in the output if the remote tracked branch no longer exists.
# git branch -v
#
# Next filter rows that indicate their remote tracked branch no longer exists.
@douglascayers
douglascayers / sfdx-project.json
Last active Apr 28, 2019
Simple Salesforce DX project configuration file to activate Salesforce Extensions for Visual Studio Code.
View sfdx-project.json
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "45.0"
@douglascayers
douglascayers / tasks.json
Last active Jun 20, 2019
Simple tasks for Visual Studio Code to deploy/retrieve/delete the currently opened file, or an entire folder, using Salesforce CLI force:source commands.
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Deploy Current File",
"type": "shell",
"command": "sfdx",
"args": [
"force:source:deploy",
"--sourcepath",
@douglascayers
douglascayers / setup.sh
Created Feb 5, 2019
Deploy Chatter Bot for Feeds using Salesforce CLI
View setup.sh
# Install Git
# https://git-scm.com/downloads
# Install Salesforce CLI
# https://developer.salesforce.com/tools/sfdxcli
# Authorize to the org you want to install Chatter Bot apps to
sfdx force:auth:web:login -a YourOrgAlias
# Download the Chatter Bot Groups app and deploy to your org (pre-requisite for Chatter Bot Feeds demo)
View sfdx-mass-action-scheduler-version.js
{
"version": "2.2",
"url": "https://github.com/douglascayers-org/sfdx-mass-action-scheduler/wiki/Release-Notes"
}
View SharedLibrary.js
/* SharedLibrary.js, upload as a static resource */
window.sum = function(a, b) {
return ( a + b );
}
View ServiceComponent.html
<!-- ServiceComponent.cmp -->
<aura:component>
<aura:method name="sum" action="{!c.handleSum}">
<aura:attribute name="a" type="Integer" required="true"/>
<aura:attribute name="b" type="Integer" required="true"/>
</aura:method>
</aura:component>
You can’t perform that action at this time.