Skip to content

Instantly share code, notes, and snippets.

@joshbirk
joshbirk / strategy.js
Created February 1, 2012 22:33
ForceDotCom Strategy for Passport
/**
* Module dependencies.
*/
var querystring = require('querystring'),
util = require('util'),
OAuth2Strategy = require('passport-oauth').OAuth2Strategy;
function Strategy(options, verify) {
options = options || {};
@joshbirk
joshbirk / samplerest.js
Created February 3, 2012 19:57
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@joshbirk
joshbirk / wizard.java
Created February 8, 2012 21:16
Simple Wizard Example
public class WizardExample {
public Contact c {get; set;}
public WizardExample(ApexPages.StandardController controller) {
//reference the contact from the standardcontroller
c = (Contact)controller.getRecord();
}
public PageReference Step1() {
@joshbirk
joshbirk / AJAXRemoteController.java
Created February 9, 2012 20:11
AJAX / JS Remoting Testing
global class AJAXRemoteController {
webService static String getContextUserName() {
return UserInfo.getFirstName();
}
webService static List<Contact> getAllMyContactsWS() {
List<Contact> contacts = [SELECT ID, FirstName, LastName, Phone, MobilePhone, AssistantPhone from Contact];
return contacts;
@joshbirk
joshbirk / DataPoint.java
Created February 9, 2012 23:28
Another Wizard Example (with PDF)
public class DataPoint {
public Boolean isPrint {get; set;}
public Boolean isEmail {get; set;}
public Contact contactData {get; set;}
public DataPoint(Contact c) {
contactData = c;
}
}
@joshbirk
joshbirk / testcontroller.java
Created February 15, 2012 18:52
Dynamic Field Example
public with sharing class TestController {
public String mainContactField {get; set;}
public TestController(ApexPages.StandardController std) {
Contact c = (Contact)std.getRecord();
mainContactField = 'Phone';
List<Contact> cWithRecords = [SELECT Id, Phone, MobilePhone, AssistantPhone, OtherPhone from Contact where ID = :c.Id];
if(cWithRecords.size() > 0) {
@joshbirk
joshbirk / jsremot1.jsp
Created March 14, 2012 20:37
Super simple SOQL/JS Remoting
function filterQuarks(spin,mass) {
remoteTest.filterQuarks(spin,mass,updateResults);
remoteTest.testDouble(logTemperatures);
}
function logTemperatures(result, event) {
console.log(result);
}
function updateResults(result, event) {
@joshbirk
joshbirk / addmerchandise.java
Created March 27, 2012 22:42
java code for Integration Demo
JSONObject mechandise = new JSONObject();
try {
if (name != null && !name.trim().equals(""))
mechandise.put("Name", name);
if (price != null && !price.trim().equals(""))
mechandise.put("Price__c", price);
if (desc != null && !desc.trim().equals(""))
mechandise.put("Description__c", desc);
if (inventory != null && !inventory.trim().equals(""))
<apex:page standardController="Contact">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/>
<script src="https://ajax.microsoft.com/ajax/jquery.ui/1.8.5/jquery-ui.js"/>
<script src="http://malsup.github.com/jquery.blockUI.js" />
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css" />
<script>
j$ = jQuery.noConflict();
function blockme() {
@joshbirk
joshbirk / apexresterror.java
Created May 18, 2012 16:25
Apex REST Error Handling
RestResponse res = RestContext.response;
res.addHeader('Error','This is an Error');
res.StatusCode = 400;
return null;