There may be times that you’d need to clean up resources such as temporary files or in my case deregister a container from a WebSphere Liberty Collective. To set this up, we just need to use
bash to handle any cleanup. This will also work with
docker-compose.yml built stacks and
Continue reading Clean up on Docker shutdown
Actually this is more automatic integration testing since the components are tied together. I used Weld for my CDI, EclipseLink for my JPA and Hibernate Validator for my Bean Validation implementations and H2 for my in-memory test database.
Continue reading Automatic Unit Testing JPA + CDI + Bean Validation
There are many algorithms that generate and validate Canadian SIN numbers. This is the one I use with bean validation. Unlike most other implementations I took into consideration that
8 is not used as the first character in a Canadian SIN. In addition, I utilized a map to deal with the doubled number for the even digits rather than doing the calculation and dealing with greater than 10 results. No regexes are involved either.
Continue reading Canadian SIN Bean Validation plus Generation
StatsCan has posted the rules for what is a valid Canadian postal code:
The postal code is a six-character code defined and maintained by Canada Post Corporation (CPC) for the purpose of sorting and delivering mail. The characters are arranged in the form ‘ANA NAN’, where ‘A’ represents an alphabetic character and ‘N’ represents a numeric character (e.g., K1A 0T6). The postal code uses 18 alphabetic characters and 10 numeric characters. Postal codes do not include the letters D, F, I, O, Q or U, and the first position also does not make use of the letters W or Z.
This post shows how I do the validation using two regular expressions… a strict one and a permissive one combined with Java Bean Validation.
Continue reading Canadian Postal Code Validation
When I designed my programmer’s portfolio site one of the things I noted it needs was my contact information. One alternative to doing that is a contact form, which has the advantage of avoiding spam from being sent to your e-mail address. However, I also found it very unnatural compared to having it open the user’s e-mail client or phone client. The
tel: links are the standard practice for contact information links, but it has the flaw of spam bots extracting the information and storing it for robocalls in the future.
So I get around it by obfuscating the links and text so that these bots would have a slightly harder time of getting the data.
Continue reading Obfuscating mailto and tel links