Patched first bug for mozilla-central

Standard

Well, everything seems difficult until you start!

How will I make a patch? Will I ever able to understand that code? Will I really able to do it?

Everyone has these questions in mind and various others, while struggling to contribute to a huge code-base like that of Mozilla. So, recently I started reading stuff from MDN (Mozilla Developer Network) and then with bugsahoy and bugzilla, started figuring out good-first-bugs.

The difficulty was, it uses such terms, I haven’t even heard of! So, I was actually really afraid of commenting that I want to pick it up. But now, I was really frustrated with myself, and thought to give it a try to any bug, people would definitely help me, and I will figure a way out.

So, I reached this bug where enough of the instructions were already there, and it seemed like a very quick fix. This was a CSS bug in animation inspector of developer tools.

Having submitted a patch, I got review for my code and accordingly I did the changes, and on Feb 1, 2016. This patch got accepted 🙂

Now I’m working on another bug which is on JS in the animation inspector | Dev tools. It’s almost done, and I hope I would submit one more patch soon.

 

MozPacers at MSIT

Standard

Our MozPacers (Mozilla Delhi) community conducted an event today at MSIT (Mahraja Surajmal Institute of Technology).
We planned various events for students and the itinerary is as follows:

Intro to Mozilla, it’s mission and Open Web – Delivered by Bhuvnesh and Manraj
Promoting Womoz and gathering more women contributors – By Ashu and Sonal
Learning version control with Git – By me; Sanyam
Webmaker tools – By Saurabh

So, I reached the venue at 11:30 AM. We made some arrangements and till the students gathered, it was already around 12:50 PM. Initial session was started by Bhuvnesh about intro to Mozilla, it’s mission, privacy etc. Then Manraj shared about his experience in contributing to Mozilla and a little bit about his visit to Leadership summit.

In between we had quiz session on Mozilla, where we distributed swags for whoever comes up with the correct answer.

Then Sonal and Ashu encouraged more women contributors to come forward and enlightened others about their contribution in the community. They told about various pathways to contribute; it’s not about just patching bugs, they told how they are doing documentation in the community.

Next session was taken by me about Intro to version control system, specifically Git. I told about basics of Git, some things about Mercurial (since that is what Mozilla is using).

Then Saurabh took session on Webmaker tools like Thimble, X-ray goggles etc. and encouraged students to learn.

Then we had a sort of open house session where we took in questions from people, and answered them. Bhuvnesh, Nikhil, Manraj, Saurabh and me answered their queries.

Lastly, I told about my exprience with Mozilla, how I’m about the land my first patch for Mozilla central, what all I learned, what’s in it to contribute to FOSS etc. I shared about how I fiddled to contribute, why it is essential to ask questions etc. I told them about IRC and Mailing list guidelines, covering basics of Bugzilla. I hope this would help them 🙂

Many students seemed to be enthusiastic enough to join MozPacers and learn from the community, and I hope we will soon see more faces in the next MozCofee meetup.

Oh, yeah, need to now have a closer look at mails, I’m expecting MSIT people would ping us now for help 🙂

I’ll update this post with pictures from the event soon 🙂

Bootstrap Modal Scroll Bug on Chrome [Easy-Fix]

Standard

As usual, I was contributing more to the PyDelhi Conference project and saw that the code of conduct was really occupying a large space and wasn’t looking good. I contacted theskumar on IRC and we decided to make some changes in the FAQ as well as Code of Conduct section.

Quick enough I decided to have modals to be used for displaying the short and long version of code of conduct. I did it as well as the other task of modifying the FAQ section.

I told theskumar about it. Since it was around 2 AM, everyone was sleeping. Next day, I got a reply from theskumar that the modal was not scrolling on the mobile.

I tried quickly on my mobile and it worked. I asked him about the browser he was using, and he told me that it was Chrome. I tried that on firefox and it was working.

I then tried it on my desktop on both firefox and chrome. In firefox, both on mobile and desktop it was working fine, but in chrome, both on mobile and desktop, it was not scrolling.

I started searching, and got to the official bootstrap repo on github, where I found various issues, and this was a known bug on chrome.

I got to StackOverflow in search of alternatives, and then kept on applying it. But no success. Either the content of the body moves, or the whole page hanged.

I reached out Apoorva mam, and then she helped me. The solution was to have a scroll bar implemented in the modal keeping it’s height fixed.

So, we just added this to CSS:

.modal-body {
position: relative;
padding: 20px;
height: 200px;
overflow-y: scroll;
}

and it’s working!

I hope this would help someone who is still figuring out about scrolling bug on chrome.

Authenticating And Getting Info From Explara API

Standard

PyDelhi is organizing a mini PyCon this year with the name PyDelhi Conf. And we all are having a great time working behind the scenes to make it a success. I’m contributing to building up the website for the confrence (conference.pydelhi.org).

So, there was this task of fetching the no. of tickets left for the conference from explara and displaying it on the website. I picked it up and had a look at Explara API. And Bingo! I noticed the tickets end-point, which would contain the remaining tickets in the JSON format.

I got into reading about accessing api. There are two methods, one is for user access and another one is for app access.
Since user access is good enough for the kind of work we’re thinking to do, I decided to go by first method and generated the access token from my personal account and made a test event for testing purpose.

After several tries and errors, I was not able to authenticate the API. It was either giving me 401 or 403. Then after a day, I contacted Anuvrat & Saurabh on IRC. Also, I reached to Rishabh. Rishabh told me that he was able to authenticate for the app method which uses OAuth2. Then he tried for the user method and told me. And there I am.

Doing a blunder. The Authorization token in the header would be preceeded by ‘Bearer’ so the header would be:

Key: Authorization
Value: Bearer <YOUR_API_KEY>

And then voila, it was authorized. Soon to my surprise, it was giving me E007 which is a custom status code of explara which implies that eventId is incorrect. I just clicked on edit on my event and in the url I found something like

eid/116168

And I thought, yeah, that’s the eventId I started passing it. But always I was getting E007. Rishabh was also trying but he was also not able to get the response 200.

At around 12.30 AM Rishabh told me that he’s going to sleep, and would try tomorrow. But I decided to try more. I googled on how to find the eventId of explara event, but no concrete answer. I kept on trying, and then decided to have a look at other methods API is offering.

There was an endpoint to get all events which require no parameters to be passed. I hit that end-point and there I was.
I got the event details as JSON and find the eventId of the event I created.

Now I took that eventId and hit the ticket end point to get the details, but there was always E007 error. I tried different methods to pass eventId parameter. I tried to pass it in a JSON body, but no success.
Then I tried x-www-form-urlencoded and then the error code changed. I quickly searched, and got to know that I need to change the content-type of my request in the header.

I changed the header and added:

Key: Content-Type
Value: application/x-www-form-urlencoded

and bingo! I got the ticket status

Now I just wrote a simple flask script to issue the request and then display the tickets left in JSON format.
And here it is: https://github.com/CuriousLearner/explara-ticket-status
Also forked to PyDelhi: https://github.com/PyDelhi/explara-ticket-status

At 3:05 AM the task was completed, and I was pretty much happy about it. A good learning experience and I hope that someone would find it useful while working with explara api. Lack of examples caused more time on this than was really needed.

PyDelhi Birthday Bash!

Standard

And here it is! We just completed 1 year of regular meetups at PyDelhi. We organized various workshops, meet-ups, events etc. in the past one year.

We had the meet on 9th Jan, 2016. The venue was Fueled. We gathered there and started the introduction outside the office. After the introduction session, we got inside and we had a small presentation about PyDelhi delivered by Rishabh, Ashutosh and me, where we explained about PyDelhi, PyCon India, volunteering, how to contribute, various events by PyDelhi in 2015 etc.

Then we had a session where we explained how we used Python in 2015 in our projects. And there were many participants. Some projects were really good.

After this, we had the snacks and cake ready! After the party, most of the people formed groups and were discussing. There were a large group of students from Amity who just started programming and were looking for inspiration. Some people just came to me and asked for help. I guided them in the best possible way I could as per my exprience.

Soon after this, Satyaakam sir told that they would give inspiration and showed github account of student of PyChill who was in 8th standard. The repo was full of algos written in Python. He also showed the website that student made for PyChill. Again, I realized what Mr. Anuvrat told me, “Hum to Jhak maar rahe hai!”.

This was really inspiring for me as well and provided enough motivation to start working hard. After this, we had volunteers sitting around and completing various tasks for the PyDelhi Conference. We set up explara account, made up logo, pamphlets, resolved various issues on the repo, made list of people for reviewing the CFPs etc.

I had a discussion on what all needs to be done with theskumar and then left.

How to clone a large repository using git

Standard

So, I was trying to clone the official Mozilla gecko repo and it had around 455182 commits.

As usual I executed on my terminal:

git clone https://github.com/mozilla/gecko-dev

Then it took whole night to get cloned. I was awake the whole night. At 5:20 AM, it was around 90% received and then boom, it just crashed.

All the data downloaded of more than 1 GB was wasted.

Well, whatever happens, always happens for good. This provided me an awesome opportunity to learn how to easily clone large repos.

So, there are two ways around this.

Do a shallow clone!

Wait, what? What is a shallow clone?

Well, I mean clone the repo but not with all commits. Let’s do it for just latest commit ie only one commit. Later once all the objects are extracted, we can deepen the clone.

So, how do you do that in git?

With the depth parameter as:

git clone –depth=1 https://github.com/mozilla/gecko-dev

Here I’ve given depth of 1 commit, and suddenly the 1.5 GB repo became just around 258 MB to be downloaded.

If you still are stuck, and even this is difficult to clone because of unstable connection then prefer downloading a bundle, or explore more option via this SO Question

Once you have shallow clone, you can deepen it.

git fetch –depth=100

to fetch 100 commits

or if you want to get all commits then simply use:

git fetch –unshallow

and that would fetch all the commits and make your repo similar to what you do in the initial place like using git clone simply.

I hope this would help someone 🙂