Skip to content

Instantly share code, notes, and snippets.

View jbro-io's full-sized avatar

Jonathan Broquist jbro-io

  • Scottsdale, AZ
View GitHub Profile
@jbro-io
jbro-io / Visualforce: DateFormat
Last active December 29, 2015 07:39
Displays how to format a date field on a Visualforce page.
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!task.ActivityDate}" />
</apex:outputText>
<apex:page showHeader="false"
sidebar="false"
standardStylesheets="false"
applyHtmlTag="false"
applyBodyTag="false"
tabStyle="[TAB_STYLE]">
<html lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
@jbro-io
jbro-io / AngularJS: angular-eventutil.js
Last active September 12, 2017 07:37
Global event dispatcher/listener utility for AngularJS
angular.module('EventUtil', [])
.factory('broadcast', ['$rootScope', function($rootScope){
return function(eventName, payload){
$rootScope.$broadcast(eventName, payload);
};
}])
.factory('listen', ['$rootScope', function($rootScope){
return function(eventName, listener){
$rootScope.$on(eventName, listener);
};
public class ObjectUtil
{
public static String getObjectRecordTypeId(SObjectType sObjectType, String recordTypeName)
{
//Generate a map of tokens for all the Record Types for the desired object
Map<String, RecordTypeInfo> recordTypeInfo = sObjectType.getDescribe().getRecordTypeInfosByName();
system.debug('RECORD TYPES:' + recordTypeInfo);
if(!recordTypeInfo.containsKey(recordTypeName))
throw new RecordTypeException('Record type "'+ recordTypeName +'" does not exist.');
var express = require('express');
var oauth = require('oauth');
var oa;
var app = express.createServer();
app.get('/', function (req, res) {
res.end('<!DOCTYPE html><meta charset=utf-8><form action=/authorize><label>Client ID: <input type=text name=client_id required autofocus></label><br><label>Client Secret: <input type=text name=client_secret required></label><br><label>Scope: <input type=text name=scope required></label><br><input type=submit>');
});
app.get('/authorize', function (req, res) {
// "Cols" and "Rows" specify the coordinates in x and y.
// Cells create cells by indexing the rows and cols array in the order [startx, starty, endx, endy].
// Edit your Main.Sublime-menu file
// Mac: /Users/yourMacName/Library/Application Support/Sublime Text 2/Packages/Default
// PC: C:\Users\yourPCName\AppData\Roaming\Sublime Text 2\Packages\Default
// Example Below:
{
"caption": "Grid: 6",
"command": "set_layout",

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@jbro-io
jbro-io / Apex: Standard Deviation Example
Last active August 28, 2019 14:21
A method for calculating standard deviations with Apex.
public class AdvancedMath
{
public static Double standardDeviation(Double[] numbers)
{
//determine the sum of the range of numbers
Double sum = 0;
for(Double d : numbers)
{
sum += d;
}
@jbro-io
jbro-io / Visualforce: KnockoutJS Statement Component
Last active March 1, 2018 04:34
This is a Visualforce component used to render Knockout.js HTML comment tags.
<apex:component layout="none">
<apex:attribute name="statement"
description="The Knockout containerless statement to insert."
type="String"
required="false"
/>
<apex:attribute name="close"
description="Flag that determines whether this is an opening or closing statement for Knockout."
type="Boolean"
global class MassDelete implements Database.Batchable<sObject>
{
global final string query;
global MassDelete(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC)