Skip to content

Instantly share code, notes, and snippets.

View wadewegner's full-sized avatar

Wade Wegner wadewegner

View GitHub Profile
@wadewegner
wadewegner / app.go
Created January 6, 2015 04:07
Trying out the gorilla/pat request router and dispatcher package for Go.
package main
import (
"github.com/gorilla/pat"
"net/http"
)
func main() {
r := pat.New()
@wadewegner
wadewegner / Web.Config
Last active August 29, 2015 14:12
Files for post "Running Go in Azure Websites in 4 Simple Steps"
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="d:\home\site\wwwroot\go\bin\go.exe"
arguments="run d:\home\site\wwwroot\server.go"
startupTimeLimit="60">
<environmentVariables>
@wadewegner
wadewegner / ExternalLoginConfirmation.cs
Last active August 29, 2015 14:06
Trying to get salesforce auth with OWIN working
//
// POST: /Account/ExternalLoginConfirmation
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
{
if (User.Identity.IsAuthenticated)
{
return RedirectToAction("Manage");
<?xml version="1.0" encoding="utf-16"?>
<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:siena="http://schemas.microsoft.com/MicrosoftProjectSiena/WADL/2014/11" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sienatool="http://www.todo.com"
siena:serviceId="WadeAPIServiceWadl">
<grammars>
<jsonTypes targetNamespace="http://www.todo.com" xmlns="http://schemas.microsoft.com/MicrosoftProjectSiena/WADL/2014/11">
<object name="GetAccounts_Root">
<property name="totalSize" type="number" />
<property name="done" type="boolean" />
<property name="records" typeRef="GetAccounts_records_Array" />
</object>
@wadewegner
wadewegner / TokenValidationHandler.cs
Last active August 29, 2015 14:05
TokenValidationHandler
public class TokenValidationHandler : DelegatingHandler
{
private readonly string _storageConnectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
const string errorMessage = "Unauthorized access; {0}";
const HttpStatusCode code = HttpStatusCode.Unauthorized;
var authValue = request.Headers.Authorization;
import os
import psycopg2
import urlparse
import pika, logging
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])
logging.basicConfig()
import os
import psycopg2
import urlparse
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])
conn = psycopg2.connect(
database=url.path[1:],
user=url.username,
@wadewegner
wadewegner / upload_rest.py
Last active August 9, 2024 16:01
Upload attachment to Salesforce using Python
import requests
import base64
import json
from simple_salesforce import Salesforce
userName = ''
password = ''
securityToken = ''
instance = ''
@wadewegner
wadewegner / addBatch.py
Last active June 29, 2020 20:55
Source code for blog post on using the bulk API with Python
def addBatch(instance, sessionId, jobId, objects):
request = u"""<?xml version="1.0" encoding="UTF-8"?>
<sObjects xmlns="http://www.force.com/2009/06/asyncapi/dataload">
""" + objects + """
</sObjects>"""
encoded_request = request.encode('utf-8')
url = "https://" + instance + ".salesforce.com/services/async/30.0/job/" + jobId + "/batch"
@wadewegner
wadewegner / async.py
Created April 30, 2014 17:58
Code used to run the Salesforce Bulk API to perform an UPDATE using Python
import requests
import xml.etree.ElementTree as ET
def login(userName, password):
request = u"""<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>