Skip to content

Instantly share code, notes, and snippets.

Currently being awesome

Jeff Douglas jeffdonthemic

Currently being awesome
Block or report user

Report or block jeffdonthemic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jeffdonthemic / apex-crud-fls.txt
Last active Oct 9, 2019
Simple Apex Controller with CRUD and FLS
View apex-crud-fls.txt
This simple controller (without CRUD and FLS) ...
public with sharing class AccountController {
public static List<Account> findAll() {
return [SELECT id, name, Location__Latitude__s, Location__Longitude__s
FROM Account
WHERE Location__Latitude__s != NULL AND Location__Longitude__s != NULL
LIMIT 50];
jeffdonthemic / index.js
Last active Oct 4, 2019
Lambda function to commit code to github. See blog post for more details.
View index.js
var githubapi = require("github"),
async = require("async"),
AWS = require('aws-sdk'),
secrets = require('./secrets.js');
// the 'handler' that lambda calls to execute our code
exports.handler = function(event, context) {
// config the sdk with our credentials
jeffdonthemic / app.rb
Last active Sep 3, 2019
Refresh Token from Salesforce
View app.rb
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
jeffdonthemic / httparty.rb
Last active Aug 30, 2019
HTTParty Examples
View httparty.rb
options = { :body =>
{ :username => 'my',
:password => 'password'
results ="", options)
## example for post with papertrail and basic auth
View Create Category Items
// create the association object with the final data
associations = {
"elements": elements
// create all of the associations
url: ''+process.env.CLOVER_MERCHANT_ID+'/category_items',
method: 'POST',
headers: {
jeffdonthemic / app.js
Created Jul 7, 2014
Simple example
View app.js
var http = require('http'),
fs = require('fs'),
// NEVER use a Sync function except at start-up!
index = fs.readFileSync(__dirname + '/index.html');
// Send index.html to all requests
var app = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
jeffdonthemic / UploadAttachment
Created May 30, 2014
Visualforce Page for customizing Attachments. See UploadAttachmentController.
View UploadAttachment
<apex:page standardController="Contact" tabStyle="Contact" extensions="UploadAttachmentController">
<apex:sectionHeader title="{!Contact.Name}" subtitle="Attach File"/>
<apex:form id="form_Upload">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Back to {!Contact.Name}"/>
<apex:commandButton action="{!back}" value="Cancel"/>
jeffdonthemic / ChatterUtils
Last active Apr 1, 2019
Simple Class to add Salesforce Chatter posts with links, urls and mentions.
View ChatterUtils
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>();
View org_connection.js
const jsforce = require('jsforce');
const jwt = require("salesforce-jwt-bearer-token-flow");
// create the connection to the org
let conn = new jsforce.Connection();
// load the private key for the token
let privateKey = require('fs').readFileSync('./server.key', 'utf8');
View ContactListViewComponent.component
<apex:component controller="ContactListViewController">
<apex:attribute name="listViewName" type="String" required="true"
description="The name of the listview." assignTo="{!listName}"/>
<apex:enhancedList height="400" rowsPerPage="25" id="ContactList"
listId="{!listId}" rendered="{!listId != null}" />
<apex:outputText rendered="{!listId == null}" value="Could not find requewed ListView: '{!listName}'. Please contact your administrator."/>
You can’t perform that action at this time.