Skip to content

Instantly share code, notes, and snippets.

View jeffdonthemic's full-sized avatar
💭
Currently being awesome

Jeff Douglas jeffdonthemic

💭
Currently being awesome
View GitHub Profile
@jeffdonthemic
jeffdonthemic / streaming.rb
Created January 16, 2013 14:45
Streaming API example with restfroce
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 June 8, 2013 00:43
angular-rails-salesforce-demo views/layouts/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 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>();
@jeffdonthemic
jeffdonthemic / gist:7247654
Last active August 6, 2020 03:56
Passing parameters in an Angular.js Controller to a Resource
<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 January 2, 2016 10:29
Sample script for with Promises for updating an Apex class in Force.com using the Tooling API with node.
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 January 10, 2014 11:19
First crack at tooling api plugin.
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 August 29, 2015 13:59
Node Promises in parallel with mongo
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 April 13, 2014 13:57
Setting nforce org in express session
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 18:08
Visualforce Page for customizing Attachments. See UploadAttachmentController.
<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 June 12, 2014 18:08
Reads handles from a CSV and calls topcoder API for more user details
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