Skip to content

Instantly share code, notes, and snippets.

View pozil's full-sized avatar

Philippe Ozil pozil

View GitHub Profile
@pozil
pozil / DX setup script
Last active September 24, 2019 17:18
DX setup script
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask && brew cask install java
https://developer.salesforce.com/media/salesforce-cli/sfdx-osx.pkg
sfdx update
sfdx force:auth:web:login --setalias hub-org
sfdx force:config:set defaultdevhubusername=username --global
@pozil
pozil / gridAndLayoutSampleApp.cmp
Last active March 4, 2020 21:34
SLDS Grid vs. Lightning Layout
<aura:application extends="force:slds">
<!-- Pure HTML and SLDS Grid -->
<div class="slds-text-heading--large slds-p-around--small">Pure HTML and SLDS Grid</div>
<div class="slds-grid slds-wrap">
<div class="slds-p-around--small slds-size--1-of-1">1</div>
<div class="slds-p-around--small slds-size--1-of-2 slds-medium-size--5-of-6 slds-large-size--8-of-12">2</div>
<div class="slds-p-around--small slds-size--1-of-2 slds-medium-size--1-of-6 slds-large-size--4-of-12">3</div>
<div class="slds-p-around--small slds-size--1-of-1 slds-medium-size--1-of-2 slds-large-size--1-of-3">4</div>
<div class="slds-p-around--small slds-size--1-of-1 slds-medium-size--1-of-2 slds-large-size--1-of-3">5</div>
@pozil
pozil / childComponentWithAttribute.cmp
Created March 23, 2017 13:41
Lightning - Passing data down the component hierarchy via attributes and a change handler
<aura:component>
<aura:attribute name="childAttribute" type="String"/>
<aura:handler name="change" value="{!v.childAttribute}" action="{!c.onChildAttributeChange}"/>
<aura:component>
@pozil
pozil / SlackIntegration.cls
Last active November 5, 2020 15:14
Slack Post Message Invocable Action
public with sharing class SlackIntegration {
@future(callout=true)
public static void postMessage(String url, String message) {
Map<String, String> body = new Map<String, String>();
body.put('text', message);
String bodyJSON = JSON.Serialize(body);
HttpResponse response = sendRequest(url, 'POST', bodyJSON);
if (response.getStatusCode() != 200) {
throw new SlackException('Failed to post Slack Message ' + response.getBody());
@pozil
pozil / toaster.cmp
Last active January 16, 2021 10:18
Lightning - Displaying a system toast with a few lines of code
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
<div class="slds-m-around--xx-large slds-text-align--center">
<lightning:button label="Fire toast event" onclick="{! c.fireToastEvent }"/>
</div>
</aura:component>
@pozil
pozil / childComponentWithMethod.cmp
Last active March 13, 2021 20:21
Lightning - Passing data down the component hierarchy via a method
<aura:component >
<aura:method name="myMethod" action="{!c.executeMyMethod}">
<aura:attribute name="param1" type="String"/>
<aura:attribute name="param2" type="String"/>
</aura:method>
</aura:component>
@pozil
pozil / componentEvent.evt
Last active June 27, 2021 06:52
Lightning - Passing data up the component hierarchy via a component event
<aura:event type="COMPONENT">
<aura:attribute name="param" type="String"/>
</aura:event>
@pozil
pozil / async-basics.js
Created June 15, 2020 18:35
Asynchronous JavaScript Cheatsheet
function callbackExample() {
setTimeout(_callback, 1000);
console.log('This appears instantaneously');
}
function promiseExample() {
_longRunningOperation()
.then(() => {
console.log('This appears later');
@pozil
pozil / Build-WSC-JAR.md
Last active March 1, 2022 13:57
Build JAR files with WSC from WSDL files

This script lets you build JAR files with WSC from Salesforce WSDL files.

  1. Create a new directory and place this shell file in the directory.
  2. Obtain the Enterprise, Partner and Metadata WSDL files from your Salesforce org and place them in the folder.
  3. Run the build-jars.sh script.
  4. Grab the JAR files from the build directory.
@pozil
pozil / applicationEvent.evt
Last active March 5, 2022 15:01
Ligthning - Passing data up and around the component hierarchy via an application component
<aura:event type="APPLICATION">
<aura:attribute name="param" type="String"/>
</aura:event>