Realtime People Counter with Google’s Cloud Vision API and RxJava

Welcome to the ninth blog of 52 Technologies in 2016 blog series. Recently, Google released Cloud Vision API that enables developers to incorporate image recognition in their applications. Image Recognition allow developers to build applications that can understand content of images. Google’s Cloud Vision API is very powerful and support following features:

  1. Image categorization: The API can help classify images into categories. You can build powerful applications like Google Photos that do automatic categorization.
  2. Inappropriate content detection: The API can detect inappropriate content in an image like nudity, violence, etc. It uses Google Safe search capabilities underneath.
  3. Emotion detection: This allows you to detect happy, sad or moderate emotions in an image.
  4. Retrieve text from the image: This allows you to extract text in multiple languages from the images.
  5. Logo detection: It can help you identify product logos within an image.

There are many possible applications that you can build using this powerful API. In this tutorial, we will learn how to build a realtime people counter. The application will subscribe to a twitter stream for a topic and would return number of people found in each image. We can then use this data to get advanced statistic like number of people in a time frame using RxJava buffer capabilities.

You can read full blog https://github.com/shekhargulati/52-technologies-in-2016/blob/master/09-cloudvision/README.md

CoreOS for Application Developers

Welcome to eighth week of 52 Technologies in 2016 blog series. This week we will learn about CoreOS, an Open source Linux distribution built to run and manage highly scalable and fault tolerant systems. It is designed to docker and rocket containers. When I started learning about CoreOS, I was overwhelmed by its complexity and different components that you have to know and interact with like etcd, systemd, fleet, Flannel. I am not an Ops guy so CoreOS documentation and many tutorials that I found on the web didn’t clicked with me. The goal of this tutorial is to help application developers understand why they should care about CoreOS and show them how to work with CoreOS cluster running on top of Amazon EC2.

What is CoreOS?

According to CoreOS website, CoreOS is a Linux for Massive Server Deployments. This means it is not a general purpose Linux distro that you can use as your development workspace instead, you will use it to run and your applications at scale.

Built on Chrome OS, CoreOS is a lean and mean operating system that runs minimal Linux. When you limit your OS to the bare minimal i.e. just openssl, ssh, linux kernel, gcc then you need a mechanism to run package and run applications that you want to use. CoreOS does not even has a package manager like yum or Apt. CoreOS is very different from other Linux distributions as it is centered around containers. Linux Containers is an operating-system-level virtualization environment for running multiple isolated Linux systems (containers) on a single Linux control host. CoreOS uses containers to run and manage applications services. You package application along with its dependencies within a container that can be run on a single or multiple CoreOS machines. CoreOS supports both Docker and Rocket containers.

Docker is the poster child of containers. In November 2013, I first learnt and wrote about Docker. Docker is a set of toolset geared around containers. Docker clicked with everyone and overnight became the tool that everyone wanted to learn and introduce in their organization. One reason Docker became popular very quickly is its approachability to an average developer. To use Docker, you don’t have to know Linux internals and work with complicated tools.

CoreOS developers claim that it is 40% more efficient in RAM usage than an average linux installation.

Read the full blog at https://github.com/shekhargulati/52-technologies-in-2016/blob/master/08-coreos/README.md

Hugo: A Modern WebSite Engine That Just Works

This week I decided to take a break from Scala and scratch my own itch my building an online bookshelf using Hugo. Hugo is a static site generator written in Go programming language. You can use it for building modern static websites. Static site generator takes your content files written in a markup language like Markdown, apply layouts you have defined, and generate static HTML files that can be delivered to the user. Static websites are nothing new, they date back to the first ever website in human history. We started with static websites, then moved to dynamic websites, and finally we are moving back to static websites for use-cases where it make sense. Most common use-cases for static websites are blogs, product documentation, help guides, tutorials, online portfolio or resume.

You can read full blog https://github.com/shekhargulati/52-technologies-in-2016/blob/master/07-hugo/README.md

Building A Lightweight Scala REST API Client with OkHttp

Welcome to the sixth blog of 52-technologies-in-2016 blog series. In this blog, we will learn how to write Scala REST API client for Medium’s REST API using OkHttp library. REST APIs have become a standard method of communication between two devices over a network. Most applications expose their REST API that developers can use to get work with an application programmatically. For example, if I have to build a realtime opinion mining application then I can use Twitter or Facebook REST APIs to get hold of their data and build my application. To work with an application REST APIs, you either can write your own client or you can use one of the language specific client provided by the application. Last few weeks, I have started using Medium for posting non-technical blogs. Medium is a blog publishing platform created by Twitter co-founder Evan Williams. Evan Williams is the same guy who earlier created Blogger, which was bought by Google in 2003.

Medium exposed their REST API to the external world last year. The API is simple and allows you to do operations like submitting a post, getting details of the authenticated user, getting publications for a user, etc. You can read about Medium API documentation in their Github repository. Medium officially provides REST API clients for Node.js, Python, and Go programming languages. I couldn’t find Scala client for Medium REST API so I decided to write my own client using OkHttp.

You can read the full blog here.

Python json object_hook

Today, I was building a REST client for one of the REST server applications using Python. I decided to use Python requests library for writing my REST API client. Requests is a very easy to use library that you can use to quickly bootstrap your REST API client. Writing REST client for REST endpoints was a matter of an hour. This REST API client will be used from our custom Jython(JVM implementation of Python) REPL. REST API has only two endpoints that return JSON objects. Response of first endpoint was fed to the second endpoint. I was returning the JSON response as Python dictionary. User can change values of the first response and pass it to the second API call. In Python, you work with dictionary as shown below. Continue reading “Python json object_hook”

Python abc.py Puzzle

Let me start with the confession that I am not an expert Python developer so this might not be a surprise for some of you. Yesterday, I was working on a Python REST API client using awesome requests library for one of my server application. To quickly hack my client, I created a Python virtual environment using virtualenv and installed required libraries using pip. I was ready to play with Python(again). I created a new file abc.py and added a method. For demonstration, let’s suppose our method is called hello, as shown below. Continue reading “Python abc.py Puzzle”