Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jeffdonthemic's full-sized avatar
💭
Currently being awesome

Jeff Douglas jeffdonthemic

💭
Currently being awesome
View GitHub Profile
@jeffdonthemic
jeffdonthemic / signer.js
Last active May 4, 2023 17:53
Node crypto sign/verify
const crypto = require('crypto')
const fs = require('fs')
function sign(plainText) {
const sign = crypto.createSign('RSA-SHA512')
sign.update(Buffer.from(plainText, 'utf8'))
signature = sign.sign(
{
key: fs.readFileSync('./salesforce_private.key', 'utf8'),
padding:crypto.constants.RSA_PKCS1_PSS_PADDING
public with sharing class EncryptionService {
// Keys are here for testing purposes. NEVER DO THIS!!!
// Use an approved secrets management solution like Shield Platform Encryption
public static final Blob PRIVATE_KEY = EncodingUtil.base64Decode(
'IMAGE-A-LOT-MORE-LINES-HERE\n' +
'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCS7LXFvLFELXwy\n' +
'UVKIYJEI3j/7b4HUIOJ1IU1la1g2Vr5SKPn+GziMFhFcBjx6LlJxAkJQlOgBOnkO\n' +
'cHC3etOoAsrrRh4LPzZ6CXQeSRjilQnzaCdq2CIu+f8UqVWbwPtb3K/aQAX905Ck\n' +
require 'restforce'
# set default org with sfdx
# sfdx config set target-org=<some username or org alias>
# grab the access token & instance url from the default scratch org using sfdx
org = JSON.parse(`sfdx org display --json`)
client = Restforce.new(
oauth_token: org['result']['accessToken'],
@jeffdonthemic
jeffdonthemic / clickupservice.cls
Created February 16, 2023 20:25
Apex REST GET
public with sharing class ClickUpTaskService {
private static String apiKey = '';
public static void call() {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.clickup.com/api/v2/list/900600512507/task');
request.setMethod('GET');
@jeffdonthemic
jeffdonthemic / AddToCart.evt
Last active December 29, 2022 17:11
Salesforce1 Lightning Demo for Spring '15
<aura:event type="APPLICATION" description="Add to cart event.">
<aura:attribute name="product" type="Product__c"/>
</aura:event>
@jeffdonthemic
jeffdonthemic / CustomAccountLookup.page
Last active January 12, 2021 15:17
Roll Your Own Salesforce "Lookup" Popup Window blog post
<apex:page controller="CustomAccountLookupController"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="Account"
id="pg">
<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">
@jeffdonthemic
jeffdonthemic / UploadAttachment
Created May 30, 2014 18:08
Visualforce Page for customizing Attachments. See UploadAttachmentController.
<apex:page standardController="Contact" tabStyle="Contact" extensions="UploadAttachmentController">
<apex:sectionHeader title="{!Contact.Name}" subtitle="Attach File"/>
<apex:form id="form_Upload">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Back to {!Contact.Name}"/>
<apex:commandButton action="{!back}" value="Cancel"/>
@jeffdonthemic
jeffdonthemic / app.js
Created July 7, 2014 09:18
Simple socket.io example
var http = require('http'),
fs = require('fs'),
// NEVER use a Sync function except at start-up!
index = fs.readFileSync(__dirname + '/index.html');
// Send index.html to all requests
var app = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(index);
});
@jeffdonthemic
jeffdonthemic / gist:7247654
Last active August 6, 2020 03:56
Passing parameters in an Angular.js Controller to a Resource
<script>
// in the html page
angular.module('config', []).constant('APIKEY',''5250738f97ce29c219000011'');
</script>
myApp.controller('JobsCtrl', ['$scope', 'Jobs', 'APIKEY', function($scope, Jobs, apiKey) {
var promise = Jobs(apiKey).query().$promise;
// do more awesome programming
}
@jeffdonthemic
jeffdonthemic / do_magic.rb
Last active June 10, 2020 14:49
Delete a file using signed commits
# This code is based upon the following links:
# https://developer.github.com/v3/git/trees/
# https://github.com/testcollab/rails-test
# https://stackoverflow.com/questions/23637961/how-do-i-mark-a-file-as-deleted-in-a-tree-using-the-github-api
# https://github.community/t/deleting-files-via-trees-no-longer-works/14042
# This creates a signed commit on the correct branch, but there are 0 changed files.
# THIS IS THE METHOD THAT IS CALLED BY THE MAIN PROCESS TO REMOVE FILES