Skip to content

Instantly share code, notes, and snippets.

View dschach's full-sized avatar

David Schach dschach

View GitHub Profile
@jongpie
jongpie / UniqueIdBenchmarkingTests.cls
Created January 30, 2024 00:23
Apex - Unique ID Generation Benchmarks
@IsTest
private class UniqueIdBenchmarkingTests {
@IsTest
static void ulidBenchmark() {
Long ulidStartTime = System.now().getTime();
System.debug('ULID generation start: ' + System.now().getTime());
for (Integer i = 0; i < 1000; i++) {
ULID.generate();
}
Long ulidStopTime = System.now().getTime();
@peterknolle
peterknolle / preChat.html
Created January 25, 2014 23:15
Live Agent Pre-Chat API in Pre-Chat Form for Service Cloud
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
(function() {
function handlePageLoad() {
var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
document.getElementById('prechatForm').setAttribute('action',
decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
}
@metadaddy
metadaddy / MessageToTask.cls
Last active December 23, 2015 00:49
Visualforce TwiML page and Apex REST method for transcribing a voice message in Twilio and saving is as an Activity to a Lead.
@RestResource(urlMapping='/messagetotask')
global class MessageToTask {
@HttpPost
global static void incomingMessage() {
String expectedSignature =
RestContext.request.headers.get('X-Twilio-Signature');
String url = 'https://' + RestContext.request.headers.get('Host') +
'/services/apexrest' + RestContext.request.requestURI;
Map <String, String> params = RestContext.request.params;
@joshbirk
joshbirk / geocontact.page
Created October 8, 2012 21:27
Geolocation
<apex:page StandardController="Contact" showHeader="true" sidebar="false">
<script>
var pos = {};
function success(position) {
pos = position.coords;
console.log(pos);
}
function error(msg) {