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 / SOQL Queries.sql
Created January 24, 2023 02:43 — forked from sholloway/SOQL Queries.sql
Useful SOQL queries for exploring a Salesforce org.
--------------------------------------------------------------------
-- Queries related to distribution of metadata.
-- Find the number of users per profile.
SELECT count(id), Profile.name
FROM User
WHERE User.IsActive = true
GROUP BY Profile.name
-- Find the distribution of Apex classes per namespace.
select count(id), NameSpacePrefix
@jsmithdev
jsmithdev / remove console log webpack.md
Created September 21, 2021 12:54 — forked from rupeshtiwari/remove console log webpack.md
remove console.log & comments from code webpack

Remove Console Log From Prod Bundle using Webpack

This will help you to remove console.log and comments from typescript or javascript files using webpack 4

Install uglifyjs-webpack-plugin

webpack remove console.log

npm i npm install uglifyjs-webpack-plugin --save-dev

create bs-module-app\webpack\webpack-optimization.config.js

@jsmithdev
jsmithdev / xmlToJson.js
Last active September 1, 2021 03:47 — forked from chinchang/xmlToJson.js
Function to convert XML to JSON
/*
Usage:
1. If you have an XML file URL:
const response = await fetch('file_url');
const xmlString = await response.text();
var XmlNode = new DOMParser().parseFromString(xmlString, 'text/xml');
xmlToJson(XmlNode);
@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 / 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 / ContentDocumentTest.java
Created June 7, 2019 03:02 — forked from xgeek-net/ContentDocumentTest.java
ContentDocumentTest Apex TestClass
@isTest
private class ContentDocumentTest {
private static testMethod void testCreate() {
ContentVersion contentVersion_1 = new ContentVersion(
Title = 'Penguins',
PathOnClient = 'Penguins.jpg',
VersionData = Blob.valueOf('Test Content')
IsMajorVersion = true
);
insert contentVersion_1;
import { LightningElement } from 'lwc';
import moment from '@salesforce/resourceUrl/moment';
import { loadScript } from 'lightning/platformResourceLoader';
export default class MomentStuffs extends LightningElement {
renderedCallback(){
Promise.all([
loadScript(this, moment + '/moment.js')
]).then(() => {
@jsmithdev
jsmithdev / generatepkgXML.sh
Created April 4, 2019 22:14 — forked from msrivastav13/generatepkgXML.sh
Generates package.xml from the Unmanaged container/Managed Package or Changesets
#!/bin/bash
if [ $# -lt 1 ]
then
echo Usage: generatepkgXML.sh orgalias packageName
exit
fi
## Retrieve the PackageXML from Unmanaged Container