Skip to content

Instantly share code, notes, and snippets.

View FishOfPrey's full-sized avatar
💭
🦈

Daniel Ballinger FishOfPrey

💭
🦈
View GitHub Profile
@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('')) {
@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());
}
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() - ';
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;

v43.0 - Summer '18

Database

Database-Info

  • SOQL_EXECUTE_BEGIN
  • SOQL_EXECUTE_END
  • SOSL_EXECUTE_BEGIN
  • SOSL_EXECUTE_END
  • QUERY_MORE_ITERATIONS
  • DML_BEGIN
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];
}
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';
@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
});
//Generated by FuseIT WSDL2Apex (http://www.fuseit.com/Solutions/SFDC-Explorer/Help-WSDL-Parser.aspx)
public class ebayApisEnhanceddatatypes {
public class EnhancedCancelRecoupRequestDetailsType {
private String[] apex_schema_type_info = new String[]{'urn:ebay:apis:EnhancedDataTypes','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class EnhancedCheckoutDataType {
private String[] apex_schema_type_info = new String[]{'urn:ebay:apis:EnhancedDataTypes','true','false'};
private String[] field_order_type_info = new String[]{};
//Generated by FuseIT WSDL2Apex (http://www.fuseit.com/Solutions/SFDC-Explorer/Help-WSDL-Parser.aspx)
//Warning: '<xsd:any>' element type has been changed to dataType List<DOM.XmlNode> called anyElement
public class ebayApisEblbasecomponents {
//Warning: '<xsd:any>' element type has been changed to dataType List<DOM.XmlNode> called anyElement
public class AbstractRequestType {
public String[] DetailLevel;
public String ErrorLanguage;
public String Version;