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
@fserb
fserb / package.json
Created July 2, 2021 04:18
Build lit into a single javascript file
{
"name": "lit",
"license": "MIT",
"scripts": {
"build": "npm install && rollup -c"
},
"dependencies": {
"@rollup/plugin-node-resolve": "^13.0.0",
"lit": "^2.0.0-rc.2",
"rollup": "^2.52.7"
@rupeshtiwari
rupeshtiwari / remove console log webpack.md
Last active September 21, 2021 12:54
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 / WebComponent.js
Last active June 9, 2022 04:49
Web Component boilerplate for a native web-component (v1 spec)
/*
* Use tag to import via es6 module (html import deprecated in v1 spec :/ )
* <script type="module" src="../components/web-component/web-component.js"></script>
*/
'use strict()'
const template = document.createElement('template')
template.innerHTML = /*html*/`
<style>
.card {
@sholloway
sholloway / SOQL Queries.sql
Last active January 22, 2024 14:43
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
@douglascayers
douglascayers / UploadFile.html
Last active April 18, 2021 14:48
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>
@jmshal
jmshal / atob.js
Last active December 13, 2022 15:54
Node.js ponyfill for atob and btoa encoding functions
module.exports = function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
<html>
<head>
<title>API Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var accessToken = "<your agent's client access token>";
var baseUrl = "https://api.api.ai/v1/";
@eteeselink
eteeselink / delay.js
Created November 13, 2015 13:55
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();
@brianmfear
brianmfear / AWS.cls
Last active February 8, 2023 00:14
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;
@chinchang
chinchang / xmlToJson.js
Last active September 7, 2023 02:39
Function to convert XML to JSON
/**
* Changes XML to JSON
* Modified version from here: http://davidwalsh.name/convert-xml-json
* @param {string} xml XML DOM tree
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) {