Skip to content

Instantly share code, notes, and snippets.

View techb's full-sized avatar

K.B. Carte techb

View GitHub Profile
@techb
techb / console-colored.py
Last active September 14, 2018 17:33
colored feedback boxes when creating cli applications.
run = '\033[1;97m[~]\033[1;m'
bad = '\033[1;31m[-]\033[1;m'
good = '\033[1;32m[+]\033[1;m'
info = '\033[1;33m[!]\033[1;m'
que = '\033[1;34m[?]\033[1;m'
@techb
techb / arr_to_csv.js
Created March 14, 2019 16:58
JS Array to CSV Download
var csv_arr = [];
// add header first before pushing data
csv.push(["Bruh", "Data", "Date", "Ect"]);
for(var i = 0; i <= somedata.length; i++){
csv_arr.push(somedata[i]);
}
// found: https://gist.github.com/yangshun/01b81762e8d30f0d7f8f
document.querySelector("#muh_epic_button").addEventListener("click", function () {
@techb
techb / check_scroll.js
Created October 1, 2019 17:50
Check if a div or container can scroll, jQuery
jQuery(function($) {
$(".my-selector").on('scroll', function() {
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
// at the bottom, do stuff like hide a down arrow
$(".down-arrow").addClass("hide");
}else{
// not at bottom, show down arrow or something else
$(".down-arrow").removeClass("hide");
}
})

Steps to use Postman with Salesforce

Use Postman to send and receive API requests to Salesforce to aid in developing and testing.

Step One

  • Salesforce Org
  • Setup
  • App Manager
  • (new or select one)
  • API (Enable OAuth Settings) to get Consumer KEY and SECRET
@techb
techb / email_perm_set.cls
Created March 16, 2020 19:44
Email Addresses by Permission Set
// Get list of email addresses by Permission Set
public static List<String> getEmailByPermSet(String permsetname){
List<Id> just_ids = new List<Id>();
List<PermissionSetAssignment> users = [
SELECT AssigneeId
FROM PermissionSetAssignment
WHERE PermissionSet.Name = :permsetname
];
for(PermissionSetAssignment uid: users){
just_ids.add(uid.AssigneeId);
@techb
techb / oktana_training_sofar.md
Last active March 20, 2020 16:47
Consolidated list of training material.
@techb
techb / EmailSend.cls
Created June 17, 2020 13:37
Utility for sending single emails in Apex with an org-wide email address
public class EmailSend {
public static void sendEmail(String candidate){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[]{candidate});
mail.setReplyTo('hr_address@my_company.com');
mail.setSubject('Thank You');
// https://help.salesforce.com/articleView?id=000340122&type=1&mode=1
// org-wide email address needs to be set
@techb
techb / TestEmailSend.cls
Created June 17, 2020 13:38
Unit test for sending emails in Apex
@isTest
public class TestEmailSend {
@isTest
static void testTheEmail(){
Test.startTest();
// the method we're testing
// https://gist.github.com/techb/7519e95bac3caa2b8adb3f65d2dc2dc8
EmailSend.sendEmail('[email protected]');
// we assert buy what govener limits say
@techb
techb / jess.py
Last active September 25, 2020 12:32
def decimal2binary(n):
# check if larger than 255 as per requirements
if n > 255:
return "Int too large"
# this is the string we're returning
binStr = ""
# this will loop forever if n never gets to or below 0
while n > 0: