Skip to content

Instantly share code, notes, and snippets.

View justin-lyon's full-sized avatar

Justin Lyon justin-lyon

  • Daejeon, South Korea
View GitHub Profile
@justin-lyon
justin-lyon / MyComponent.js
Last active November 25, 2022 05:17
Sample SF LWC toaster utility
// SAMPLE USAGE
import * as toaster from 'c/toaster';
export default class MyComponent extends LightningElement {}
connectedCallback() {
toaster.init(this);
}
save() {
@justin-lyon
justin-lyon / calc-business-days-formula
Created June 30, 2022 11:01
salesforce formula field to compare two Date Fields
(IF(AND((5 - (CASE(MOD( FirstDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD( SecondDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( SecondDate__c - FirstDate__c ) + 1) < 7)),
((CASE(MOD( SecondDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD( FirstDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( SecondDate__c - FirstDate__c ) - (CASE(MOD( FirstDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD( FirstDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD( SecondDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0))))-1)
@justin-lyon
justin-lyon / .bashrc
Created June 27, 2022 05:15
windows .bashrc ssh-agent setup
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
add_keys () {
# *** path to SSH Key(s) here ***
@justin-lyon
justin-lyon / scan-for-external-ids.java
Created June 16, 2022 11:58
Apex Anon - Scan for External IDs
List<SObjectType> types = new List<SObjectType> {
Account.getSObjectType(),
Contact.getSObjectType(),
Opportunity.getSObjectType(),
Lead.getSObjectType()
};
List<Field> fields = new List<Field>();
for (SObjectType t : types) {
Schema.DescribeSObjectResult dsor = t.getDescribe();
@justin-lyon
justin-lyon / cheatsheet.sh
Created June 7, 2022 00:29
Bash Cheat Sheet
# List all Apex Classes from path, without file extensions.
ls force-app/main/default/classes | grep -E \.cls$ | sed s/.cls//g
@justin-lyon
justin-lyon / flex-align-center.html
Created May 8, 2021 02:29
align center using flex
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html,
body {
margin: 0;
# These are some Java and Maven commands I want to keep handy
# Create a clean package, wipes out /target, compiles, runs tests, and generates a brand new .jar
mvn clean package
# Run the jar
java -jar target/myapp.jar
# List the contents of the jar
jar tf target/myapp.jar
public with sharing MyClass {
public KbManagerI kavManager;
public MyClass() {
// Default KbManager Implementation
this(new MyKbManager());
}
// Allows for Constructor Injection, so we can change the implementation for our tests.
public MyClass(KbManagerI km) {
@justin-lyon
justin-lyon / .eslintrc.json
Last active November 9, 2020 02:54
Setup Linting & Formatting
{
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
"semi": "error"
}
}
@justin-lyon
justin-lyon / RestTemplateConfiguration.java
Last active October 6, 2020 20:48
Trying to test some stuff
@Configuration
public class RestTemplateConfiguration {
public static final String REST_TEMPLATE_NAME = "someRestTemplate";
@Autowired
private AppConfig appConfig;
@Value("${props.useProxy})
private boolean useProxy;