Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Currently being awesome

Jeff Douglas jeffdonthemic

💭
Currently being awesome
View GitHub Profile
@jeffdonthemic
jeffdonthemic / index.js
Last active Jan 20, 2021
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
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html
@jeffdonthemic
jeffdonthemic / CustomAccountLookup.page
Last active Jan 12, 2021
Roll Your Own Salesforce "Lookup" Popup Window blog post
View CustomAccountLookup.page
<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
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
jeffdonthemic / app.js
Created Jul 7, 2014
Simple socket.io 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'});
res.end(index);
});
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');
jwt.getToken({
@jeffdonthemic
jeffdonthemic / httparty.rb
Last active Aug 6, 2020
HTTParty Examples
View httparty.rb
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 / gist:7247654
Last active Aug 6, 2020
Passing parameters in an Angular.js Controller to a Resource
View gist:7247654
<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 Jun 10, 2020
Delete a file using signed commits
View do_magic.rb
# 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
@jeffdonthemic
jeffdonthemic / do_magic.rb
Last active Jun 5, 2020
Remove github files from tree
View do_magic.rb
# https://github.community/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 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.
Restforce::Collection