Skip to content

Instantly share code, notes, and snippets.

Map<Date, List<Task>> tasksbyweek = new Map<Date, List<Task>>();
for(Task t : tasks) {
Date weekstart = new Date();
if(tasksbyweek.get(weekstart)==null)
tasksbyweek.put(weekstart, new List<Task>());
tasksbyweek.get(weekstart).add(t);
}
Map<Id, LIST<Case>> caseMap = new Map<Id, LIST<Case>>();
@RestResource(urlMapping='/xxxx/*')
global with sharing class MyWLResource {
@HttpPost
global static void doPost(String accountid)
{
Account myaccount;
list <Opportunity> myresult;
try
{
myaccount = [select website from Account where id=:accountid];
<template>
<svg width="75" height="50" viewBox="0 0 256 180" version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
<g>
<path d="M106.553203,159.610976 C114.801129,168.204994 126.284107,173.534815 138.983873,173.534815 C155.865892,173.534815 170.594851,164.121105 178.438396,150.146262 C185.254593,153.191874 192.799405,154.885905 200.737669,154.885905 C231.186506,154.885905 255.871995,129.985475 255.871995,99.2706935 C255.871995,68.5522694 231.186506,43.651839 200.737669,43.651839 C197.021731,43.651839 193.389583,44.0234329 189.877657,44.7338328 C182.970383,32.4129469 169.807947,24.0885163 154.700107,24.0885163 C148.375726,24.0885163 142.393793,25.5493901 137.067615,28.1469039 C130.065621,11.6765534 113.751923,0.127999726 94.7387049,0.127999726 C74.9385822,0.127999726 58.0638501,12.6565411 51.5864595,30.2271008 C48.7557888,29.6259931 45.8231119,29.3126885 42.8139304,29.3126885 C19.23958,29.3126885 0.127998772,48.6209959 0.127998772,72.4430755 C0.127998772,88.40
@nickforce
nickforce / Jenkinsfile
Created September 24, 2020 15:03
Sample Jenkinsfile with Parameter based SFDX Deployment
#!groovy
pipeline {
agent any
options {
timeout(time: 5, unit: 'MINUTES') // timeout all agents on pipeline if not complete in 5 minutes or less.
}
parameters {
@nickforce
nickforce / ZendeskService.cls
Last active September 27, 2020 14:24
[TEMPLATE] Consuming Rest API in Apex (Zendesk)
// API we will consume
// https://developer.zendesk.com/rest_api/docs/support/users
// Create a named credential "Zendesk" with the following value "https://company.zendesk.com/api/v2"
// Substitute in your company and the correct version number
public class ZendeskService {
// create static variable for the endpoint we are going to leverage
private static String CUSTOMER_RESOURCE = '/users/create_or_update.json';
@isTest
private class ProcessContacts_Test {
@testSetup static void setup() {
// Create contact record
List<Contact> testContacts = new List<Contact>();
for(Integer i=0;i<1;i++) {
testContacts.add(new Contact(FirstName = 'GoogleBard'+i,
LastName = 'Test'));
}
insert testContacts;
@nickforce
nickforce / bard_prompt_salesforce_apex_trigger.md
Created June 5, 2023 02:31
Bard Prompt Salesforce Apex Trigger

I want you to act as a salesforce apex language interpreter. Write an apex trigger to process contacts before update and check if the field Email is being updated. If yes then update a field on that contact record Email_Updated_Date__c to the current date time

/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var twoSum = function(nums, target) {
let numObj = {}
for(i = 0; i < nums.length; i++) {
let other = target - nums[i];
if(numObj[other] !== undefined) {
@nickforce
nickforce / gist:f3bd1c370db22f305f78cd2225f75332
Created July 6, 2023 04:24
Array Prototype Last (leetcode)
Array.prototype.last = function() {
if(!this?.length) return -1;
return this.pop();
};
/**
* const arr = [1, 2, 3];
* arr.last(); // 3
*/
@nickforce
nickforce / gist:19b0efd3e8af2efded49f8ebe6880cdb
Created July 6, 2023 04:54
Palindrome Number (leetcode)
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function(x) {
if(x < 0) return false;
if(x == 0) return true;
if(x.toFixed(0).split('').reverse().join('')-0 == x) return true;
return false;
};