This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jwt' | |
require "faraday" | |
require "uri" | |
def token | |
private_key = './keys/server.key' | |
priv_key = OpenSSL::PKey::RSA.new(File.read(private_key)) | |
JWT.encode payload, priv_key, 'RS256' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'restforce', '~> 6.2.2' | |
gem 'thor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AnimalsCallouts { | |
public static HttpResponse makeGetCallout() { | |
Http http = new Http(); | |
HttpRequest request = new HttpRequest(); | |
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals'); | |
request.setMethod('GET'); | |
HttpResponse response = http.send(request); | |
// If the request is successful, parse the JSON response. | |
if(response.getStatusCode() == 200) { | |
// Deserializes the JSON string into collections of primitive data types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsforce = require('jsforce'); | |
const { exec } = require('child_process'); | |
exec("sfdx org display --json", (error, stdout, stderr) => { | |
let org = JSON.parse(stdout); | |
console.log('================='); | |
console.log(org.result.username); | |
console.log(org.result.instanceUrl); | |
console.log('================='); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'base64' | |
private_key = File.read("./salesforce_private.key") | |
public_key = File.read("./salesforce_public.key") | |
data = "reports50" | |
priv_key = OpenSSL::PKey::RSA.new(private_key) | |
signature = priv_key.sign_pss("RSA-SHA512", data, salt_length: :digest, mgf1_hash: "RSA-SHA512") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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://git.521000.bestmunity/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://git.521000.bestmunity/t/deleting-files-via-trees-no-longer-works/14042 | |
def commit_files_to_remove | |
# get the base branch tree that has all of the files in it | |
branch_tree = github.git_data.trees.get @repo.username, | |
@repo.repo_name, | |
new_branch_sha, | |
recursive: true | |
# select only the files for THIS badge |
NewerOlder