Skip to content

Instantly share code, notes, and snippets.

View dieffrei's full-sized avatar
🌍
Focusing

Diéffrei Quadros dieffrei

🌍
Focusing
View GitHub Profile
$scope.getOrderMargin = function() {
var result = 0.0;
var costSUM = 0.00;
var totalValue = 0.00;
_.each($scope.sharedModel.order.OpportunityLineItems.all(), function(it) {
if (it.hasProduct() && (!it.hasSpecialPrice() && !it.hasResidualPrice())) {
totalValue = totalValue + it.getTotalValue();
costSUM = costSUM + ((it.product2.getFreightPickUpCost() + it.product2.getListCost2()) * it.Quantity)
}
});
module.exports = function(grunt) {
// project configuration.
grunt.initConfig({
git_deploy: {
deploy_to_repo_target: {
options: {
url: 'dieffrei@bitbucket.org/dieffrei/sample-repo.git'
},
@dieffrei
dieffrei / 1.before.js
Created June 1, 2016 18:49 — forked from cowboy/1.before.js
grunt: an example of building task targets dynamically
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
min: {
ariaAccessibility: {
src: ['src/javascripts/jquery.selectBoxIt.ariaAccessibility.js'],
dest: 'src/javascripts/jquery.selectBoxIt.ariaAccessibility.min.js'
},
@dieffrei
dieffrei / decrypt-salesforce-aes
Created December 19, 2016 20:52
How to decrypt salesforce data on java?
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class Main {
private static final String characterEncoding = "UTF-8";
private static final String cipherTransformation = "AES/CBC/PKCS5Padding";
{
"id": "https://login.salesforce.com/id/00Dx0000000BV7z/005x00000012Q9P",
"issued_at": "1278448832702",
"instance_url": "https://***yourInstance***.salesforce.com/",
"signature": "0CmxinZir53Yex7nE0TD+zMpvIWYGb/bdJh6XfOH6EQ=",
"access_token": "00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW1 9ye6PE3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs"
}
@dieffrei
dieffrei / TargetOrgService.cls
Last active April 21, 2018 17:15
Salesforce Named Credential
public class TargetOrgService {
public class SFEnvelope {
public List<Account> records {get;set;}
}
private static final String ACCOUNTS_SOQL = 'SELECT Id, Name FROM Account LIMIT 10';
public static List<Account> fetchAccounts() {
HttpRequest request = new HttpRequest();
/**
* Created by dieffrei on 11/1/18.
*/
global with sharing class SFDBBundleRepository implements BundleRepository {
private MSSBundleSelector bundleSelector;
private MSSBundle_DependencySelector bundleDependencySelector;
private ManagedService_SettingsSelector managedServiceSettingsSelector;
private SkillSelector skillSelector;
@dieffrei
dieffrei / clean_code.md
Created May 27, 2019 10:17 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

public interface IPersonalCustomerApplicationService {
void deactivate(Set<Id> customerIds);
}
class VoidAnswer implements fflib_Answer {
public Object answer(fflib_InvocationOnMock invocation) {
return null;
}
}
@dieffrei
dieffrei / squashing-commits-already-on-remote.sh
Last active December 6, 2019 17:13
Squashing commits already on remote branch
git rebase -i HEAD~10 #number of commits
git push origin +master #name of your branch