Skip to content

Instantly share code, notes, and snippets.

@kheast
kheast / simple-salesforce-jwt.py
Created January 30, 2022 23:16 — forked from davidmreed/simple-salesforce-jwt.py
Using simple_salesforce with JWT authentication
import jwt
import requests
import datetime
from simple_salesforce import Salesforce
from simple_salesforce.exceptions import SalesforceAuthenticationFailed
def jwt_login(consumer_id, username, private_key, sandbox=False):
endpoint = 'https://test.salesforce.com' if sandbox is True else 'https://login.salesforce.com'
jwt_payload = jwt.encode(
{
@kheast
kheast / postmanNetSuiteTBA.js
Created August 21, 2019 17:30 — forked from michoelchaikin/postmanNetSuiteTBA.js
Postman pre-request script to generate TBA variables for NetSuite Web Services
/*
Usage:
1. Define a NetSuite environment in Postman (https://www.getpostman.com/docs/postman/environments_and_globals/manage_environments)
with the following keys set: account, consumerKey, consumerSecret, tokenId, tokenSecret
2. Add this script to your "Pre Request Script" in Postman (https://www.getpostman.com/docs/postman/scripts/pre_request_scripts)
3. Add the Token Passport in your request with variable placeholders
@kheast
kheast / cpanel_ssl_install.py
Last active April 12, 2018 09:24
Python script to install SSL certificate from Let's Encrypt into Cpanel for a single domain.
#!/usr/bin/env python2.7
'''This script will install an SSL certificate into Cpanel
for a single domain. In my case, the certificate is from
Let's Encrypt via 'acme.sh'. The script expects the certificate
to be stored in the manner described at
http://east.fm/posts/acme-cpanel-a2hosting
This script requires a single argument: the domain name.
@kheast
kheast / process_fdgg
Created February 9, 2017 19:08
bash script to submit credit card transaction to First Data Global Gateway
#!/bin/bash
# Code to submit a credit card transaction to First Data Global
# Gateway for processing. Shows the bare minimum necessary to process
# a transaction. Handy to verify validity of credentials and XML.
# Primarily intended to process transactions against FDGG test
# endpoint, but it will happily process live transactions against
# the FDGG secure endpoint, charging a real credit card for the
# specified amount.
@kheast
kheast / boto3-resource-profile.py
Created February 8, 2017 17:57
How to get boto3.resource to use a profile from credentials file
# To get boto3.resource to use a profile name, one must first
# setup a default session. The credentials provided during the
# session setup will be subsequently used by resource().
#
# See: https://github.com/boto/boto3/issues/21
# https://github.com/boto/boto3/pull/69
boto3.setup_default_session(profile_name=self.dpkg.profile_name)
self.ec2 = boto3.resource('ec2', region_name=self.dpkg.region_name)
filters = [{'Name': 'instance-state-name', 'Values': ['running']}]
for inst in self.ec2.instances.filter(Filters=filters):