Sunday, March 25, 2018

How I turned my disaster into a huge relief

Why I was not happy* working on vscode

*Disclaimer: I have nothing against vscode, vscode community or Typescript, it was just not the right fit for me.

Did you ever feel the pressure of being forced to do something you didn't enjoy anymore?
But you had to stay, there was no escaping it, you had a goal.

That's exactly how I felt with vscode. It was exciting in the beginning, unfortunately there was one "but": it was not a perfect project for me. Typescript has never been my strength, in fact I didn't know it just 3 months ago, before I started working on vscode. 

I did not enjoy working on the project at all. It was my constant pain I had to tolerate. And here are reasons why: I wanted to learn Typescript, to contribute to something I use every day and to work on the back-end. If the first two reasons are self-explanatory, the third one need more input.

There was always an idea sitting at the back of my head that front-end was easy, back-end was more advanced. I was constantly told that at school, at work, most of my friends had the same opinion. And also all of the people I talked to about back-end vs front-end said that they hated css. When I started to work with React, I enjoyed it, it was easy and so straight forward. Even when I had some issues those were nothing compared to the back-end hell I had experienced. I tried to reject the thought that React was something I could do, I thought front-end was so easy for me because everyone can do it. It's back-end that requires more intelligence and I should head towards it.

That's exactly why I decided to go and contribute to vscode. It met all the requirements I had. Later, as I found out, it didn't meet the only big one it should: I was not happy and not obsessed about the project at all. Even finding a bug was a torture, I didn't understand half of the titles. But trying to fix those was even worse: going through tons of files, reading so much code, I still couldn't find the right spots where to start. It was so annoying, unconsciously I postponed and postponed my Releases to the last minute almost every time.

I felt jealous listening to my classmates presentations, not because working on open source was easy for them(it wasn't), but because they had passion and excitement. At least finding bugs seemed effortless and they always knew where they were going. I admired my classmates. Still I had more free time to invest into making vscode the same/similar experience. I was constantly telling myself: "It's just a beginning, it will get better, you need to get familiar with code at first". And three months later it only got worse.

At some point I decided to give up. It's not always a bad idea to come to a conclusion that it was not my place, I am not happy or helpful too much, so it was time to move on. A few of my classmates were working with React and in some places where they struggled, I saw a solution. This time I decided to contribute to something I enjoy, can contribute more and be helpful.

There was one project my classmate, Sean, is working on I spotted: addons-frontend Mozilla(AMO).
Which every his presentation I noticed how clearly I was reading the code he was showing, how I was understanding his every detail of a story. I decide to take a look at the issues and found a few interesting ones. So I decided to stick around.

How I fixed my first bug for AMO

I come to the conclusion that it's time to move on on Sunday. The day before Release 0.4 is due. I decided to abandon my bug in vscode and work on AMO. So I found this amazing "good first bug". To install the project I just need to run two commands: yarn && yarn amo:stage.

Nothing looked suspicious. I wish there was a note in the README:
"If you are a Windows user, you are doomed". 

Guess what? I am a Windows user! So I got npm error out of nowhere. I found a bug in AMO that described it.

The solution was to install Windows Subsystem for Linux... I can't describe how much pleasure** I get from installing stuff (**sarcasm). I don't even want to get into to much details here, my day was ruined, I spent 4-5 hours trying to figure it out. And even thought the process of installing Windows Subsystem was straight forward, I was getting weird errors every 5-10 minutes. It was a battle: me vs machines. I lost.

Another option was to configure a VM box: it took a while. And when it was almost done I realized that I could use my work laptop which happened to be MacBook. A few minutes later I had a built and compiled version of AMO running on my laptop.

About an hour later, after looking for a spot where a change for my issue should be implemented, I have submitted my PR. At least this story has a happy ending.

I have a hope that the hardest part is behind me, I will feel good while working with React and I will be useful to the community while learning this beautiful technology in a more advanced way.

P.S. Special thanks to my classmate Sean who decided to mentor me and help to change unit test to reflect my code changes.

P.S.S. This is a second time I have written this blog post. The first time when I have finished, I clicked "Save" button multiple times as I always did, I waited until "Saved" message had appeared and closed the tab. Switched laptops, opened my blog again and the blog post I spend about an hour and a half was gone. Today was definitely not my day.

Thursday, March 15, 2018

TIL: How to use DatePickerAndroid and TimePickerAndroid in React Native?

While working with React Native, I always tried to use built-in components instead of "reinventing" the bicycle.

So today the design mockups for my project required me to write the form for a user to pick up date and time. And I went to the React Native docs page and scrolled down the bar looking what they have to offer, which component I may use. That's how I came across DatePickerAndroid and TimePickerAndroid in API's section.

Even thought docs are quite straight forward, it took we a while to figure out how to properly use it.

Part 1. DatePickerAndroid

Let's start with DatePickerAndroid: first thing we need to do is to write "onPress" type of the function. Important step is to declare is as "async" function, otherwise you will get an annoying "await is a reserved word" error message.

Another important step that I forgot about was to import DatePickerAndroid from 'react-native' package.

In this case I have assigned data to directly to the state, if you would like to do the same DO NOT forget to add ".bind(this)", when you are calling your function: "random.datePicker.bind(this)".

You can use this function on any element that supports "onPress" property.

Another big challenge is styling DatePickerAndroid. Currently it cannot be done directly through React Native, but we can mess up a little bit with Android code:
"<project>\android\app\src\main\res\values\styles.xml" file in your React Native project.

Let's change the color scheme of the component!

If you want to use the dark theme simply change Theme.AppCompat.Light.NoActionBar to Theme.AppCompat and Theme.AppCompat.Light.Dialog to Theme.AppCompat.

Final result:

Part 2. TimePickerAndroid

TimePickerAndroid is similar to DatePickerAndroid, so once you figured out how to use one of them, you know how to use both:

As you can see even code and strategy how we are going to use it are the same, timePicker may be used as "onPress" function as well.

Even styling would be similar:

And if you want to have a darker theme you would have to perform all the same modifications as with DatePickerAndroid.

Final result:

Congratulations! Now you know how to make your form more user-friendly and do less validation!

Saturday, March 10, 2018

Release 0.3: Status Report

It's almost impossible to control how much work load you have.
These 2 weeks were super busy in my semester: midterms, assignments, labs, deadlines...

At some point working on my bug for Release 0.3 I realized that I don't have enough time to finish it for this Release. So it's work in progress; I was able to create a visible command on command pallet and now I need to work on functionality:

That will be done for Release 0.4. Meanwhile I was trying to fix this bug, I was working on localization for VS Code, here is what I accomplished:

In Transifex, your translation should be voted and reviewed by 2 people to be accepted, so that's not all the words I have localized, but only those that will appear on actual VS code Ukrainian and Russian instances.

I was also contacted by Andy Alt, who is working on a new project, to translate his project to Russian!

It felt nice to be remembered, I have already helped him with Russian and Ukrainian translations for rmw project in the last semester, so I was familiar with the process and agreed with no hesitations. So about 5-6 hours later I have submitted a PR to hldig project.

According to the, "hl://Dig is a fork of ht://Dig, a world-wide-web search system for an intranet or small internet."

At first I thought that I won't do much for this release. But at the end of the day I translated about 300 lines worth of messages for Andy, 456 strings were approved and now are seen by Russian and Ukrainian VS Code users and I was able to create a "dummy" blah command in VS Code command pallet.

It's only a beginning

What have I learned for the past 8 months of Open Source Programming? I was convinced from the very beginning that this course would be i...