Skip to content

Instantly share code, notes, and snippets.

View metadaddy's full-sized avatar

Pat Patterson metadaddy

View GitHub Profile
@metadaddy
metadaddy / MessageToTask.apex
Created August 24, 2012 21:59
Transcribing Voice Messages to Tasks with the Tropo API
@RestResource(urlMapping='/messageToTask')
global class MessageToTask {
global class Result {
public String guid;
public String identifier;
public String transcription;
}
@HttpPost
global static void incomingMessage(Result result) {
@metadaddy
metadaddy / Connector.page
Created October 18, 2012 06:00
Call Routing with Twilio and Force.com
<?xml version="1.0" encoding="UTF-8" ?>
<apex:page sidebar="false"
showHeader="false"
controller="ConnectorController"
contentType="application/xml">
<Response>
<Say>Hello {!callerName}. Connecting you with {!rep.Name}.</Say>
<Pause/>
<Dial>{!rep.Phone}</Dial>
</Response>
@metadaddy
metadaddy / MultiJSONResponseCalloutMock.cls
Created October 19, 2012 14:14
MultiJSONResponseCalloutMock
global class MultiJSONResponseCalloutMock implements HttpCalloutMock {
private HTTPResponse res;
private Map<String, String> m;
global MultiJSONResponseCalloutMock() {
this.res = new HTTPResponse();
this.m = new Map<String, String>();
this.res.setStatusCode(200);
this.res.setStatus('OK');
}
@metadaddy
metadaddy / TestWindowOpenClose.page
Created November 1, 2012 21:05
Logout from Salesforce
<apex:page >
<script>
var win = window.open('https://login.salesforce.com/secur/logout.jsp', '_blank');
setTimeout(function(){ win.close(); }, 2000);
</script>
<h1>Test Open/Close</h1>
</apex:page>
@metadaddy
metadaddy / SiteLogin.page
Created February 26, 2013 21:00
OAuth for Portal Users
<apex:page showHeader="false" sidebar="false" standardStylesheets="false" cache="false" controller="SiteLoginController">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="format-detection" content="telephone=no" />
<title>
login
</title>
<apex:stylesheet value="{!$Resource.login}"/>
</head>
@metadaddy
metadaddy / ButtonController.cls
Last active December 14, 2015 08:59
Controlling physical devices from a Raspberry Pi and approvals in Force.com!
@RestResource(urlMapping='/button/*')
global class ButtonController {
@future(callout=true)
public static void light(Boolean state) {
HTTPRequest outreq = new HTTPRequest();
outreq.setEndpoint('http://api.superpat.com:5000/pins/25');
outreq.setMethod('POST');
outreq.setHeader('Content-Type', 'application/json');
outreq.setBody(state ? 'true' : 'false');
@metadaddy
metadaddy / user.json
Created May 22, 2013 17:24
Minimal example payload for user creation using Force.com REST API. Post this to https://instance.salesforce.com/services/data/v27.0/sobjects/User
{
"Username" : "user@example.com",
"Alias" : "user",
"Email" : "me@example.com",
"FirstName" : "Test",
"LastName" : "User",
"ProfileId" : "PROFILE_RECORD_ID",
"LanguageLocaleKey" : "en_US",
"LocaleSidKey" : "en_US",
"EmailEncodingKey" : "UTF-8",
<apex:page >
<apex:includeScript value="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"/>
<script>
jQuery(document).ready(function($) {
$('#queryform').submit(function(){
$.ajax($('#query').val(),
{
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
},
@metadaddy
metadaddy / MobileInventory.page
Last active December 21, 2015 04:09
Mobile Workshop tutorial after adding logo
<apex:page standardStylesheets="false" showHeader="false" sidebar="false"
standardController="Merchandise__c" extensions="MobileInventoryExtension"
recordSetVar="products">
<head>
<title>Mobile Inventory</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<apex:stylesheet value="{!URLFOR($Resource.jquerymobile130, 'jquery.mobile-1.3.0.min.css')}" />
@metadaddy
metadaddy / MobileInventory.page
Last active December 21, 2015 04:09
After adding price field.
<apex:page standardStylesheets="false" showHeader="false" sidebar="false"
standardController="Merchandise__c" extensions="MobileInventoryExtension"
recordSetVar="products">
<head>
<title>Mobile Inventory</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<apex:stylesheet value="{!URLFOR($Resource.jquerymobile130, 'jquery.mobile-1.3.0.min.css')}" />