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 / 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://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
@jeffdonthemic
jeffdonthemic / do_magic.rb
Last active June 5, 2020 19:29
Remove github files from tree
# 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
@jeffdonthemic
jeffdonthemic / restforce.rb
Created January 24, 2020 17:46
Restforce monkey patch
module Restforce
class Mash < Hashie::Mash
class << self
def klass(val)
if val.key? 'records'
# When the hash has a records key, it should be considered a collection
# of sobject records.
Restforce::Collection
@jeffdonthemic
jeffdonthemic / app.rb
Last active September 3, 2019 15:16
Refresh Token from Salesforce
begin
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
@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 / app.js
Created November 16, 2018 21:47
SLDS Modal
function openModal(name) {
$("#"+name).addClass('slds-fade-in-open');
$("#backdrop").addClass('slds-backdrop_open');
}
function closeModal(name) {
$("#"+name).removeClass('slds-fade-in-open');
$("#backdrop").removeClass('slds-backdrop_open');
}
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<actionOverrides>
<actionName>Accept</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>CancelEdit</actionName>
<type>Default</type>
</actionOverrides>
// create the association object with the final data
associations = {
"elements": elements
}
// create all of the associations
request({
url: 'https://api.clover.com:443/v3/merchants/'+process.env.CLOVER_MERCHANT_ID+'/category_items',
method: 'POST',
headers: {
List<Product2> products = [select id, name from product2 where productcode = 'foo'];
Set<Id> ids = (new Map<Id,Product2>(products)).keySet();
System.debug(ids.size());
@jeffdonthemic
jeffdonthemic / bulk-api.json
Created May 25, 2016 11:43
Trailhead Bulk API JSON Import
[
{
"name": "Insuron Bulk Company"
},
{
"name": "Orboid Bulk Company"
},
{
"name": "Bovis Bulk Company"
},