Skip to content

Instantly share code, notes, and snippets.

View cdcarter's full-sized avatar

Christian Carter cdcarter

View GitHub Profile
@cdcarter
cdcarter / stg_header.jsf
Created November 1, 2015 20:07
slds breadcrumbs weird
<apex:page standardStylesheets="false" applyBodyTag="false" docType="html-5.0">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<apex:stylesheet value="{!URLFOR($Resource.SLDS0101, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
<body>
<apex:form styleClass="slds">
<div class="slds-page-header" role="banner">
<nav class="slds-m-bottom--xx-small" role="navigation">
<p id="bread-crumb-label" class="slds-assistive-text">You are here:</p>
<ol class="slds-breadcrumb slds-list--horizontal" aria-labelledby="bread-crumb-label">
<li class="slds-list__item slds-text-heading--label"><a href="">Volunteers Settings</a></li>
@cdcarter
cdcarter / .gitignore
Created December 1, 2015 21:37
salesforce gitignore
config/
*.sublime-*
.gitignore
apex-scripts/*
debug/
@cdcarter
cdcarter / swagger.json
Created January 4, 2016 22:18
pm-swagger
{
"swagger": "2.0",
"info": {
"title": "Public Metrics",
"description": "Public Metrics creates public facing APIs and dashboards for key metrics tracked in Salesforce with a declarative and easy to set up process. This document defines the public API generated by the package.",
"version": "0.0.1"
},
"host": "public-metrics-1-developer-edition.na22.force.com",
"schemes": [
"https"
@cdcarter
cdcarter / slackbot.java
Last active January 16, 2016 18:01
NPSP-Slack-Bot
/**
* @author Christian Carter (@cdcarter)
* @date Jan 2016
*
*
* @description A simple NPSP Slack slashcommand to show you the number of new donations today!
* This is a "my first slackbot" condition class, it doesn't check auth tokens, it doesn't check which
* command was called, but it'll get us started!
*/
{"response_type":"ephemeral","attachments":[{"title":"Annual Campaign Statstics","fields":[{"title":"Donors","value":"342"},{"title":"Donations",value="371"},{"title":"Amount","value","$37,040"},{"title":"Amount Remaining","value":"$12,960"}]}]}
@cdcarter
cdcarter / song.txt
Created January 23, 2016 21:56
50 ways to call your apex
"The problem is all inside your head" Marc said to me
"The answer is easy if you take it logically
I'd like to help you in your struggle to be free
There must be fifty ways to call your Apex"
Parker said "It's really not my habit to intrude
Furthermore, I hope my meaning won't be lost or misconstrued
But I'll repeat myself at the risk of being crude
There must be fifty ways to call your Apex
Fifty ways to call your Apex"
@cdcarter
cdcarter / Donor Analysis Formula
Created February 19, 2016 16:41
donor analysis formula
IF( npo02__TotalOppAmount__c = 0, "Non-Donor",
IF( npo02__OppAmountThisYear__c > 0 && npo02__OppAmountThisYear__c = npo02__TotalOppAmount__c, "New",
IF( npo02__OppAmountThisYear__c > npo02__OppAmountLastYear__c && npo02__OppAmountLastYear__c != 0, "Increased",
IF( npo02__OppAmountThisYear__c < npo02__OppAmountLastYear__c && npo02__OppAmountThisYear__c != 0, "Decreased",
IF( (npo02__OppAmountLastYear__c != 0 || (npo02__OppAmountLastYear__c = 0 && npo02__TotalOppAmount__c != 0)) && npo02__OppAmountThisYear__c = 0, "Lapsed",
IF( npo02__OppAmountThisYear__c = npo02__OppAmountLastYear__c && npo02__OppAmountLastYear__c != 0, "Renewed",
IF( npo02__OppAmountThisYear__c > 0 && npo02__OppAmountLastYear__c = 0 && npo02__TotalOppAmount__c > 0 && (npo02__TotalOppAmount__c != npo02__OppAmountThisYear__c), "Recovered","Error"
)
)
)
@cdcarter
cdcarter / deactivateTrigger.apxc
Created February 27, 2016 22:45
deactivate-relationship-trigger
npsp__Trigger_Handler__c th = [SELECT Id FROM npsp__Trigger_Handler__c WHERE npsp__Class__c = 'REL_Relationships_TDTM' LIMIT 1];
th.npsp__Active__c = false;
update th;
@cdcarter
cdcarter / superbatch.java
Last active March 12, 2016 21:39
SuperBatch
// a batch class for every context, by @cdcarter
public class SuperBatch implements Database.Batchable<SObject>, Schedulable {
// from anon apex, `SuperBatch.startBatch()` starts the job with batch size 100
public static void startBatch() { (new SuperBatch()).doIt(); }
public SuperBatch() {}
public void doIt() { Database.executeBatch(this,100); }
/* create a visualforce page below, and a list button
* add the list button to list views to ondemand run the batch (size 100)
* <apex:page standardController="SObject" recordSetVar="sobj"
@cdcarter
cdcarter / debug.jsp
Last active May 7, 2016 23:16
Visualforce Debug Pane
<!-- the devconsole parameter is automatically set when a page is in refresh/preview mode from Developer Console
which allows us to only display our custom viewstate debug pane when we're in Developer Mode! -->
<apex:pageBlockSection id="debug" title="Debugging" rendered="{!$CurrentPage.parameters.core.apexpages.request.devconsole == '1'}">
<apex:pageBlockTable value="{!clients}" var="client">
<apex:column value="{!client.Name}"/>
<apex:column value="{!client.Enrollment_Status__c}"/>
<apex:column value="{!client.Referral_Agency__c}"/>
<apex:column >
<apex:facet name="header">Saved</apex:facet>
<apex:outputPanel rendered="{!NOT(ISBLANK(client.Id))}" layout="block"><input disabled="true" type="checkbox" checked="true"/></apex:outputPanel>