Thursday, June 4, 2015

textutil in Mac OS X

Lynx had a useful option to convert html pages to text. 
lynx -dump input.html > output.txt
And I miss that on Mac OSX. I stumbled upon an alternative for this - textutil. It comes bundled with MAC OS X. Converting an html file to text can be done in this way:
textutil -convert txt ~/Downloads/your-fav-profile.html

There should be a file created: ~/Downloads/your-fav-profile.txt

RTFM. Textutil is a utility extracted from the Cocoa text system 

Monday, June 1, 2015

Pushing Docker containers to more than one registry using Gradle

In the early days, we had to maintain two docker registries, one in AWS us-east-1 and the other in eu-west-1. This required us to build our containers and then push it to both registries. Below is a build.grade using Ben’s Gradle-Docker plugin to do the following:
  1. Builds a docker container based on the Dockerfile in the root directory.
  2. Tag and push to both repos (us-east-1 and eu-west-1).
The root directory (project folder) should contain your Dockerfile and build.gradle.

This is how the build.grade looks like:


Note that you can also build this on Jenkins.

S3's Eventual Consistency

If you are working with AWS services, particularly S3, you might have encountered S3's eventual consistency model (or you'll eventually encounter it). This post here describes concisely the eventual consistency issue. We have similar systems, where data is published to S3 and then notified to an online system about its availability using a messaging bus. There have been occasions when the message has been consumed by an online service to later discover that the S3 data was still not accessible.

Collections vs Iterables: Java


One important note while considering Collections vs Iterables is that Collections in some sense assume that you have loaded the data into memory and have access to the size(). On the other hand, Iterables allow for lazy evaluation of the data. This becomes an important considerable when you are working with large scale data just being loaded from a database. In a sense, it allows you “stream” the data.


Here is another good discussion:
http://stackoverflow.com/questions/1159797/when-should-i-use-iterable-vs-collection-in-java