Skip to content

Instantly share code, notes, and snippets.

@KorbenC
KorbenC / ApexCsvExample.java
Created April 10, 2017 07:11 — forked from douglascayers/ApexCsvExample.java
Apex CSV Example. Note the use of String.escapeCsv() method
String csv = 'Id,Name\n';
for ( List<Account> accts : [ SELECT id, name FROM Account LIMIT 10 ] ) {
for ( Account acct : accts ) {
csv += acct.id + ',' + acct.name.escapeCsv() + '\n';
}
}
ContentVersion file = new ContentVersion(
title = 'accounts.csv',
versionData = Blob.valueOf( csv ),
@KorbenC
KorbenC / OpportunityTrigger.trigger
Last active June 11, 2020 15:45
One Trigger Per Object Pattern using context specific handler methods and logic-less triggers. Bonus features such as Routing Abstractions, Recursion Detection and Prevention, and Centralize Enable/Disable of Triggers!
trigger OpportunityTrigger on Opportunity (
before insert, after insert,
before update, after update,
before delete, after delete) {
//trigger body
new OpportunityTriggerHandler().run();
}
@KorbenC
KorbenC / gist:b69b8651f60d7f2a23f7
Created August 6, 2015 15:31
Database & Rails Course by Richard Schneems
http://www.schneems.com/post/25098659429/databases-rails-week-1-introduction/
http://www.schneems.com/post/25503708759/databases-rails-week-2-modeling-relationships-and/
http://www.schneems.com/post/25925957093/databases-rails-week-3-pure-ruby-views/
http://www.schneems.com/post/26418738373/databases-rails-week-4-routing/
http://www.schneems.com/post/27122707453/databases-rails-week-5-controllers/
http://www.schneems.com/post/27558427060/databases-rails-week-6-data-visualization-with/
http://www.schneems.com/post/28125445535/active-record-deep-dive/
http://www.schneems.com/post/28908007902/databases-rails-week-8/
http://www.schneems.com/post/29620668076/database-rails-week-9/
@KorbenC
KorbenC / ApexCoding.txt
Created June 3, 2015 13:10
Apex Coding Standards
Apex Coding Standard
Introduction
-------------
Apex is a strongly-typed, object-oriented, proprietary programming language for the Force.com platform.
It lets you execute flow and transaction control statements in conjunction with calls to the Force.com API.
Apex borrows it's syntax from Java, and functions like a database stored procedure.
To learn more about Apex, read the developer documentation on the Force.com developer site.
[http://www.salesforce.com/us/developer/docs/apexcode/index.htm]
@KorbenC
KorbenC / QueryUtil.cls
Created April 23, 2015 19:36
SOQL Select * from ...
/*
* Static methods to extend standard SOQL query capabilities.
*
* @author: Luke
* @date: Dec 2012
*/
public class QueryUtil {
public class QueryException extends Exception {}
@KorbenC
KorbenC / test.sql
Created December 11, 2014 21:18 — forked from anonymous/sql.SQL
declare @column varchar(max)
declare @sql nvarchar(max)
declare @tablename varchar(max)
declare tables cursor for select column_name from INFORMATION_SCHEMA.columns where table_name ='Salesforce_Task_Backup_12102014' and column_name!='ID'
Open tables
Fetch Next FROM tables
into @column
--set @column='userguid'
--set @value='5000010431119001'
@KorbenC
KorbenC / LoC.cls
Created October 3, 2014 13:14
Counts the lines of apex code in org, combined both class and triggers.
Integer classLines = 0;
Integer triggerLines = 0;
for(ApexClass a : [Select Body From ApexClass]){
List<String> lines = a.Body.split('\n');
classLines += lines.size();
}
for(ApexTrigger a : [Select Body From ApexTrigger]){
List<String> lines = a.Body.split('\n');
@KorbenC
KorbenC / BootstrapDashboard.page
Created May 13, 2014 16:05
Visualforce dashboard using Twitter Bootstrap
<apex:page sidebar="false" docType="html-5.0" controller="VSDashBoard_Con">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<script>
function goToDetailPage(recId){
if(typeof sforce != 'undefined' && typeof sforce.one != 'undefined'){
sforce.one.navigateToSObject(recId);
}
else{
window.location.href = '/'+recId;
}
@KorbenC
KorbenC / index.html
Created May 5, 2014 15:09
Bootstrap template w/ CDNs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
@KorbenC
KorbenC / gist:7b75a284b47ccf13f00a
Last active August 29, 2015 14:00 — forked from jrob00/gist:1230741
Change Mac OSx default screenshot directory
$ defaults write com.apple.screencapture location /Users/name/dropbox/photos/screenshots