Making a server logs available online with Firebase (Part 2 of 3)

This is the second part of the post. The first one is available here.

Uploading the server logs to Firebase.

This task proved to be very simple. I wanted to achieve the following

  1. Add a timestamp to the message.
  2. Upload the message to Firebase. Each of the users should have their instance of the log file.
  3. Print the message into the log.
  4. Erase the old messages every 10 minutes.
Without going much further into the details, here is the class I ended up using.
package com.spreys.udacity;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with Intellij IDEA
 * @author vspreys
 * Date: 18/04/15
 * Contact by: vlad@spreys.com
 */
public class Logger {
    private static final SimpleDateFormat TIMESTAMP_FORMAT 
         = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    private final DatabaseReference databaseReference;

    public Logger(String username) {
        FirebaseDatabase database = FirebaseDatabase.getInstance();
        this.databaseReference = database
                                    .getReference("logs/" + username);
        startCleaner();
    }

    /**
     * Prints out message into the console with the current date/time
     * @param message message to be printed
     */
    public void println(String message){
        String timeStamp = TIMESTAMP_FORMAT.format(new Date());

        String messageWithTimestamp = timeStamp + ": " + message;

        //Print out the message
        System.out.println(messageWithTimestamp);

        //Update the database with the new message
        databaseReference.push().setValue(messageWithTimestamp);
    }

    private void startCleaner() {
        new Thread(new Runnable() {
            public void run() {
                do {
                    databaseReference.setValue(null);
                    println("The logs have been cleaned");

                    //Clean the logs every 10 minutes
                    waitFor(10 * 60);
                } while (true);
            }
        }).start();
    }

    private void waitFor(float seconds){
        try {
            Thread.sleep((int)(seconds * 1000)); 
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

Making a server logs available online with Firebase (Part 1 of 3)

About the project

Over the last 12 months or so I have been working on a small Java application which needs to be continuously running in the background. The application itself is not that interesting, all it does is collecting the information from different APIs and sending me occasional emails when it finds new information. It has only two users (including myself), and I have no intention of making it public.

The setup around this application, however, is a lot more interesting, and I have learnt a lot from it, so I thought I would share some of my learnings.

The problem

Until I have implemented the solution described below the only way to read the logs of my application (it prints a lot of time) was to SSH to my server, and open an instance of the “screen” application on which it runs. It was way too many steps, and it meant that I could only do so from a computer, so I thought I should make them available on the Internet so that I could access them from any device which has a connection to WWW. I decided to use Firebase for this purpose.

I will separate the whole process into three parts:

  1. Setting up Firebase (this article);
  2. Updating my Java application to start uploading the information to the server;
  3. Creating a website which can access the data;

Firebase setup

I have created a new project from the Firebase console by giving the name and my location.

screen-shot-2016-09-11-at-8-27-01-am

Then I needed to add a service account which would be used to write the logs. I have followed the official Firebase documentation to achieve that step.

As I mentioned, I have two users (including myself), so I added two accounts in the Firebase console. I went to “Auth” section and then selected “SET UP SIGN-IN METHOD”.

screen-shot-2016-09-11-at-8-31-15-am

screen-shot-2016-09-11-at-8-32-07-am

For now, I only needed to “Enable” the simple “Email/Password” option. After that, I could return to the “USERS” section to add my two accounts.

screen-shot-2016-09-11-at-8-33-46-am

That was all of the setup I needed on the Firebase side.

 

Design your future presentation at AUT

On the 12th of May this year Auckland University of Technology gave me this amazing opportunity to give a speech during their “Design Your Future” event. I have spent the last 5 and a half years studying at AUT part time and I was fortunate to meet fantastic people who are very passionate about Software and Education.

I told about my journey into software development to Dr Stephen Thorpe who asked me to share this story with the students of AUT.

You can find my presentation below. It’s about my Successes, Failures and everything in between.

 

Tools for remote software development teams collaboration

Over the last 2-3 years I had several opportunities to work with teams which don’t share the same office. It comes with its own challenges, so I wanted to create a short (hopefully) post to list some of the software which proved to be useful for the remote teams collaboration. In this post I am not going to cover open source software, as it is a very different beast, but I’d rather focus on small(ish) private projects with team size of up to 5 people.

Source Versioning Control

I have tried a few different systems, including keeping the source code in a shared Dropbox folder (yes, that did happen and no, I’m not proud of it), private SVN repositories, Team Foundation Service, Bitbucket and a private Github repository.

All of them come with their own pros and cons. Personally I would stop on either Team Foundation Service, aka Visual Studio Online or a private Github repository.

Github is very pleasant from the coding perspective, it has a very mature UI, it is easy to make pull requests, merge and fork code, it is possible to quickly overview all of the code changes and it is very fast. All of that been said, in most of the cases Visual Studio Online would win for me for two reasons:

  1. It is free for teams of up to 5 people
  2. It combines project managements tools as well as the version control system, and having the two tools to work side by side is awesome.

Communication

Emails, phone calls, Skype, Facebook groups, Google Hangouts and Slack are the tools I have been using for the team communication. So far Slack is the winner. It allows to create different channels for different purposes, it is very easy to search the communication history, there is an insane amount of integrations with different services, it is possible and easy to share files and images and it is free unless your team is getting very big.

Documentation

So far nothing managed to convince me to move away from the Google Docs. Ability for several people to work on the same document at the same time is priceless. It is very fast, easy to use and it is free.

Diagrams

For a long time I was a very big fan of Lucidchart. It is working fast, it allows to design any type of a diagram I could think of, it allows an online collaboration and it is very easy to use. All of this been said, I have found their current pricing model a little much, which eventually forced me to move away from Lucidchart. For better or worse I don’t need to create diagrams very often, so I might use the software for a couple of days every couple of months and then forget about it. And their restrictions on the free version of the product are rather aggressive.

So lately I have been using draw.io. It is almost as powerful as Lucidchart and it is completely free. Plus it allows to save all of the charts on Google Drive.

Design

I don’t have to say too much on this topic. Invision does everything I could ask from a design software. At times I find it unnecessary hard to use, but maybe that’s because I’m not spending too much time in it.

Project Management

Researching a good project management software was one of my assignments at the university a few years back. I have tried a lot of different applications some of which are better than others, but I’m yet to find one I would fell in love with. Visual Studio Online is my current tool of choice. Mainly because it is in the cloud and it is free for small team.

Continues Integration System

Argh, CI is something we should use a lot more often than we do. The amount of times something is working on one machine, but not the other is too high and CI could totally resolve this problem. Unfortunately I’m yet to find an easy to setup solution with low overhead. The best I have found so far is a standalone installation of TeamCity. It does require a lot of resources and setting it up to work in a cloud is not as straight forward as I’d like it to be.

Source of Truth

It is very easy to get lost when so many different tools are used. Personally I found it incredibly valuable to have a website to store all of the build artefacts including exported versions of documents, wireframes, designs, copies of diagrams, application builds, etc, all stored in one easily accessible and secured location. WordPress is my GoTo engine whenever I need to create a website. It doesn’t take longer than a couple of hours to setup a brand new website from scratch and start storing the documentation.

Hobbies. How do I unwind from work.

Humans are not machines, we cannot work 24 hours per day and we have a very limited supply of time. A lot of us work 8 to 9 hours per day (if not more) and are having a commute of up to two hours per day. Adding on top of it a healthy amount of 8 hours of sleep and we are left with approximately of 4 hours per day. So what can we do with this time?

Over the years I have tried many different things including going to the gym, having a second job, studying, playing video games, watching countless amount of TV shows, spending time on social media, etc. So much of it was such a waste of time! I do think that having a hobby is crucial, but over time I dismissed some of the hobbies as being disruptive to my lifestyle, so I think it’s time to share my experience.

Sport

Everybody keeps on stressing how important exercising is and it is for a good reason! At some point of my life I have filled in every minute of my time with “stuff”, so I didn’t have any time to exercise (at least I kept on telling it to myself). I was working remotely in the morning, taking my motorbike to work, working for the whole day, taking my motorbike back home and studying until I fall asleep in the evening. That was a complete disaster for my health and the energy level! In just three months of this routine I have gained 5 kilograms of weight, became insanely addicted to coffee and other energy drinks and still felt like a zombie until I decided that enough is enough. I’ve tried many different sports to keep healthy including running, going to the gym, swimming, rock climbing, etc, and I hated most of it. Here are the things which did work for me though:

Going to the gym with a friend

I used to go to the gym on my own. I started a few times, I tried multiple different programs, I tried classes and free weights, I had a personal trainer at some point of time, but no matter what I’ve tried, I secretly hated all of it. Until one day I have started going to the gym during the lunch break with my ex-coworker and a good friend. All of a sudden from boring routine it became a nice adventure and something I was actually looking forward to every day. We’ve been doing this for over a year and it was absolutely incredible experience.

Playing tennis

I’ve started playing a few months ago. I’m pretty bad at the game, but I do enjoy the social factor and getting better over time.

Walking

Riding a motorbike to work is incredible. I get to work within 20 minutes, it costs me $10 per week and I don’t need to pay for parking. When I started doing this I thought I would never go to any other way of commuting. But then I have realised that I can walk to the train (20 minutes), walk from the train (another 20 minutes) and do the same route on the way back. That’s just under an hour and a half of walking each day. And it really changed the way I feel. My level of energy increased, I got a chance to listen to a few audiobooks I would’ve not listened to otherwise and my overall health improved. Walking proved to be simple and effective. And the fact that I’m going to/from work gives me purpose which made it a lot easier than just walking for the health benefits.

Hanging out with people

It’s crazy how easy it may get to lose contact with people. They say that we make our best friends in school and we really struggle making friends after the university. Nowadays I try hard to keep in touch with people. That can mean anything from having a coffee with an ex-coworker, organising a BBQ for a group of people, getting away for a weekend camping, etc.

Practicing Guitar

Having a hobby which does not involve me staring at my computer and solving problems gives me real relaxation. And I do love music. Yousician and Rocksmith are making this experience even more fun!

Reading books and listening to audiobooks

There is so much to learn in this incredible world. I often ask people what books inspire them and add them to my “to read” list. I have a subscription to Audible and I listen to Audiobooks while walking. I also use Amazon’s Word Runner to read books while I’m on the train.

Watching TV shows

People create incredible TV shows all the time. The trouble is that I find this type of activity a waste of time, so I found a little “hack” which really works for me. I started watching my TV Shows on a tablet with wireless headset while doing other routine tasks. I watch TV shows while ironing my clothes, cleaning the apartment, doing dishes and other types of activities which do not involve active brain activities.

How about you?

I would be keen to hear what other professionals do to keep sane. Please share your hobbies in the comment section below!

How much time does an average developer spend per day writing software?

It is not a secret that a lot of IT projects go over budget, over time and get released with a lot less functionality comparing to the original plan. There are several factors contributing towards this and a lot of them are out of scope of this post. But the one I want to focus on, is that developers usually spend a lot less than 40 hours per week writing software. A lot. Which makes it very hard for the project managers to deal with estimations. Let’s say that it is estimated that a project will take 80 hours of the development work. For the sake of the argument let’s say that this estimate is very accurate. Does it mean that a single developer can finish the project within two weeks or that two developers can finish it within one week? The answer is no, because developers don’t spend 8 hour per day writing code.

So the question is, how much less? Well, of course, it depends on individuals and their environment. I have read a few books on this topic, some suggest that the answer is no more than 6, others, crazy enough, say that they cannot get more than 2-3 hours out of the day to actually build software.

Usually this is not because they are lazy! let’s admit it, we love writing code. This is why we do it in the first place. But aside from doing development, there is a huge amount of tasks that needs to be completed by devs. Meetings (Sprint Planning, Sprint Retrospectives, Daily Standups, Client Demos, Performance Reviews, regular catch-ups with the managers, Coffee breaks with the colleagues, etc, etc, etc) can stuck up to a couple of days per week. Communication is another big factor which prevents developers from doing the actual work. I am not talking about disruptive communication here (although that is also a factor for a lot of us, because humans are social creatures), but rather productive communication. A manager could tap you on a shoulder to ask a question about the product, a QA specialist may want to discuss a bug with you, your peer may want to discuss with you how to approach a particular problem and so much more. Emails, Slack and other IM messages can easily take an hour per day as well.

What’s the remedy?

And the answer is it depends! There are multiple ways to improve productivity of individuals and of the departments. Some needs to be enforced by the managers, others can be employed by the individuals themselves. I am going to cover a few techniques I personally found useful in the later posts. You can have a look at my Speed Reading to learn how to reduce time spent on reading emails and blog articles, but before you jump to a solution you need to find out whether you have a problem and if you do what exactly the problem is. Which leads me to a software I have been using lately to find my bottle necks.

RescueTime

RescueTime is a fantastic tool to find out what you spend your digital day on. It runs in the background and it analysis what applications you use and what websites you visit. RescueTime can then provide you with daily, weekly, monthly and annual reports about your productivity score and the categories you spend most of the time on. Here is a screenshot of my report for February 2016 to give you an example:

Screen Shot 2016-03-13 at 9.12.52 AM

As you can see from my report only 29% of my time was spent on Software Development. It doesn’t mean that the rest of the time I don’t do anything. You can see that 15% of my time is spent on Communication & Scheduling. That is my emails, IM messages with the team and working with a product backlog using Jira. Another 11% I have spent on Reference & Learning. At the moment I am working on Android Nanodgree from Udacity and finishing it off is one of my annual goals. Also Stackoverflow, Apple and Google documentation falls under this category.

Using this application is effortless, and it provides a good inside into my days. It is also free. ResuceTime does provide a paid subscription model which I have tried, but personally I didn’t find it useful. Do keep in mind that information is stored in the cloud, so we never know what it is used for. Otherwise, I encourage you to give it a go!

I would be curious to know how much time you spend on software development and whether you have used anything similar to RescueTime and how did you like/hate it.

Speed Reading. How to start reading 2 to 6 times faster

Why does an average human read with the speed of 200 word per minute?

There a few reasons, but the main one is that usually we pronounce everything we read in our heads and that takes a lot of time! It doesn’t help much with the understanding of the material we are reading, but it is what we naturally do.

The other big reason, although this one is a lot smaller, is the eye movement. It takes time for us to move our eyes from one word to another and then all the way back to the next line of text.

So how can we improve?

There are people who read fast. Usually they do it by glancing at a bigger portion of the text. Instead of reading the text word by word, as so many of us do, they read 2-3 words, or even the whole line of text. Imagine if you could read the whole line of text by just glancing at it? Then you would only need to move your eyes from the top of the page to the bottom with no left to right (or right to left) eye movement.

Learning this technique is not easy. Fortunately in our age there are technologies which could help us to read faster even without hours of practice. There are different ways software could help us, but in general they solve the same two problems. They eliminate the eye movement and they force us to switch from one portion of the text to another fast enough to prevent us from reading that text in our heads.

Software I have personally tried.

Spritz

By far this one is the most interesting solution I have seen. They go one step further then other systems by highlighting the most important portion of the word which our eyes should focus on. But it’s enough of me talking. Head over the their website and try it yourself right of their homepage.

But Spritz is just a patented technology, they don’t really provide any final products. What they do is allowing other companies to use their technology in their own products. Samsung used to partner with them for their Samsung Gear devices. And there are other product and services around which implement Spritz as well, but nothing I could personally use in my day to day life as far as I could see.

Spreeder

Spreeder looked interesting enough for me to buy their software, but I was a bit disappointed. I was hoping that this software would allow to me to speed read anything including the emails I receive and website articles I read. My hope was that I could just copy and paste the content into their application and then press the run button. It doesn’t exactly work that way. Before you can Spreed anything you first need to create a new item in your library by giving it a name, specifying the author, etc. Only then you can hit the run button.

I’m sure there are a lot of people who would and do enjoy their products, but it isn’t for me.

UseClark

I have shared my disappointment about Spreeder on Twitter and people from UseClark offered me to try out their plugin for Google Chrome. I don’t usually use Chrome, but decided to give it a go and was really impressed. Once activated UseClark extension removes all of the distractions from the website including ads, menus, etc, and focus on the content of the article. Once you hit the play button the application starts highlighting the portion of the sentence you need to focus on. It’s easier to show then to explain, so here is a quick demo I have made:

One interesting fact I have noticed about this extension is that it doesn’t eliminate the eye movement and I have conflicted feelings about it. On one hand I wonder if it would become very tiring for eyes to move with this speed for a prolonged time. On the other hand it does help to understand where in the article you are which provides some context. The other thing which I’m not particularly happy about is that the application is pausing before scrolling down. You can see it on the 21 second of my demo. Not sure how this could be solved though. Maybe a faster scrolling could help or maybe slower but more consistent scrolling could be an option, so that the page scrolls while you read. Not sure if that would be any better, but it would be interesting to try out. Also the extension breaks every now and then on scrolling, it may scroll and then get stuck, so I have to manually switch to a different sentence to continue.

Looking at UseClark it seems that there are many more applications to come and I would be very excited to see what they are.

Have you every used any speed reading technologies?

Tell me about your experience in the comments and I would be very interested to try learn what you think and try out new products.

What are the Career Services at #Udacity?

In my opinion, Udacity is the best resource to learn mobile development, which I am so passionate about, but there is one more critical value which Udacity provides – Career Services. In this post I will try to summarise what career services Udacity provides and how they helped me personally.

Best of all Career Services are summarised by Kathleen Mullaney who is a Vice President in Careers at Udacity in her Linked In summary.

Screen Shot 2016-02-16 at 9.44.37 PM

Udacity is not just about the education (which is, of course, hugely important), but it is also about helping the student to find companies who would appreciate their newly acquired skills.

Job Guarantee

Udacity has recently launched “Nanodegree Plus” program which, at the time of this writing, is only available in the United States. This program includes everything else a Nanodegree program does, plus, no pun intended, it promises to make a full refund of the tuition if the student would not find a job with a help of Udacity within 6 months of the graduation. That’s a pretty big promise if you ask me!

Career Reviewers

While getting technical skills, Nanodegree students would also learn how to create an effective Resume, Linked In and Github profile. Better still, students can submit their Resumes, Linked In and Github profiles to the career reviewers who would give their professional and personal feedback and students can re-submit their work as many times as required until it gets to the best possible shape.

Professional Portfolios

Most of the work students have to do around their Nanodegrees is based on projects. So by the end of the course each of the students will have 4-5 applications or websites which they have personally built to put on their portfolio to demonstrate to the potential employers.

Mockup Interviews

All of the students can participate in mockup interviews for the position they are interested in and get personal feedback on how they answered the questions.

Udacity Profiles

Each of the students can create a profile in the Udacity’s directory which is reviewed by partner companies. In that profile students can specify whether there are looking for on premises or remote jobs as well as the freelance opportunities.

Udacity’s Career Resource Center

The Resource Center provides a lot of fantastic articles to help students who are looking for a job.

So what have I personally found the most useful?

Personally I think that gaining the technical knowledge was the most beneficial for me when I was looking for my last job, but I have also loved the fact that I had a portfolio of the applications which I could bring to the interview.

What did I learn after visiting #Intersect2016

I have been very fortunate to visit the very first conference held by Udacity called Intersect2016. I have met a lot of very inspirational individuals including Udacity students and employees as well as some of the leaders of technology era in Silicon Valley. It took me a long time to digest all of the information and emotions I have received during this event, but now is time to put my thoughts together and share the main ideas that affected me personally during the event.

DSC9816

Never give up

This thought has been repeated many times during the intersect, but I think best of all it has been put by Laura I. Gomez who is a CEO of Atipica. Laura’s career is very inspiring, she is a very intelligent and highly motivational lady, I highly recommend you to follow her on Twitter (and she has one of the best Twitter usernames ever!).

Screen Shot 2016-02-08 at 7.37.15 PM

Only 1% of interesting things has been invented

Sebastian Thrun who is a founder and a CEO of Udacity gave this quote during his opening keynote. I highly encourage you to watch his speech on youtube as it is exceptionally inspiring. His speech starts at 20:11.

Screen Shot 2016-02-08 at 8.19.11 PM

Online professional presence is important

Ana Díaz-Hernández gave a small presentation during one of the break-out sessions telling us how important it is to have an online presence. Her presentation inspired me to create a Twitter account as well as this blog.

Networking is even more important

I have to be honest with you, I’m not very good at networking. I rarely participate in Meetups and conferences and I think that Intersect was the biggest conference I have ever been invited to. But I incredibly enjoyed it. First of all meeting so many people and learning about their background as well as their stories was fascinating. It was nice to hear what people think about the current state of the technology era and where they think we are heading as well as to hear the challenges and joys of working in IT.

Udacity kindly organised business cards for all of us and we had a chance to exchange them among ourselves, so for the couple of days after the event my LinkedIn profile received quite a bit of attention. The next day after the Intersect I have received a call from a recruiting agent who saw my profile on LinkedIn and was wondering if I was interesting to learn about a new opportunity. I am not looking for a job at the moment, but I think it was an interesting development.

Algorithms and data structures are still important, but is it for much longer?

This topic has been brought up a lot during the intersect by many people. Udacity is very different from the traditional computer science education. In my experience Computer Science taught by Universities covers a lot of the basics, but not so much the latest technologies which are actually used by the companies. So traditional path for the students is to complete a computer science degree, then go to a company as an intern or a junior developer and learn the stack of technologies on the job. Udacity on the other hand provides a more relevant education, but, to some extent, does not cover the basics as well as Universities do.

One of the examples is Algorithms and Data Structures. A lot of the students mentioned that this is a missing piece of the education provided by Udacity, but a lot of the companies are asking for this knowledge during the job interviews. Advise from Makinde Adeagbo – learn it yourself. Makinde suggested that a lot of the companies are moving away from this requirement, but until then we are responsible for getting our own knowledge.

Hard work pays off

The last couple of years of my career were hard. I have been working full time as a mobile developer, studied part time in a university, studied at Udacity, have been working part time at Udacity as a Code Reviewer and have been invited to write an iOS application for Udacity called Kudacious. I won’t lie, it was exhausting. A lot of the time I had to spend my weekends, evenings and holidays in the front of the computer, while so many people around me were having fun, watching TV shows, playing video games and so on.

But I can tell you, it was totally worth it. During the Intersect I have been named as one of the Inspiring students and it was one of the proudest moments of my life.

Screen Shot 2016-02-08 at 8.04.00 PM

It is never too late to switch careers

There were a lot of individuals who are just starting out in their career, but what surprised me (to some extent) is how many people were there who wanted to switch to a completely new career. I think it is a very scary step for anybody and I have a lot of respect for these people.

The future of education is changing today and it is not going to be the same ever again

Education provided by Udacity is starting to be recognised by very large technology companies, it is affordable (starting from $200 per month), people can learn at their own pace, and when they leave Udacity they are prepared for their first job. At the end of a Nanodegree students have a portfolio of their work, their CV, LinkedIn and Github profiles are reviewed by professionals. And they have participated in practice interviews. Other companies will have to adapt or seize to exist.