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 / gist:2146052
Created March 21, 2012 10:31
MemberRestSvc - Apex REST Service (v24)
@RestResource(urlMapping='/v.9/member/*/results/*')
global with sharing class MemberRestSvc {
@HttpGet
global static ReturnClass doGet() {
String[] uriKeys = RestContext.request.requestURI.split('/');
// get the member name from the uri
String memberName = uriKeys.get(uriKeys.size()-3);
@jeffdonthemic
jeffdonthemic / gist:2146160
Created March 21, 2012 10:54
Test_MemberRestSvc - Test Class for Apex REST Service (v24)
@isTest
private class Test_MemberRestSvc {
static {
// setup test data
}
static testMethod void testDoGet() {
RestRequest req = new RestRequest();
@jeffdonthemic
jeffdonthemic / gist:2146168
Created March 21, 2012 10:56
Test_MemberRestSvc - Test Class for Apex REST Service (v23)
@isTest
private class Test_MemberRestSvc {
static {
// setup test data
}
static testMethod void testDoGet() {
RestRequest req = new RestRequest();
@jeffdonthemic
jeffdonthemic / AccountRegionTriggerHandler
Created April 10, 2012 13:41
AccountRegionTrigger, Handler and Test class
public with sharing class AccountRegionTriggerHandler {
@future
public static void ProcessRegionsAsync(Set<ID> accountIds){
// holds a map of the account id and comma separated regions to build
Map<Id, String> accountRegionMap = new Map<Id, String>();
// get ALL of the regions for all affected accounts so we can build
List<Account_Region__c> accountRegions = [select id, Account__c,
@jeffdonthemic
jeffdonthemic / gist:2508492
Created April 27, 2012 11:21
Force.com Node.js Demo - app.js
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, rest = require('./rest.js')
, oauth = require('./oauth.js')
, url = require('url');
@jeffdonthemic
jeffdonthemic / gist:2508501
Created April 27, 2012 11:23
Force.com Node.js Demo - routes/index.js
// only needed if calling the rest api from this file (accounts route)
var rest = rest = require('./../rest.js');
/*
* GET home page.
*/
exports.index = function(req, res){
res.render('index', { title: 'Salesforce.com Node.js REST Demo' })
};
@jeffdonthemic
jeffdonthemic / gist:2567190
Created May 1, 2012 10:43
CLI - thor file
require 'databasedotcom'
class Utils < Thor
desc "query SOQL", "runs a soql query and displays the value of each record's 'name' field"
method_option :config_file, :type => :string, :default => "databasedotcom.yml",
:aliases => "-c", :desc => "The name of the file containing the connection parameters."
def query(soql)
client = authenticate(options[:config_file])
# execute the soql and iterate over the results to output the name
@jeffdonthemic
jeffdonthemic / gist:2567200
Created May 1, 2012 10:44
CLI - yaml file
client_id: YOUR-CLIENT-ID
client_secret: YOUR-CLIENT-SECRET
host: test.salesforce.com
debugging: false
username: YOUR-USERNAME
password: YOUR-PASSWORD
@jeffdonthemic
jeffdonthemic / gist:3485039
Created August 27, 2012 02:13
node-force-demo app.js
var express = require('express')
, routes = require('./routes')
, util = require('util')
. async = require('async')
, nforce = require('nforce');
var port = process.env.PORT || 3001; // use heroku's dynamic port or 3001 if localhost
var oauth;
// use the nforce package to create a connection to salesforce.com
@jeffdonthemic
jeffdonthemic / force-node-streaming-app.js
Created September 7, 2012 12:42
Streaming API example with nforce
/**
* Module dependencies.
*/
var config = require('./config.js');
var express = require('express')
, faye = require('faye')
, nforce = require('nforce')
, util = require('util')
, routes = require('./routes');