Skip to content

Instantly share code, notes, and snippets.

View jsmithdev's full-sized avatar
🏗️
building things

Jamie Smith jsmithdev

🏗️
building things
View GitHub Profile
@jsmithdev
jsmithdev / slds-grid-common.html
Created November 22, 2020 22:34
slds grid commonly used / simple
<div class="slds-grid slds-gutters">
<div class="slds-col">
<span>1</span>
</div>
<div class="slds-col">
<span>2</span>
</div>
@jsmithdev
jsmithdev / lwc-toast.js
Last active August 25, 2020 19:16
Toast util JS file for LWC's
import { ShowToastEvent } from 'lightning/platformShowToastEvent'
/**
*
* @param {String} str - String to capitalize the first character
* @returns {String} String with first character capitalized
*/
export function capitalize(str){
return str.charAt(0).toUpperCase() + str.slice(1)
@jsmithdev
jsmithdev / RestService.cls
Created June 26, 2020 19:43
Apex REST Example
@RestResource(urlMapping='/RestService/*')
global with sharing class RestService {
@HttpPost
global static String wookiehookie(String data) {
System.debug(data);
return '"had_data": "' +data+ '"';
}
@jsmithdev
jsmithdev / UploadFile.html
Created June 24, 2020 06:39 — forked from douglascayers/UploadFile.html
JavaScript snippet for uploading fille to Salesforce as ContentVersion and sharing to record as ContentDocumentLink via jsforce and jquery.
<apex:page>
<head>
<script src="{!$Resource.jquery224}"></script> <!-- https://jquery.com/ -->
<script src="{!$Resource.jsforce170}"></script> <!-- https://jsforce.github.io/ -->
<script>$j = jQuery.noConflict();</script>
</head>
<body>
<form>
@jsmithdev
jsmithdev / atob.js
Last active June 23, 2020 19:39 — forked from jmshal/atob.js
Node.js ponyfill for atob and btoa encoding functions
const atob = a => Buffer.from(a, 'base64').toString('binary')
module.exports = { atob }
@jsmithdev
jsmithdev / delay.js
Created June 20, 2020 00:21 — forked from eteeselink/delay.js
ES7 async/await version of setTimeout
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function something() {
console.log("this might take some time....");
await delay(5000);
console.log("done!")
}
something();
@jsmithdev
jsmithdev / IsCommunity_APEX.cls
Created May 29, 2020 17:49
find out if lwc etc is running in commmunity
@AuraEnabled
public static Boolean isCommunity(){
Boolean isCommunity = false;
String host = URL.getSalesforceBaseUrl().toExternalForm();
String uri = host.replace('https://', '');
for(Domain d : [SELECT Domain FROM Domain]){
if(d.Domain == uri){
@jsmithdev
jsmithdev / AWS.cls
Created May 17, 2020 01:26 — forked from brianmfear/AWS.cls
Abstract AWS implementation in Apex Code
/*
// Example implementation as follows:
public class AWSS3_GetService extends AWS {
public override void init() {
endpoint = new Url('https://s3.amazonaws.com/');
resource = '/';
region = 'us-east-1';
service = 's3';
accessKey = 'my-key-here';
method = HttpMethod.XGET;
@jsmithdev
jsmithdev / settings.json
Created May 8, 2020 16:15
vs code + salesforce: If you pull down whole org metadata and only want search to find only references in code
{
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/.sfdx": true,
"**/.history": true,
},
"search.include": {
"**/apex": true,
"**/aura": true,
@jsmithdev
jsmithdev / LWC_META.js-meta.xml
Created April 28, 2020 01:27
Common metadata for LWCs
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>48.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Component Name</masterLabel>
<description>Component to do something</description>
<targets>