Skip to content

Instantly share code, notes, and snippets.

Currently being awesome

Jeff Douglas jeffdonthemic

Currently being awesome
View GitHub Profile
jeffdonthemic / do_magic.rb
Last active Jun 10, 2020
Delete a file using signed commits
View do_magic.rb
# This code is based upon the following links:
# This creates a signed commit on the correct branch, but there are 0 changed files.
jeffdonthemic / do_magic.rb
Last active Jun 5, 2020
Remove github files from tree
View do_magic.rb
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,
recursive: true
# select only the files for THIS badge
jeffdonthemic / app.js
Created Jul 7, 2014
Simple example
View app.js
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'});
View org_connection.js
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');
jeffdonthemic / restforce.rb
Created Jan 24, 2020
Restforce monkey patch
View restforce.rb
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.
jeffdonthemic / UploadAttachment
Created May 30, 2014
Visualforce Page for customizing Attachments. See UploadAttachmentController.
View UploadAttachment
<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 / httparty.rb
Last active Dec 17, 2019
HTTParty Examples
View httparty.rb
options = { :body =>
{ :username => 'my',
:password => 'password'
results ="", options)
## example for post with papertrail and basic auth
jeffdonthemic / apex-crud-fls.txt
Last active Oct 9, 2019
Simple Apex Controller with CRUD and FLS
View apex-crud-fls.txt
This simple controller (without CRUD and FLS) ...
public with sharing class AccountController {
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 / index.js
Last active Oct 4, 2019
Lambda function to commit code to github. See blog post for more details.
View index.js
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
jeffdonthemic / app.rb
Last active Sep 3, 2019
Refresh Token from Salesforce
View app.rb
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
You can’t perform that action at this time.