Skip to content

Instantly share code, notes, and snippets.

View fractastical's full-sized avatar

Joel Dietz fractastical

View GitHub Profile
@fractastical
fractastical / @ca_peterson SObject initialization from Id.txt
Created May 24, 2011 21:37
@ca_peterson SObject initialization from Id
#
* This method accepts the ID of any object type and returns the full name, including prefix of the sObject
#
* type to which it belongs.
#
* @author cpeterson
#
**/
#
public static Schema.SObjectType getObjectType(id subject){
List<UserFeed> myfeed = [SELECT Id, FeedPostId
FROM UserFeed
WHERE feedpostid = :recipeSixFPostID LIMIT 1];
FeedComment fcomment = new FeedComment();
fcomment.FeedItemId = myfeed.get(0).id;
fcomment.CommentBody = recipeSixComment;
insert fcomment;
recipeSixComment = '';
public void recipeFiveAddPost()
{
FeedPost fpost = new FeedPost();
fpost.ParentId = UserInfo.getUserId();
fpost.Body = recipeFiveAddAFeedPost;
insert fpost;
ApexPages.addMessage(new ApexPages.Message(
ApexPages.Severity.INFO, 'FeedPost ID is:'+fpost.id));
public List<Recommendation> getRecipeEightTopPosters()
{
List<AggregateResult> results = [
SELECT ParentId pid, Parent.Name pname, COUNT(id) fcount
FROM UserFeed
WHERE Type='UserStatus'
AND CreatedDate = THIS_WEEK
GROUP BY Parent.Name, ParentId
ORDER BY Count(id) DESC LIMIT 10];
public with sharing class RESTController {
public void processRequest(){
validateRequest();
if( HasError )
return;
//Add support for other types of verbs here
processGetQuery();
}
public with sharing class AccountTriggerHandler {
private boolean m_isExecuting = false;
private integer BatchSize = 0;
public AccountTriggerHandler(boolean isExecuting, integer size){
m_isExecuting = isExecuting;
BatchSize = size;
}
public with sharing class AccountTriggerHandler {
private boolean m_isExecuting = false;
private integer BatchSize = 0;
public AccountTriggerHandler(boolean isExecuting, integer size){
m_isExecuting = isExecuting;
BatchSize = size;
}
trigger AccountTrigger on Account (after delete, after insert, after undelete,
after update, before delete, before insert, before update) {
AccountTriggerHandler handler = new AccountTriggerHandler(Trigger.isExecuting, Trigger.size);
if(Trigger.isInsert && Trigger.isBefore){
handler.OnBeforeInsert(Trigger.new);
}
else if(Trigger.isInsert && Trigger.isAfter){
handler.OnAfterInsert(Trigger.new);
AccountTriggerHandler.OnAfterInsertAsync(Trigger.newMap.keySet());
@fractastical
fractastical / @force2be Time Timezone conversions.txt
Created May 24, 2011 21:38
@force2be Time / Timezone conversions
//http://www.force2b.net/index.php/2010/08/date-time-and-timezone-handling-in-apex/
/* **********************************************************************************************
* TimeConversions Class
* Created by: Michael Smith/Force2b, 04/06/2010
*
************************************************************************************************ */
global class TimeConversions {
/* -------------------------------------------------------------------------------------
class ChatPostWrapper {
Chat_Session__Feed post;
public String postBody { get; set; }
public String userHandle { get; set; }
public String createdDate { get; set; }
public Boolean newPost { get; set; }
public Boolean systemMessage { get; private set; }
public List<FeedComment> comments { get; set; }