Spring Data Pageable JPA Filter Query with 3 of 4 Parts of Composite Key via a Query Method

Let’s say you are using Spring Data and you have a “Composite Key” (ie, a tuple or EmbeddedId). Generally, you may want to query by the whole composite key (ie, by ID), which is generally fairly straightforward with a JPA “query method” (still not sure that is the official name)….

Continue reading

Allow BitBucket Webhooks Access to Jenkins on an AWS EC2 instance behind a Private VPC

Let’s say you want to let BitBucket notify Jenkins to do a build every time a PR is created or a branch is updated. You can leverage the BitBucket webhooks to do this. If so you will want to allow traffic from the BitBucket CIDR addresses here: https://support.atlassian.com/organization-administration/docs/ip-addresses-and-domains-for-atlassian-cloud-products/#AtlassiancloudIPrangesanddomains-OutgoingConnections If you…

Continue reading

Convert any Image into ASCII Art for a Custom Spring Boot Banner

Matrix ASCII Art with Trinity, Neo and Morpheus

If you’d like to override the standard Spring Boot banner with something custom, then you’ve come to the right place. Find any image you want to convert to ASCII art. Then, download the following Git Hub project https://github.com/qeesung/image2ascii  Now, you can run a script like the following: You’ll see something…

Continue reading

Using AWS CloudFormation to Deploy a WebSite with AWS S3 and AWS CloudFront

This will use AWS CloudFormation (ie, Infrastructure as Code) to create an S3 Bucket with a good bucket policy and CORS configuration. Also, it will setup the CloudFront distribution to point at this S3 Bucket. Lastly, it will create an AWS Route 53 record set for the website. You will…

Continue reading

AWS DLM LifeCycle Policy for Creating Snapshots for EBS Volumes on an EC2 Instance

It seems AWS CloudFormation does not readily support creating EBS Volume Snapshots via BlockDeviceMappings‘s EBS property. Luckily there is an alternative approach that allows you to setup a DLM LifeCycle Policy which scans for EC2 Instance Tags (apparently there is also no support to really tag the Volumes directly via CloudFormation that…

Continue reading

JUnit Hamcrest: Matching a Group of Map Properties from Any Map within a List

Let’s say that you have an ArrayList of LinkedHashMaps. Let’s further say that you would like to find any Map within that List, which contains a set of Properties. Here is how you can write a Unit Test with Hamcrest Matchers to do this: Here we can see that we…

Continue reading

Handling Multiple Date Formats with One Method via Joda Time

Handling Multiple Date Formats with One Method via Joda Time

Nearly any project that amounts to anything must handle the processing of Dates, Times, and Timestamps. When it comes to Java projects, I see time and time again that developers just insert date formatters anywhere and everywhere. This violates the concept of modularity and making a segment of code do…

Continue reading