Skip to content

Instantly share code, notes, and snippets.

View douglascayers's full-sized avatar

Doug Ayers douglascayers

View GitHub Profile
@peterknolle
peterknolle / CORS_MessageService.cls
Last active August 29, 2015 14:05
Accessing Apex REST from Site.com
@RestResource(urlMapping='/v1.0/messages')
global class MessageService {
@HttpGet
global static void getMessages() {
// buildMessages gets FeedItems
List<Message> messages = buildMessages();
RestResponse res = RestContext.response;
@keirbowden
keirbowden / gist:6044766
Created July 20, 2013 11:55
Visualforce page for a Publisher action that posts case information to an account feed.
<apex:page standardcontroller="Account" extensions="ChatterAccountSnapshotExt">
<apex:form >
<apex:pageMessages />
<apex:pageBlock title="Service Snapshot">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Post to Feed" action="{!post}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Closed Cases" />
@cdcarter
cdcarter / QuickData.java
Last active May 29, 2016 04:31
QuickData
public class QuickData {
/* QuickData inserts your Mockaroo Schema, no questions asked. Remote Site needed.
* USAGE: QuickData.createRecords('MOCKAROOAPIKEY','20689c00',20,List<Lead>.class);
* Creates 20 leads using the schema at https://www.mockaroo.com/20689c00 */
public static List<SObject> createRecords(String a, String s, Integer c, Type t) {
String fmtStr = 'https://www.mockaroo.com/{1}/download?count={2}&key={0}';
List<String> reqDetails = new List<String>{a,s,String.valueOf(c)};
string requestString = String.format(fmtStr,reqDetails);
HttpRequest req = new HttpRequest();
req.setEndpoint(requestString);
@madmax983
madmax983 / ltngDataServiceFun.cmp
Last active October 28, 2016 09:18
Fun with Lightning Data Service
<aura:component >
<aura:attribute name="recordIds"
type="List"
access="public"
description="An array of Ids"/>
<aura:attribute name="records"
type="Map"
description="The records!"
default="{}"/>
<aura:attribute name="errors"
@mdhorine
mdhorine / Email Affiliated Contacts
Created January 28, 2015 13:50
Email Affiliated Contacts button for use with Salesforce NPSP
/**************************************************
/ Button: Email Affiliated Contacts /
/ Author: Matt Horine /
/ Client: Step Up to Serve /
/ Date: 28 January 2015 /
/ /
/ Description: Button on Affiliated Contacts /
/ related list to allow selection and email of /
/ affiliated contacts from the Account Page in /
/ the same way the Send an Email button allows /
@jeffdonthemic
jeffdonthemic / ChatterUtils
Last active April 1, 2019 00:21
Simple Class to add Salesforce Chatter posts with links, urls and mentions.
public with sharing class ChatterUtils {
// makes a simple chatter text post to the specified user from the running user
public static void simpleTextPost(Id userId, String postText) {
ConnectApi.FeedType feedType = ConnectApi.FeedType.UserProfile;
ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();
messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
@wadewegner
wadewegner / wadewegner.zsh-theme
Last active February 11, 2020 00:06
My ZSH theme that includes some stuff for SFDX
# wadewegner.zsh-theme
prompt_fn() {
config="$(cat .sfdx/sfdx-config.json 2> /dev/null)";
globalConfig="$(cat ~/.sfdx/sfdx-config.json)";
defaultusername="$(echo ${config} | jq -r .defaultusername)"
defaultdevhubusername="$(echo ${config} | jq -r .defaultdevhubusername)"
globaldefaultusername="$(echo ${globalConfig} | jq -r .defaultusername)"
@douglascayers
douglascayers / UploadFile.html
Last active April 18, 2021 14:48
JavaScript snippet for uploading fille to Salesforce as ContentVersion and sharing to record as ContentDocumentLink via jsforce and jquery.
<apex:page>
<head>
<script src="{!$Resource.jquery224}"></script> <!-- https://jquery.com/ -->
<script src="{!$Resource.jsforce170}"></script> <!-- https://jsforce.github.io/ -->
<script>$j = jQuery.noConflict();</script>
</head>
<body>
<form>
@davejlong
davejlong / ant-git.xml
Created March 17, 2011 15:30
A simple ant script that will commit and push to a git repo.
<?xml version="1.0"?>
<project name="Demo" default="version" basedir=".">
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
@mshanemc
mshanemc / cleanScratchInfo.cls
Created November 29, 2017 23:24
cleaning up old scratch orgs from your dev hub with SFDX
// ScratchOrgInfo is an object in your dev hub
delete [select id from ScratchOrgInfo where Status = 'Deleted'];