Skip to content

Instantly share code, notes, and snippets.

View FishOfPrey's full-sized avatar
💭
🦈

Daniel Ballinger FishOfPrey

💭
🦈
View GitHub Profile
@FishOfPrey
FishOfPrey / DeveloperConsoleOpenLogById.js
Last active August 30, 2018 22:03
Have the Salesforce Developer Console open a debug log by ID
var logId = "07Lc000001OiO8GEAV";
apex.ide.Viewer.open({
id: "l-" + logId,
logId: logId,
Name: "Log " + logId,
xtype: "logviewer",
rawLogSize: 1
});
public virtual class EinsteinVision_HttpBodyPart {
//...
/**
* Write a key-value pair to the form's body for a blob.
*/
public static string WriteBlobBodyParameter(string key, string file64, string filename, string mimeType) {
string contentDisposition = 'Content-Disposition: form-data; name="' + key + '"; filename="'+filename+'"';
string contentDispositionCrLf = contentDisposition + '\r\n';
List<boolean> lockers = new List<boolean>();
for(integer s = 0; s< 1000; s++){
for (integer i = s; i < 1000; i += (s+1)){
if(s == 0) {
// First Student Opens every locker
lockers.add(true);
} else {
// nth student toggles every nth locker
lockers[i] = !lockers[i];
}

v43.0 - Summer '18

Database

Database-Info

  • SOQL_EXECUTE_BEGIN
  • SOQL_EXECUTE_END
  • SOSL_EXECUTE_BEGIN
  • SOSL_EXECUTE_END
  • QUERY_MORE_ITERATIONS
  • DML_BEGIN
public class FishOfPreySettings {
// Normally during testing we want to limit the custom setting to a testing user.
// However, this won't work with anything that depends on $Setup.FishOfPrey_Settings__c.showTheThing__c in a validation rule
// As it will appear as null
private static boolean useTestingUpdateUserCustomSetting {
get {
if(useTestingUpdateUserCustomSetting == null) {
return true;
}
return useTestingUpdateUserCustomSetting;
public class FishOfPreySettingsMockProvider implements System.StubProvider {
private FishOfPrey_Settings__c testingSettings;
public Object handleMethodCall(Object stubbedObject, String stubbedMethodName,
Type returnType, List<Type> listOfParamTypes, List<String> listOfParamNames,
List<Object> listOfArgs) {
string methodName = 'FishOfPreySettingsMockProvider.handleMethodCall() - ';
@IsTest
public class FishOfPreySettings_Test {
@IsTest
public static void showTheThingDefault() {
boolean showTheThing = FishOfPreySettings.Instance.showTheThing;
System.assertNotEquals(null, showTheThing);
System.assertEquals(0, Limits.getQueries());
System.assertEquals(0, Limits.getDmlStatements());
}
@FishOfPrey
FishOfPrey / FindApexStringHashCollisions.apex
Created July 10, 2018 22:55
Find hash collisions in Apex for two character strings.
Map<Integer, List<String>> hashMap = new Map<Integer, List<String>>();
String str = 'abcdefghijklmnopqrstuvwxyz';
str += str.toUpperCase();
Set<integer> collisions = new Set<Integer>();
for (string c1 : str.split('')) {
for (string c2 : str.split('')) {
//Generated by FuseIT WSDL2Apex (http://www.fuseit.com/Solutions/SFDC-Explorer/Help-WSDL-Parser.aspx)
// Warning: DataStorageItem - All the XmlSchemaElements in '<xsd:choice>' element are added as members of the class. Choice Members: CreditCardData DE_DirectDebitData OrderId Function
// Warning: Action_element - All the XmlSchemaElements in '<xsd:choice>' element are added as members of the class. Choice Members: InitiateClearing InquiryCardInformation InquiryOrder InquiryTransaction StoreHostedData RecurringPayment Validate GetExternalTransactionStatus GetExternalConsumerInformation SendEMailNotification GetLastOrders GetLastTransactions ManageProducts ManageProductStock RequestCardRateForDCC RequestMerchantRateForDynamicPricing CreatePaymentURL
// Warning: InquiryTransaction_element - All the XmlSchemaElements in '<xsd:choice>' element are added as members of the class. Choice Members: OrderId TDate IpgTransactionId MerchantTransactionId
// Warning: Validate_element - All the XmlSchemaElements in '<xsd:cho
// MIT License
//
// Copyright 2017 Electric Imp
//
// SPDX-License-Identifier: MIT
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell