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 / httparty.rb
Last active May 2, 2024 00:45
HTTParty Examples
options = { :body =>
{ :username => 'my',
:password => 'password'
}
}
results = HTTParty.post("http://api.topcoder.com/v2/auth", options)
##
## example for post with papertrail and basic auth
##
@jeffdonthemic
jeffdonthemic / apex-crud-fls.txt
Last active April 18, 2024 16:52
Simple Apex Controller with CRUD and FLS
This simple controller (without CRUD and FLS) ...
public with sharing class AccountController {
@AuraEnabled
public static List<Account> findAll() {
return [SELECT id, name, Location__Latitude__s, Location__Longitude__s
FROM Account
WHERE Location__Latitude__s != NULL AND Location__Longitude__s != NULL
LIMIT 50];
@jeffdonthemic
jeffdonthemic / datacloud-ingestion-insert.rb
Last active December 7, 2023 15:12
Using the Data Cloud Ingestion to insert records with JWT connected app
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
@jeffdonthemic
jeffdonthemic / org_connection.js
Created March 25, 2019 21:15
jsforce with jwt
const jsforce = require('jsforce');
const jwt = require("salesforce-jwt-bearer-token-flow");
// create the connection to the org
let conn = new jsforce.Connection();
// load the private key for the token
let privateKey = require('fs').readFileSync('./server.key', 'utf8');
jwt.getToken({
@jeffdonthemic
jeffdonthemic / index.js
Last active October 27, 2023 15:42
Lambda function to commit code to github. See blog post for more details.
var githubapi = require("github"),
async = require("async"),
AWS = require('aws-sdk'),
secrets = require('./secrets.js');
// the 'handler' that lambda calls to execute our code
exports.handler = function(event, context) {
// config the sdk with our credentials
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html
@jeffdonthemic
jeffdonthemic / Gemfile
Last active August 15, 2023 14:46
Salesforce 2GP Packaging CLI
source 'https://rubygems.org'
gem 'restforce', '~> 6.2.2'
gem 'thor'
@jeffdonthemic
jeffdonthemic / api-json.playground
Created August 22, 2014 18:29
Swift API call & parsing JSON
import Foundation
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
/**
* Paste all the code from the following file
- https://github.com/lingoer/SwiftyJSON/blob/master/SwiftyJSON/SwiftyJSON.swift
**/
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.
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('=================');
@jeffdonthemic
jeffdonthemic / signer.rb
Last active May 9, 2023 17:48
Ruby crypto sign/verify
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")