Skip to content

Instantly share code, notes, and snippets.

View mjgallag's full-sized avatar

Michael Gallagher mjgallag

  • San Francisco, California
View GitHub Profile
@mjgallag
mjgallag / wrapped.sh
Created January 30, 2018 22:14
wrapped
#!/bin/bash
echo $BASH_SOURCE $@ >> ~/Desktop/WRAPPED-LOG.txt
$BASH_SOURCE-wrapped $@
@mjgallag
mjgallag / SFDCSummer13RegressionIdsByIdsMapComparisonBug
Last active December 18, 2015 08:19
Salesforce Summer '13 (28.0) Regression - Map<Id, Id> Comparison Bug (Known Issue - https://success.salesforce.com/issues_view?id=a1p30000000SytdAAC)
final Map <Id, Id> identicalMapIdA = new Map<Id, Id>{'001E000000etpxTIAQ' => '001E000000etpxSIAQ'};
final Map <Id, Id> identicalMapIdB = new Map<Id, Id>{'001E000000etpxTIAQ' => '001E000000etpxSIAQ'};
final Map<String, String> identicalMapStringA = new Map<String, String>{};
final Map<String, String> identicalMapStringB = new Map<String, String>{};
for (Id keyId : identicalMapIdA.keySet()) identicalMapStringA.put(keyId, identicalMapIdA.get(keyId));
for (Id keyId : identicalMapIdB.keySet()) identicalMapStringB.put(keyId, identicalMapIdB.get(keyId));
// Workaround is to put Map<Id, Id> into Map<String, String>
System.assertEquals(identicalMapStringA, identicalMapStringB);
var HasSession;
function hasSession(onTrue, onFalse) {
var script = document.createElement('script');
script.src = 'https://na1.salesforce.com/apex/HasSession';
script.onload = function() {
document.head.removeChild(script);
if (HasSession)
onTrue();
else
@mjgallag
mjgallag / RemoteAction.js
Last active October 11, 2015 06:08
Sencha Touch/Ext JS Force.com Remote Action Proxy
Ext.define('Force.proxy.RemoteAction', {
extend: 'Ext.data.proxy.Direct',
alias: 'proxy.remoteaction',
requires: ['Ext.direct.RemotingMethod'],
updateDirectFn: function(directFn) {
directFn.directCfg.method.getArgs = Ext.create('Ext.direct.RemotingMethod').getArgs;
directFn.directCfg.method.getLen = function() {return this.len;};
directFn.directCfg.method.getOrdered = function() {return true;};
},
createRequestCallback: function(request, operation, callback, scope) {
@mjgallag
mjgallag / gist:2896541
Created June 8, 2012 16:15
BUG FIXED! Type.forName Specific SObject List Summer '12 (25.0) Week of June 4th Patch Regression Bug
// Per Rich Unger should be fixed in Week of June 11th Patch - https://twitter.com/rich_unger/status/210844950722641920
System.assert(Type.forName('List<' + Account.SObjectType.getDescribe().getName() + '>').newInstance() instanceOf Account[]);
// Workaround (slightly less efficient)
static Map<String, SObject[]> listInstancesBySObjectNames = new Map<String, SObject[]>{};
static SObject[] newListInstance(SObjectType sObjectType) {
if (!listInstancesBySObjectNames.containsKey(sObjectType.getDescribe().getName()))
listInstancesBySObjectNames.put(sObjectType.getDescribe().getName(),
Database.query('SELECT Id FROM ' + sObjectType.getDescribe().getName() + ' WHERE Id = null'));
@mjgallag
mjgallag / SeeAllDataCustomSettingTests.cls
Created March 1, 2012 18:19
BUG FIXED! See All Data Custom Setting Tests
@isTest class SeeAllDataCustomSettingTests {
@isTest (SeeAllData=true) static void trueSeeAllDataCustomSettingTest() {
final SeeAllDataCustomSetting__c seeAllDataCustomSetting = new SeeAllDataCustomSetting__c(Name = 'Name');
System.assertEquals(0, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(0, SeeAllDataCustomSetting__c.getAll().size());
insert seeAllDataCustomSetting;
System.assertEquals(1, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(1, SeeAllDataCustomSetting__c.getAll().size());
delete seeAllDataCustomSetting;
@mjgallag
mjgallag / BatchJob.cls
Created February 24, 2012 17:32
Scheduled Batch Job Test Example
global class BatchJob implements Database.Batchable<Account> {
global Account[] start(Database.BatchableContext batchableContext) {return new Account[]{};}
global void execute(Database.BatchableContext batchableContext, Account[] accounts) {}
global void finish(Database.BatchableContext batchableContext) {}
}
@mjgallag
mjgallag / SystemAbortJobMixedDmlBug.cls
Created February 21, 2012 15:19
System Abort Job Mixed Dml Bug Tests
global class SystemAbortJobMixedDmlBug implements Schedulable {
global void execute(SchedulableContext schedulableContext) {}
}