git tags and pushing to a remote repo

Tags are useful to mark specific versions or releases of your code in a repo on a given branch. To tag everything on the current branch, use:

git tag new-tag-name

To push a new tag to a remote repo, you can either push all tags (which is not recommended):

git push remote-name --tags

or push a specific tag:

git push remote-name tag-name

More example in this SO question.

AWS CloudFormation example for S3 bucket

Typical Cloudformation for an S3 bucket with block all public access enabled:

Resources:
  S3BucketExample:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: s3-bucket-name
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        BlockPublicPolicy: true
        IgnorePublicAcls: true
        RestrictPublicBuckets: true

‘serverless invoke local’ with Java Lambdas

If you create a Java Lambda with the provided template, you’re probably returning a response using the provided ApiGatewayResponseClass. If you run your Lambda locally with ‘serverless invoke local –function functioname’, you’ll see a response like this:

Serverless: Invoke invoke:local
Serverless: In order to get human-readable output, please implement "toString()" method of your "ApiGatewayResponse" object.

com.serverless.ApiGatewayResponse@3bd3d05e

Any other logger output will appear in your console, but in order to see the actual content of your ApiGatewayResponse, add a toString() method as the message suggests.

You include any of the properties in ApiGatewayResponse, but if you’re just interested in the JSON payload in the body of the response, then just adding this will return the body:

public String toString(){
    return this.body;
}

Learning Java 8 Streams

I’ve never had a good opportunity to use Java 8 Streams since traditional iteration approaches always seemed to be appropriate for what I needed. Working on my Sudoku related projects (in particular an implementation of a Human Solver) I needed an approach to count occurrences of numbers in Lists and also find where pairs existed in Lists.

To get started, I started with a number of simpler examples to gradually work up to what I was looking for. I’ve collected a number of my examples in this project here.