Skip to content

Instantly share code, notes, and snippets.

@omniphx
omniphx / TriggerHandler (complex)
Last active March 15, 2018 15:46
TriggerHandler with hashmap to prevent recursion
public virtual class TriggerHandler {
public static Boolean shouldRun = true;
public static Boolean shouldHandlersRun = true;
public TriggerContext context;
public static Boolean isFirstTime = true;
private Integer hashCode;
private Boolean isTriggerExecuting;
private static Map<Integer, Set<TriggerContext>> processedHashCodes = new Map<Integer, Set<TriggerContext>>();
private final List<String> OMITTED_FIELDS = new List<String>{'CompareName','CreatedById','CreatedDate','LastModifiedById','LastModifiedDate','SystemModstamp'};
public virtual class TriggerHandler {
public static Boolean shouldRun = true;
public static Boolean shouldHandlersRun = true;
public TriggerContext context;
private Boolean isTriggerExecuting;
public static void disable() {
TriggerHandler.shouldRun = false;
}
@omniphx
omniphx / hide ng-grid
Created December 30, 2015 05:30
A style for hiding ng-grid
.ng-hide:not(.ng-hide-animate) {
display: block!important;
position: absolute;
top: -9999px;
left: -9999px;
}
.btn-inverse {
color: #fff;
background-color: transparent;
border-color: #fff;
}
.btn-inverse:active,
.btn-inverse:focus,
.btn-inverse:hover{
color: @color-primary-3;
background-color: #fff;
@omniphx
omniphx / site
Created December 20, 2015 04:38
nginx conf for sites
server {
listen 80;
listen 443 ssl;
server_name ~^(.*)\.192\.168\.33\.10\.xip\.io$;
set $file_path $1;
root /var/www/$file_path/public;
ssl_certificate /etc/ssl/xip.io/xip.io.crt;
ssl_certificate_key /etc/ssl/xip.io/xip.io.key;
@omniphx
omniphx / gulpfile.js
Last active July 31, 2021 07:08
Create a new file with gulp
var
gulp = require('gulp'),
tap = require('gulp-tap'),
path = require('path'),
newfile = require('gulp-file');
gulp.task('new-file', function(){
gulp.src('./foo.derp')
.pipe(tap(function(file){
var fileName = path.basename(file.path) + ".derp";
@omniphx
omniphx / gulpfile.js
Created December 3, 2015 21:10
Gulp configuration for handling static resources
var gulp = require('gulp'),
shell = require('gulp-shell'),
zip = require('gulp-zip'),
minifyCSS = require('gulp-minify-css'),
less = require('gulp-less'),
debug = require('gulp-debug'),
gutil = require('gulp-util');
gulp.task('update', shell.task(
'bower update'
@omniphx
omniphx / RemoveUserFromHierachyFields.cls
Created March 10, 2015 12:59
Remove User from hierachy fields
Id userId = '005i000000XXXXX';
List<String> fields = new List<String>{'Sales_Director__c','Account_Coordinator__c','Account_Services_Representative__c','Program_Director__c','Sales_Director__c','Placement_Manager__c','Inside_Sales_Representative__c','New_Family_Placement_Manager__c'};
User[] users = [
SELECT Id, Name, Account_Coordinator__c, Account_Services_Representative__c,Inside_Sales_Representative__c, New_Family_Placement_Manager__c,Placement_Manager__c, Program_Director__c, Sales_Director__c
FROM User
WHERE Account_Coordinator__c = :userId
OR Account_Services_Representative__c = :userId
OR Inside_Sales_Representative__c = :userId
@omniphx
omniphx / RecordsOwnedByUser.cls
Created March 10, 2015 12:58
Records owned by User
Id userId = '005i000000XXXXX'; //Input userId
Map<String, Schema.SObjectType> sobjects = Schema.getGlobalDescribe();
system.debug('sobjects: ' + sobjects);
Map<Schema.SObjectType, Integer> ownerMap = new Map<Schema.SObjectType, Integer>();
for(Schema.SObjectType sobj : sobjects.values())
{
Set<String> objectFields = sobj.getDescribe().fields.getMap().keySet();
@omniphx
omniphx / HelperTriggerUtility
Last active August 29, 2015 14:08
Helper class for determining field change criteria
public with sharing class HelperTriggerUtility {
private SObject newObj;
private SObject oldObj;
public HelperTriggerUtility(SObject oldObj, SObject newObj) {
this.newObj = newObj;
this.oldObj = oldObj;
}