Skip to content

Instantly share code, notes, and snippets.

View damianmcdonald's full-sized avatar

Damian McDonald damianmcdonald

View GitHub Profile
@damianmcdonald
damianmcdonald / retry_utils.py
Created January 14, 2024 12:40
Python helper functions for implementing retry with exponential backoff and custom error checking
class RetryUtils():
"""
Provides helper functions for implementing retry with exponential backoff.
"""
def retry_with_backoff(
function: Callable,
function_args: list[Any],
allowed_exceptions: list[str] = [],
retries: int=5,
@damianmcdonald
damianmcdonald / README.md
Last active November 23, 2022 10:45
Node.js application which creates an S3 bucket and uploads a file with permissions and metadata

Overview

A Node.js application which creates an S3 bucket and uploads a file with permissions and metadata.

This example uses the createBucket and upload methods of the AWS SDK for JavaScript.

See API doocumentation for detailed information; https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

To see the available parameters for the s3 upload method, see the paramObjects.js file.

@damianmcdonald
damianmcdonald / aws-service-principals.txt
Last active January 24, 2020 10:51 — forked from shortjared/list.txt
List of AWS Service Principals
a4b.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
amazonmq.amazonaws.com
apigateway.amazonaws.com
appsync.amazonaws.com
athena.amazonaws.com
autoscaling.amazonaws.com
b
backup.amazonaws.com
@damianmcdonald
damianmcdonald / README.md
Last active April 20, 2020 19:09
Common S3 and S3 Glacier actions using the AWS S3, S3API and Glacier APIs

A gist showing some common S3 and S3 Glacier actions using the API's listed below.

Actions

  • Create an S3 Bucket
  • Upload files to bucket choosing different storage classe
  • Download objects from S3
  • Restore objects from S3
  • Configure an S3 lifecycle policy
  • Create Glacier vault
@damianmcdonald
damianmcdonald / ApacheHttpClientMultiPartUpload.java
Created July 19, 2015 12:00
Multi Part Upload using Apache HttpClient 4
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.HttpClientBuilder;
import org.json.JSONObject;
@damianmcdonald
damianmcdonald / JerseyRestClientMultipartUpload.java
Created July 19, 2015 11:16
Multi Part Upload using Jersey REST client
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.MultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import org.json.JSONObject;
@damianmcdonald
damianmcdonald / JerseyRestClientWithSSLContext.java
Created July 19, 2015 10:21
Use of Jersey REST client with SSLContext
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.json.JSONObject;
import javax.net.ssl.SSLContext;
@damianmcdonald
damianmcdonald / ApacheHttpClientWithSSLConnectionSocketFactory.java
Created July 19, 2015 10:06
Use of Apache HttpClient 4 with SSLConnectionSocketFactory
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
@damianmcdonald
damianmcdonald / MongoDBToCasbahExamples.scala
Created July 12, 2015 09:16
MongoDB commands to Scala Casbah examples
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.commons.MongoDBObject
class MongoDBToCasbahExamples {
/* The BSON structure that will be used for the examples
{
"userId": "134256",
"currencyFrom": "EUR",
"currencyTo": "GBP",
@damianmcdonald
damianmcdonald / EmbeddedMongoDBImmutableTest.scala
Created July 12, 2015 08:25
Example ScalaTest case using Embedded MongoDB with the ScalaTest EmbededMongo trait - Immutable Usage
import java.util.Date
import com.github.simplyscala.MongoEmbedDatabase
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.commons.MongoDBObject
import de.flapdoodle.embed.mongo.distribution.Version
import org.scalatest.{BeforeAndAfter, FunSpec}
import org.slf4j.LoggerFactory
class EmbeddedMongoDBImmutableTest extends FunSpec with MongoEmbedDatabase with BeforeAndAfter {