Skip to content

Instantly share code, notes, and snippets.


Chris Peterson capeterson

View GitHub Profile
<apex:page controller="Thingy">
This blank canvas with our controller applied lets us invoke the remoting methods from the dev console via:
<li><code>Thingy.regularLimits(function(response){console.log('Regular limits are:',response);});</code></li>
<li><code>Thingy.readOnlyLimits(function(response){console.log('Regular limits are:',response);});</code></li>
View map.cls
new Map<String,Object>{
'isBooleanType' => true,
'integerType' => 42,
'strings' => 'are stringy',
'this is where it gets tripy' => new Map<String,Object>{
'down the rabbit hole' => true,
'through the looking glass' => new Map<String,Object>{
'isThisEnoughToGetThePointAcross' => true
capeterson / gist:8326438
Created Jan 8, 2014
Apex List.addAll doesn't allow adding subclasses of the list's type properly.
View gist:8326438
List<SObject> l = new List<Sobject>();
l.addAll(new List<Contact>());
View MyControllerThing.cls
public with sharing class MyControllerThing{
public static MyWrapperThing getWrapper(){
MyWrapperThing result = new MyWrapperThing();
result.isSomething = true; = 'my wrapper obj';
result.version = 7;
return result;
View SublimeAstyleFormatter.sublime-settings
// NOTE: You should always edit options in user file, not this file.
// Auto format on file save
"autoformat_on_save": false,
// Please visit for more information
"options_default": {
// Default bracket style
// Can be either "allman", "ansi", "bsd", "break", "java", "attach", "kr", "k&r",
View gist:5879152
Iterator<Schema.sObjectField> i = fields.iterator();
result += + i.hasNext() ? ',' :'';
View TestCumulative.cls
private class TestCumulative{
private static void cumulativeTest(){
List<test_obj__c> objs = [select id from test_obj__c];
for(integer i = 0; i < 99; i++){
insert new test_obj__c();
System.debug(LoggingLevel.Error,'Finished the loop. About to die.');
objs = [select id from test_obj__c];
capeterson / Invoice_PostAction.trigger
Created Aug 22, 2012
FinancialForce Posting via checkbox
View Invoice_PostAction.trigger
trigger Invoice_PostAction on c2g__codaInvoice__c (after insert, after update) {
List<c2g.CODAAPICommon.Reference> toPost = new List<c2g.CODAAPICommon.Reference>();
if( document.Action_PostDocument__c == true ){
if(document.c2g__invoiceStatus__c != 'In Progress'){
System.debug(LoggingLevel.Warn,'Cannot post invoice, invoice is '+document.c2g__invoiceStatus__c);
c2g.CODAAPICommon.Reference ref = new c2g.CODAAPICommon.Reference(); =;
capeterson / gist:2955412
Created Jun 19, 2012
Dynamic SOQL + var binding
View gist:2955412
Set<String> names = new Set<String>{'Me','Myself','I'};
String query = 'SELECT id, name FROM User WHERE LastName IN :names';
List<sObject> objs = Database.query(query);
View TransactionTest.cls
private class TransactionTest{
static void test(){
String companyName = 'Company 1';
c2g__codaCompany__c company = [SELECT id, name FROM c2g__codaCompany__c WHERE name = :companyName];
User usr = new User(alias = 'standt',