Skip to content

Instantly share code, notes, and snippets.

@joshbirk
joshbirk / Controller.cs
Created July 20, 2011 17:45 — forked from recalde/Controller.cs
Salesforce_JQuery_Remoting
global with sharing class CPPBuilderRob {
public CPPBuilderRob() {
// Remember: @RemoteActions are static, hence controller has no state
}
@RemoteAction
global static CPP_Report_Poller GetReportGroups(string opportunityId) {
// Query from CPP_Report_Request__c
@joshbirk
joshbirk / rsshandler.cls
Created September 20, 2011 17:53
Converting an RSS Feed into a Custom Object
static global List<Dom.XMLNode> getRSSFeed(string URL) {
Http h = new Http();
HttpRequest req = new HttpRequest();
// url that returns the XML in the response body
req.setEndpoint(url);
req.setMethod('GET');
HttpResponse res = h.send(req);
Dom.Document doc = res.getBodyDocument();
@joshbirk
joshbirk / build-file.sh
Created September 22, 2011 19:33
Moving one file for Force.com Migration Tool
echo ${1%.*}
echo "Cleanup"
rm src-latest/classes/*
rm src-latest/pages/*
rm src-latest/components/*
echo "Moving files"
cp src/classes/${1%.*}.cls src-latest/classes/
cp src/classes/${1%.*}.cls-meta.xml src-latest/classes/
@joshbirk
joshbirk / keychain.sh
Created October 3, 2011 17:14
Shell script to get password out of Keychain (OSX), via http://blog.macromates.com/2006/keychain-access-from-shell/
security 2>&1 >/dev/null find-generic-password -ga $1 \
|ruby -e 'print $1 if STDIN.gets =~ /^password: "(.*)"$/'
@joshbirk
joshbirk / buildwithkeychain.sh
Created October 3, 2011 21:15
This is one way to swap out the password with the one in keychain, build, then swap back.
. build.properties
if [ ${usekeychainaccess} == 'enabled' ]
then
shellpassword=$(~/bin/keychain.sh ${password})
sed "s/${password}/${shellpassword}/" build.properties > new.properties
cp new.properties build.back
cp new.properties build.properties
fi
ant build-all
@joshbirk
joshbirk / fdctest.py
Created October 7, 2011 05:38
Python script using rest-python-client with Force.com
import os
import urlparse
import urllib
from restful_lib import Connection
consumer_key = 'CONSUMERKEY'
callback = 'https://login.salesforce.com/services/oauth2/success'
login_url = 'https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id='+consumer_key+'&redirect_uri='+callback
@joshbirk
joshbirk / toggleheadersidebar.js
Created October 11, 2011 16:48
JavaScript to show/hide header and sidebar from standard Salesforce pages
if(document.getElementById("AppBodyHeader").style.display == 'none') {
document.getElementById("AppBodyHeader").style.display = 'block';
} else {
document.getElementById("AppBodyHeader").style.display = 'none';
}
tds = document.getElementsByTagName("td");
for(var x = 0; x < tds.length; x++) {
if(tds[x].className == 'oLeft' || tds[x].id == 'sidebarCell') {
if(tds[x].style.display == 'none') {
@joshbirk
joshbirk / ApexJSONExample.cls
Created October 19, 2011 03:08
Apex Example of the new JSON parser/serialization
public with sharing class ApexJSONExample {
public ApexJSONExample() {
}
public void testSerialize() {
Flog__c f = new Flog__c();
Dog__c dog = [SELECT ID, Name, Breed__c from Dog__c LIMIT 1];
f.JSON__c = JSON.serialize(dog);
@joshbirk
joshbirk / loginsoap.as
Created November 9, 2011 17:30
Flex RESTKit - login completely via SOAP and use REST callout
public function login():void {
var lr:LoginRequest = new LoginRequest();
lr.username = 'YOUR USERNAME';
lr.password = 'YOUR PASSWORD';
lr.callback = new com.salesforce.AsyncResponder(doQuery,showError);
force.login(lr);
}
private function doQuery(result:LoginResult):void {
@joshbirk
joshbirk / panel.page
Created November 9, 2011 18:37
Controlling outputpanel with JavaScript
<apex:page showHeader="false" StandardController="Account">
<script>
function changevalue(input) {
value = input.options[input.selectedIndex].value;
if(value == 'Customer - Channel') {
document.getElementById('{!$Component.myform.mypanel}').style.display = 'none';
} else {
document.getElementById('{!$Component.myform.mypanel}').style.display = 'block';
}
}