Skip to content

Instantly share code, notes, and snippets.

View mshanemc's full-sized avatar

Shane McLaughlin mshanemc

View GitHub Profile
const progress = cli.progress({
format: `Chunk and upload ${this.flags.csvfile} | {bar} | {value}/{total} Chunks | ETA: {eta_formatted} | Elapsed: {duration_formatted}`,
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591'
});
progress.start();
@mshanemc
mshanemc / implementation.js
Last active July 4, 2019 01:23
wire service for off-core LWC that subscribes to a websocket
import wsSubscribe from '../../messages/wsWire/wsWire';
@wire(wsSubscribe, { uri: location.href.replace(/^http/, 'ws'), log: true, fake: true })
wiredResults({ error, data }) {
if (error) {
console.error('error from ws subscribe wire', error);
} else if (data) {
console.log(data);
this.results = data;
}
@mshanemc
mshanemc / deploying
Created January 17, 2018 16:41
working with an existing org in sfdx/vscode
//add this to your ~/.bash_profile
alias cdp="mkdir src;sfdx force:source:convert -d src;sfdx force:mdapi:deploy -w 5 -d src"
//then, when you want to deploy something to your default alias,
cdp
//The alias is setup so that you can add other flags on the end, like
cdp -u cg2 (deploy somewhere else)
cdp -c (just check that it would, but don't really deploy...useful for validation
@mshanemc
mshanemc / gist:f275b3440840fd41278b368e76b4955b
Created November 30, 2017 20:57
Moving data around in sfdx
# query the data like this gives you a json file
sfdx force:data:tree:export -q "select Bikes_Sold__c, Region__c from Dealer__c" -u cg1 -d data
# Problem: there's no query to CSV for bulk api upsert use. So we have to parse/convert that json.
# uses npm packages jq and json2csv
# convert to csv for bulk API
cat data/Dealer__c.json | jq .records | jq 'map(del(.attributes))' | json2csv -o data/Dealer__c.csv
@mshanemc
mshanemc / cleanScratchInfo.cls
Created November 29, 2017 23:24
cleaning up old scratch orgs from your dev hub with SFDX
// ScratchOrgInfo is an object in your dev hub
delete [select id from ScratchOrgInfo where Status = 'Deleted'];
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PATH=$PATH:~/tools
### making sublime command line editor
@mshanemc
mshanemc / CasePathGuidance.vfp
Created July 7, 2017 14:55
anythingpath in classic service cloud console
<apex:page standardController="Case" standardStylesheets="false" cache="false" showHeader="false" doctype="html-5.0">
<apex:includeLightning />
<apex:stylesheet value="/resource/anythingSLDS201/assets/styles/salesforce-lightning-design-system.css" />
<div id="lightning"/>
<script>
$Lightning.use("c:ServiceCasePath", function() {
$Lightning.createComponent("c:AnythingPath", {
recordId : "{!$CurrentPage.parameters.Id}",
sObjectName : "Case",
pathField : "Status"
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="imgUrl" type="string" required="true" default="https://farm8.staticflickr.com/7683/17369785125_efca0c32ec_o.jpg"/>
<img src="{!v.imgUrl}" />
</aura:component>
({
rebuildRecord : function(record, describe) {
let testobj = {
apiName: "Account",
fields : {
Name : {
displayValue:null,
value: "Burlington Textiles Corp of America"
}
@mshanemc
mshanemc / ExampleCallback.js
Last active February 25, 2021 13:54
Example of Lightning Components for handling Apex Callback Errors
action.setCallback(this, function(a){
if (a.getState() === "SUCCESS") {
//happy path stuff
} else if (a.getState() === "ERROR"){
var appEvent = $A.get("e.c:handleCallbackError");
appEvent.setParams({
"errors" : a.getError(),
"errorComponentName" : "someUniqueName"
});
appEvent.fire();