Skip to content

Instantly share code, notes, and snippets.

Avatar

Ralph Callaway ralphcallaway

View GitHub Profile
View gist:af1eab92c5f83b1cf010
# Eclipse Project Files
com.salesforce.ide.core.prefs
salesforce.schema
Referenced Packages
.project
# Maven’s Mate Generated Files
apex-scripts
config
debug
View .gitignore
# Eclipse Project Files
com.salesforce.ide.core.prefs
salesforce.schema
Referenced Packages
.project
# Maven’s Mate Generated Files
apex-scripts
config
debug
@ralphcallaway
ralphcallaway / andyIsAwesome.r
Last active Aug 29, 2015
Submission by reference - June Salesforce Hack of the Month Submission
View andyIsAwesome.r
# /usr/bin/env copy
import http://andyinthecloud.com/2015/05/25/automating-org-setup-via-process-builder-and-metadata-api/
# no rules rulez!
@ralphcallaway
ralphcallaway / jQuery.component
Created Nov 9, 2012
Salesforce component for adding jQuery to a visualforce page
View jQuery.component
<apex:component >
<apex:attribute name="version"
type="String"
required="false"
description="Version of jquery. Defaults to 1.8.2. See https://developers.google.com/speed/libraries/devguide#jquery for a full list of available versions"
default="1.8.2"/>
<apex:attribute name="minified"
type="Boolean"
required="false"
@ralphcallaway
ralphcallaway / snippet.cls
Created Nov 9, 2012
Example of good exception handling for vf pages
View snippet.cls
public void functionWithDML() {
try {
insert listOfStuff;
} catch(DMLException e1) {
// do nothing here, page messages are automatically generated
} catch(Exception e2) {
// uh-oh, something else happened bad, better show it to the user
ApexPages.addMessage(
new ApexPages.Message(
ApexPages.Severity.ERROR
@ralphcallaway
ralphcallaway / AccountView.cls.java
Created Nov 21, 2012
Massive Internal View State (file extensions changed to assist with language auto-detection) See http://salesforce.stackexchange.com/questions/4537/how-to-reduce-a-large-internal-view-state-what-is-in-the-internal-view-state for related discussion
View AccountView.cls.java
/* NB: Class has been edited for brevity and may not compile initially */
public with sharing class AccountView {
// Input Properties
public String filter1 { get; set; }
public String grouping1 { get; set; }
public String grouping2 { get; set; }
// Select Lists
@ralphcallaway
ralphcallaway / AnotherWay.html
Created Nov 26, 2012
Alternative Implementation of Client Preferces
View AnotherWay.html
<apex:form >
<apex:pageBlock id="cp_module" rendered="{!detailKey = 'cp'}" title="Client Preferences" mode="edit">
<apex:pageblockButtons location="top">
<apex:commandButton value="Edit" rendered="{!NOT(clientPreferencesModification)}"
rerender="cp_module" status="LoadingStatusSpinner">
<apex:param assignTo="{!clientPreferencesModification}" value="true"/>
</apex:commandButton>
<apex:commandButton value="Save" rendered="{!clientPreferencesModification}"
action="{!saveClientPreferences}" status="LoadingStatusSpinner"
rerender="cp_module, im_counts"/>
View gist:5c3d06c3a0a44cb7108c
git config --global alias.ls 'log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate'
git config --global alias.ll 'log --pretty=format:%C(yellow)%h%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --numstat'
git config --global alias.lnc 'log --pretty=format:%h\ %s\ [%cn]'
git config --global alias.lds 'log --pretty=format:%C(yellow)%h\ %ad%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=short'
git config --global alias.ld 'log --pretty=format:%C(yellow)%h\ %ad%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=relative'
git config --global alias.le 'log --oneline --decorate'
git config --global alias.assume 'update-index --assume-unchanged'
git config --global alias.unassume 'update-index --no-assume-unchanged'
git config --global alias.assumed '!git ls-files -v | grep ^h | cut -c 3-'
git config --global alias.unassumeall '!git assumed | xargs git update-index --no-assume-unchanged'
View DynamicDMLHelper.cls
/*
Developer: Ralph Callaway <ralph@callawaycloudconsulting.com>
Description: Helper methods for dynamic DML
*/
public class DynamicDMLHelper {
public static Object recursiveGet(sObject record, String field) {
if(field.contains('.')) {
Integer firstPeriod = field.indexOf('.');
String nextObjectName = field.subString(0, firstPeriod);
@ralphcallaway
ralphcallaway / destructiveChanges.xml
Created Feb 25, 2013
Clean a new Salesforce dev org
View destructiveChanges.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>26.0</version>
</Package>
You can’t perform that action at this time.