Skip to content

Instantly share code, notes, and snippets.

💭
Currently being awesome

Jeff Douglas jeffdonthemic

💭
Currently being awesome
View GitHub Profile
@jeffdonthemic
jeffdonthemic / streaming.rb
Created Jan 16, 2013
Streaming API example with restfroce
View streaming.rb
require 'restforce'
require 'faye'
# Initialize a client with your username/password.
client = Restforce.new :username => ENV['SFDC_USERNAME'],
:password => ENV['SFDC_PASSWORD'],
:security_token => ENV['SFDC_SECURITY_TOKEN'],
:client_id => ENV['SFDC_CLIENT_ID'],
:client_secret => ENV['SFDC_CLIENT_SECRET']
@jeffdonthemic
jeffdonthemic / application.html.erb
Created Jun 8, 2013
angular-rails-salesforce-demo views/layouts/application.html.erb
View application.html.erb
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<title>Angular Salesforce Demo</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="container">
@jeffdonthemic
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>();
@jeffdonthemic
jeffdonthemic / gist:7247654
Last active Jan 18, 2018
Passing parameters in an Angular.js Controller to a Resource
View gist:7247654
<script>
// in the html page
angular.module('config', []).constant('APIKEY',''5250738f97ce29c219000011'');
</script>
myApp.controller('JobsCtrl', ['$scope', 'Jobs', 'APIKEY', function($scope, Jobs, apiKey) {
var promise = Jobs(apiKey).query().$promise;
// do more awesome programming
}
@jeffdonthemic
jeffdonthemic / tooling.js
Last active Jan 2, 2016
Sample script for with Promises for updating an Apex class in Force.com using the Tooling API with node.
View tooling.js
var Q = require("q"),
request = require('request');
// call with the following
// var apexClassId = "01pi0000004kbvAAAQ"; // the id of the apex class to update
// var newCode = "public class Test1 { public void sayHelloOnceAgain() { } }"; // pass in some code
// var connetion = resp object from nforce org.authenticate
function updateApex(apexClassId, newCode, connection) {
@jeffdonthemic
jeffdonthemic / tooling-plugin-test.js
Created Jan 10, 2014
First crack at tooling api plugin.
View tooling-plugin-test.js
var nforce = require('nforce'),
tooling = require('nforce-tooling')(nforce);
var sfuser = username
var sfpass = password;
var org = nforce.createConnection({
clientId: '3MVG9A2kN3Bn17ht1YQvQ6nm.jFel8rlyJZmshbAk1q2jOWva9KnNpzRoTR5n2LxulHbXMm0UucBJiOk_Rx7b',
clientSecret: '4527253748424741492',
redirectUri: 'http://localhost:3000/oauth/_callback',
@jeffdonthemic
jeffdonthemic / promises-parallel.js
Last active Aug 29, 2015
Node Promises in parallel with mongo
View promises-parallel.js
var allPromise = Q.all([ getTemplates(), getGroups() ])
allPromise
.then(function (data) {
console.log(data);
});
function getTemplates () {
var deferred = Q.defer()
Template.find({}, function (err, data) {
if (err) deferred.reject(err) // rejects the promise with `er` as the reason
@jeffdonthemic
jeffdonthemic / app.js
Created Apr 13, 2014
Setting nforce org in express session
View app.js
var nforce = require('nforce');
/**
* Salesforce configuration.
*/
var org = nforce.createConnection({
clientId: process.env.SFDC_CLIENT_ID,
clientSecret: process.env.SFDC_CLIENT_SECRET,
redirectUri: 'http://localhost:3000/oauth/_callback',
@jeffdonthemic
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
jeffdonthemic / getuser.rb
Created Jun 12, 2014
Reads handles from a CSV and calls topcoder API for more user details
View getuser.rb
require 'csv'
require 'httparty'
CSV.foreach('/Users/jeff/Desktop/names.csv', :headers => false) do |row|
response = HTTParty.get("http://api.topcoder.com/v2/users/#{row.first}")
puts "#{response['handle']},#{response['country']}"
end
You can’t perform that action at this time.