Skip to content

Instantly share code, notes, and snippets.

@PezzerDev
PezzerDev / Mass-Deactivate Salesforce Users
Last active January 26, 2021 21:20
[Mass-Deactivate Salesforce Users] Deactivates all users that aren't assigned one of the profiles definied in a set #salesforce #apex
// Profiles to leave enabled
Set<String> excludedProfiles = new Set<String> {
'System Administrator',
'Integration System Administrator',
'AccessTSC Digital Profile',
'TriState Onboarding Team',
'Tristate Administrator'
};
List<User> usersToUpdate = new List<User>();
@PezzerDev
PezzerDev / DailyLeadProcessor.cls
Created February 2, 2019 07:58
[Scheduled Apex] Example of a schedulable Apex job #salesforce #apex
global class DailyLeadProcessor implements Schedulable {
global void execute(SchedulableContext context) {
List<Lead> leads = [Select Id, LeadSource from Lead where LeadSource = null limit 200];
for (Lead currentLead : leads) {
currentLead.LeadSource = 'Dreamforce';
}
update leads;
}
}
@PezzerDev
PezzerDev / get-translation.js
Last active February 2, 2019 07:00
[CSS Translation Extract] Function to extract translation values from CSS transform value #css
/**
* Extracts the translation values from a given CSS transformation.
* @param {string} transformValue The CSS transform string from which the translation values will be extracted (e.g. ‘translate3d(10px, 25px, 30px)’)
* @returns {object} translation values found in the given transform (e.g. { x: 10, y: 25, z: 30 })
*/
function getTranslation(transformValue) {
var matches = transformValue.match(/translate(3d)*\((\d+.?\d*(px)?),\s*(\d+.?\d*(px)?)(,\s*(\d+.?\d*(px)?))?\)/);
if (matches) {
return {
x: parseInt(matches[2]) || 0,
@PezzerDev
PezzerDev / download-embedded-vimeo-video.js
Last active August 28, 2021 16:31
[Vimeo Download] Downloads an embedded Vimeo video #browser
downloadEmbededVideos();
/**
* Finds and downloads all embeded Vimeo videos.
*/
function downloadEmbededVideos() {
// Find Vimeo embed frame
var embedFrames = document.querySelectorAll('iframe[src*="player.vimeo.com"]');