Skip to content

Instantly share code, notes, and snippets.

@joshbirk
joshbirk / extension.java
Created November 9, 2011 18:38
Controlling outputpanel with Apex
public with sharing class MyExtension {
public Boolean showPanel {get; set;}
public String inputValue {get; set;}
public MyExtension(ApexPages.StandardController controller) {
inputValue = '';
showPanel = true;
}
@joshbirk
joshbirk / jQote2VF.xml
Created November 17, 2011 23:37
This is an example of using jQote2 within Visualforce. The RemoteAction function is just a simple SOQL call.
<apex:page Controller="DataController" showHeader="false" standardStylesheets="false">
<apex:includeScript value="{!URLFOR($Resource.HTML5Util, 'jquery.min.js')}" />
<apex:includeScript value="{!$Resource.jQote2}"/>
<script type="text/javascript">
j$ = jQuery.noConflict();
j$(document).ready(
function() {
DataController.getRecords(function(result, event) {
j$('#contactList').jqoteapp('#contacts_tmpl', result);
@joshbirk
joshbirk / loginsoap.as
Created November 24, 2011 17:15
Longer version of the REST login w/ SOAP for Flex-RESTKit
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:salesforce1="com.salesforce.*"
creationComplete="login();"
>
<fx:Declarations>
<salesforce1:Connection id="force" />
</fx:Declarations>
@joshbirk
joshbirk / jqoteload.html
Created November 30, 2011 23:32
Using jQ's load to insert jQote2 templates remotely
<!Doctype html>
<HTML>
<HEAD>
<script src="jQuery-1.5.1.min.js" ></script>
<script src="jQuery.jQote2.min.js" ></script>
<script type="text/javascript">
j$ = jQuery.noConflict();
j$(document).ready(
function() {
j$('#contacts_tmpl').load('test_template.js', function() {
@joshbirk
joshbirk / blueconverter.sh
Created December 29, 2011 08:55
BlueButton Shell Conversion
#create initial JSON file
touch ${1%.*}.json
echo '{ "BlueButtonData" : {' > ${1%.*}.json
echo '"Conversion Data": "Converted by BlueConverter",' >> ${1%.*}.json
#read ASCII data file
blackcats="MY HEALTHEVET PERSONAL INFORMATION REPORT,DOWNLOAD REQUEST SUMMARY"
arraykeys="Contact First Name:Contacts,Provider Name:Providers,Facility Name:Facilities,Health Insurance Company:Companies,Date/Time:Appointments,Medication:Medications,Category:Medications,Allergy Name:Allergies,Medical Event:Events,Immunization:Immunizations,Test Name:Tests,Measurement Type:Measurements,Event Title:Events"
militarycategories="Regular Active Service,Reserve/Guard Association Periods,Reserve/Guard Activation Periods,Deployment Periods,DoD MOS/Occupation Codes,Military/Combat Pay Details,Separation Pay Details,Retirement Periods,DoD Retirement Pay"
@joshbirk
joshbirk / UpdatedApexREST.java
Created January 7, 2012 00:36
Preview of some of the changes to Apex REST in version 24.0
@RestResource(urlMapping='/FieldCase/*')
global class ApexRESTUpdate {
//Note we no longer need to include RestRequest and RestResponse as incoming parameters
//The static RestContext has request and response properties instead
@HttpGet
global static List<Case> getOpenCases() {
String companyName = RestContext.request.params.get('companyName');
Account company = [ Select ID, Name, BillingState from Account where Name = :companyName];
List<Case> cases = [SELECT Id, Subject, Status, OwnerId, Owner.Name from Case WHERE AccountId =: company.Id];
@joshbirk
joshbirk / checkemail.py
Created January 17, 2012 16:23
Python Script to check GMail account
#!/usr/bin/env python
def gmail_checker(username,password):
import imaplib,re
i=imaplib.IMAP4_SSL('imap.gmail.com')
try:
i.login(username,password)
x,y=i.status('INBOX','(MESSAGES UNSEEN)')
messages=int(re.search('MESSAGES\s+(\d+)',y[0]).group(1))
unseen=int(re.search('UNSEEN\s+(\d+)',y[0]).group(1))
return (messages,unseen)
@joshbirk
joshbirk / KennelTest.java
Created January 23, 2012 22:59
Using PhoneGap to get and upload Images in Visualforce
public with sharing class KennelTest {
public Dog__c exampleDog {get; set;}
public Attachment dogImage {get; set;}
public String getImageBase64() {
if(dogImage.Body != null) {
return EncodingUtil.base64Encode(dogImage.Body);
} else {
return '';
}
@joshbirk
joshbirk / streamingjquery.js
Created January 31, 2012 17:19
Using Streaming API w/ jQuery And Notifications


 j$ = jQuery.noConflict();


 j$(document).ready(function() {

 j$.cometd.configure({
url:'https://'+window.location.hostname+'/cometd/23.0',
requestHeaders: {"Authorization": "OAuth {!$Api.Session_ID}"}
});
j$.cometd.init();
j$.cometd.subscribe('/topic/AllDogs', function(message) {
@joshbirk
joshbirk / passport-fdc.js
Created January 31, 2012 21:09
Basic Passport / Force.com / Node.js example
var port = process.env.PORT || 3000;
var fs = require('fs');
var express = require('express');
var passport = require('passport')
, OAuthStrategy = require('passport-oauth').OAuth2Strategy;
passport.serializeUser(function(user, done) {
done(null, user);
});