Posted in Internship, Machine Learning, Programming, Web Dev

Creating an ML Model and Serving it as a RESTful API: Part 2

This post is the continuation of the Model and API creation, so be sure to check out part 1 of this series first!

Part 2 of the series will be focused on creating a very simple web app that asks for Iris’s petal and sepal width and length. It will then make a call to the Iris Classification Model API to classify the type of Iris flower based on the given user data. The web app will be created in PHP and HTML, where it will be hosted in a local server.

Coding the Web App 🖥️

The web app contains four input fields to accept user data. Once the user clicks submit, it will call the API and return the predicted classification in JSON format.

To do that, we create a file called iris-app.php and enter the following PHP and HTML codes inside:

<?php
 $form = “
 <!DOCTYPE html>
 <html>
 <body>
 <h1>Iris Classification</h1>
 <form action=’iris-app.php’ method=’GET’>
 <p>Enter Sepal Length</p>
 <input type=’text’ name=’slength’/>
 <br/>
 <p>Enter Sepal Width</p>
 <input type=’text’ name=’swidth’/>
 <br/>
 <p>Enter Petal Length</p>
 <input type=’text’ name=’plength’/>
 <br/>
 <p>Enter Petal Width</p>
 <input type=’text’ name=’pwidth’/>
 <br/>
 <input type=’submit’ name=’Submit’/>
 <input type=’hidden’ name=’submitted’ value=’true’/>
 </form>
</body>
 </html>”;
echo $form;

Note the extra input tag below Submit. It will be used to notify the program that the form has been submitted.

It should look like this:

When the user clicks submit, it will redirect back to the same file as this is where we will be doing the API request. We then have to enclose the form in an if-else statement so that the request will only happen if the user clicks submit. If not, then the form will just keep showing itself.

The code will then be:

<?php
 if(isset($_GET[‘submitted’])){
 //API Request Goes Here
 }
 else{
   $form = “
   <!DOCTYPE html>
   <html>
    <body>
      <h1>Iris Classification</h1>
      <form action=’home.php’ method=’GET’>
        <p>Enter Sepal Length</p>
        <input type=’text’ name=’slength’/>
        <br/>
        <p>Enter Sepal Width</p>
        <input type=’text’ name=’swidth’/>
        <br/>
        <p>Enter Petal Length</p>
        <input type=’text’ name=’plength’/>
        <br/>
        <p>Enter Petal Width</p>
        <input type=’text’ name=’pwidth’/>
        <br/>
        <input type=’submit’ name=’Submit’/>
        <input type=’hidden’ name=’submitted’ value=’true’/>
      </form>
    </body>
  </html>”;
  echo $form;
}

The cURL library can be used to make HTTP requests in PHP. We use curl_init() to initialize a cURL session first, then only make the API request using curl_setopt() where it takes three parameters:

  • cURL_handler — returned when you initialized cURL using `curl_init()`
  • Option — the constant value for the setting to be changed. For this program, we use `CURLOPT_URL` as we want to pass a URL as the value in the third parameter
  • Value — the value to be used for the setting. In this case, we make a call to the API along with the user’s input as the query.

Once this is set, we send out the request using `curl_exec()` and finally close the cURL session using `curl_close`.

Full code is written below:

$swidth = $_GET[‘swidth’];
$slength = $_GET[‘slength’];
$pwidth = $_GET[‘pwidth’];
$plength = $_GET[‘plength’];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://iris-classification-model.herokuapp.com/classify?swidth=".$swidth."&slength=".$slength."&pwidth=".$pwidth."&plength=".$plength);
$result = curl_exec($ch);
curl_close($ch);

And we’re done! If we run the program with these values:

We get the Iris classification as:

Hurrah! Now we have our Model API and interface 🎉!

Posted in Internship, Programming, Python

Creating an ML Model and Serving it as a RESTful API: Part 1

I started my internship at a local company that focuses on Data Science and Machine Learning and as part of my training, I was tasked to create a simple Iris Classification model that identifies the type of Iris category (Versicolor, Virginica and Setosa) based on the given petal and sepal width and length. Being someone who has minimal Machine Learning background, I needed a lot of research and reading in order to arrive at the required output, but it was all worth it.

In this post, I will be sharing the steps I did to create an Iris Classification model using Python and serve it through Flask RESTful API. I have also created a simple PHP interface that connects to the API to demonstrate its usage.

Model Creation 🤖

In Machine Learning, a model is trained using a set of data to recognize certain patterns. Python’s open-source Machine Learning library, Sci-Kit Learn, provides model training for supervised and unsupervised learning. It is simple to use and it has a lot of tutorials to get started with.

First, install Sci-Kit library using pip:

pip install -U scikit-learn

Once the installation is finished, create a file called `model.py` where Sci-Kit Learn’s already made Iris dataset can be used:

from sklearn import datasets
iris = datasets.load_iris()

*Note: You can use your own dataset but it needs to be preprocessed and formatted for Sci-Kit Learn to understand and train the model as efficiently as possible.

Next, the datasets are separated into data and target. Data consists of petal and sepal width and length in centimetres, while the target, or the label, is the class to predict. For the Iris classification, the target consists of Versicolor, Virginica and Setosa.

iris_data = iris.data
iris_target = iris.target

Before training the model, the data and target are split again so that the other half is used for the actual model training while the other is used for verifying the model (in other terms, testing the model’s accuracy).

This can be achieved using train_test_split:

from sklearn.model_selection import train_test_split
iris_data_train, iris_data_test, iris_target_train, iris_target_test = train_test_split(iris_data, iris_target, test_size = .5)

The test_size parameter specifies the size of the testing datasets.

Now, we can start building the model. There are many classification algorithms that can be used for this model, but I settled on K-Nearest Neighbors as the accuracy score is much higher.

from sklearn import neighbors
classifier = neighbors.KNeighborsClassifier()

From this, we can start training the model:

classifier.fit(iris_data_train, iris_target_train)

And there we have it! We have a trained Iris classification model. We can print the accuracy level of the model using accuracy_score:

from sklearn.metrics import accuracy_score
predict_iris = classifier.predict(iris_data_test)
print(accuracy_score(iris_target_test, predict_iris))
From the above, the model has an accuracy score of 97%! Great!

Creating Flask API ⚙️


Before we create the Flask API, the model needs to be serialized using a Python library called Pickle. By “pickling” a python code, it is converted into a byte stream for it to be easily sent over the network or saved on disk. “Unpickling” is the opposite, where it converts the python file into its original state.

Pickle can be installed using pip:

pip install pickle-mixin

Our Iris classification model can be “pickled” or serialized using the following code:

import pickle
pickle.dump(classifier, open(“iris_model”, “wb”))

This creates the iris_model file. If you try to open it, it will show indecipherable characters.

Now that we have our model pickled, we can now start with the Flask API!

Like the rest of the Python libraries, we install flask as well:

pip install flask

We then create our main app file called `app.py`. Inside, we import the libraries required for our Flask API:

from flask import Flask, jsonify
from flask_restful import reqparse, abort, Api, Resource
app = Flask(__name__)
api = Api(app)

Our Iris Classification model is then loaded and “unpickled”:

import pickle
loaded_model = pickle.load(open(“iris_model”, ‘rb’))

When we create the front-end interface later, we need a way to send over the user input to the Iris classification Flask API. In order to do that, we create parameters to the URL and we pass the user input there. The inputs we need are the petal and sepal width and length, and from this information, the model predicts what type of Iris flower we are referring to.

We create the parameters using the following code:

parser = reqparse.RequestParser()
parser.add_argument(‘slength’)
parser.add_argument(‘swidth’)
parser.add_argument(‘plength’)
parser.add_argument(‘pwidth’)

Once the queries are set, we need to call the model to predict the Iris type based on the given inputs. We then create a class called `requestIris` that takes the URL parameter values then insert it to the model for prediction. The predictions will come into integer format, so 0 is setosa, 1 is versicolor, and 2 is virginica. Also, note that the data returned should be in JSON format.

The full code is stated below:

class requestIris(Resource):
def get(self):
args = parser.parse_args()
slength= args[‘slength’]
swidth = args[“swidth”]
plength = args[“plength”]
pwidth = args[“pwidth”]
prediction = (loaded_model.predict([[slength, swidth, plength, pwidth]])).tolist()
if(prediction[0] == 0):
type=”setosa”
elif(prediction[0] == 1):
type=”versicolor”
else:
type=”virginica”
serve_model = {“Iris Type”:type}
print(serve_model)
return jsonify(serve_model)

We then add the resource to our API, and create a route for the resource:

api.add_resource(requestIris, ‘/classify’)

Last but not least, we add the code to run our Flask application:

if __name__ == ‘__main__’:
app.run()

Hurray! We have our Iris Classification API now!

The API can be run locally or published to Heroku. I published mine here:

https://iris-classification-model.herokuapp.com/

In the next post, I will be writing about the PHP frontend interface to demonstrate the API’s application. Stay tuned!

Posted in Family, Music, Programming, School Life

Thank You 2020!

Year 2020 had been the most unexpected year I ever had. A lot of things may have happened, but I wouldn’t say it’s the worst year for me. Sure, there’s the pandemic that caused almost a lot of planned activities to go unplanned and heartaches that resulted in wet pillow and puffy eyes, but there are always things to be grateful for.

Goodbye, 2020!

Developer Journey 💻

Firstly, I have achieved my goal to win Google Code-In programming competition. Although my prize trip to Google Headquarters in San Francisco, California was cancelled (and boy, it caused more tears than I ever shed), I get to have satisfactory alternative prizes. What’s more, it helped me gain confidence to join more hackathons and coding competitions, and I realized that I can actually do it.

Speaking of hackathons, 2020 also enabled me to focus more and join online hackathons that are held from the other parts of the world. I get to meet people with the same interests as I and helped me learn. I also get to win a 1-year hosting and domain name for my website portfolio from a hackathon that is sponsored by Qoom.

Last but not the least, I started learning PHP and Laravel Framework after being blessed with a part-time work as a freelance web developer! It’s challenging at first (considering I have college to focus to as well), but I got through it alright, and get to enjoy my first salary by buying donuts 😋.

Student Stuff 📝

College life changed pretty much for 2020. For one, we get to conduct lessons through online means because of the pandemic. Being a person who was homeschooled for the whole duration of my elementary and high school years, I’m used to studying at home, so there’s no problem with that. The biggest challenge with online classes is perhaps the group assignments, as they are “harder” to execute without face to face discussions.

As for the lessons, we get to study OOP concept using Java (the language I always try to learn but keeps procrastinating), and PHP lessons aren’t bad, especially my part-time work helped me understand the language more and put them into hands-on practice (though combining school and part-time do require more effort, time management, and sacrifice from too much gaming 😂).

One last thing to add, I got my results for my last semester this January 7, and I can happily say I got my third Dean’s list award 💖

Musical Hobby 🎹

Being in quarantine made it easier for me to play my piano, and at the same time, to NOT play it (my dad works at home so I can only play during his breaks). I’m happy that I get to play the songs I’ve been wanting to play, which includes the Voltes V Theme Song and Silhouette of a Breeze from Emma: A Victorian Romance anime.

Though youth choir at my local Church was postponed (thus, I cannot sing there for now), I was given a Karaoke Microphone for Christmas. Time to SIIIING!

Family Life 👪

Of course, I get to spend more time with my family because of the pandemic. They were the ones who helped me grab opportunities and comfort me during 2020’s heartaches. Even though outings are minimal, we get to have a nice picnic near the seaside every once in a while. Late night movies are also frequent, and I also get to learn new recipes to cook for my family!

Final Thoughts

Once again, 2020 is a lot, even if it’s mostly spent inside my house. As I welcome 2021 and continue improving in different aspects of my life, I won’t regret being a part of 2020’s adventures 😉

Posted in Programming, Sugar Labs

Sugarizer Activity: Constellation Activity

Constellation Activity is my first ever Sugarizer Activity. It has been a year since it was added on Sugarizer (time flew so fast!).

Do check it out on: https://try.sugarizer.org/

Constellation Activity demo

What is Constellation Activity?

Constellation Activity is a web-based, 3D planetarium where users can see the constellations, stars, and planets in their current position in the sky. It shows where they are positioned on a particular day and time, and from which place the user is currently staying.

The Star Chart, which shows the constellation, stars and planets, can be changed in a different projection. There are currently 8 projection available, namely: Stereo, Ortho, Mollweide, Fisheye, Lambert, Equirectangular, Gnomic and Polar. It can be changed by clicking the “Projection View” dropdown button.

This was added as one of the enhancement for the activity, and to also allow the users to choose the Star Chart view that they are most comfortable with.

Aside from Projections, another enhancement added for this activity is detecting user’s location. The user can either choose from a limited list of countries in the “World List” Dropdown to see what the sky view is on the chosen country, or they can set the location to where they are currently staying by clicking the “Set to My Location” button. It will then set the star chart base on longitude and latitude.

“Set to My Location” is more specific in getting the longitude and latitude of the user’s location. However, I still added “World List” for users to be able to see the different sky view in other countries, without specifying its exact location.

Another feature of this activity is that the user can add or minus a day to see the sky view previously or afterward. They also have the ability to toggle star names and constellation lines.

Project Reflection

I remember thinking about this because I noticed that Sugarizer doesn’t have an astronomy related activity. Being someone who likes astronomy during high school, I was inspired to do this project to better help students and users appreciate the beauty of the night sky even without a proper instrument like a telescope. Though books can only take students so far, having an interactive platform for them to explore makes learning fun and engaging.

The night sky ❤

Doing this project also helped me improve my JavaScript programming language. In all honesty, I learned JavaScript more by doing constellation activity 😂. It’s one of the challenges I ran into while doing this project. Another challenge I faced is that this is my first, “real” project to an open source , so it took quite some time getting used to the environment and work space. Reading other developers’ codes is no joke, by the way.

It is also nice and satisfying to think that your work or project will be used and maybe even help other people. It’s one of the reasons why I enjoy writing codes 💖.

Once again, do check out constellation activity or if you are a developer or interested in improving this project, visit Sugarizer’s updated version of the activity: https://github.com/llaske/sugarizer

Posted in ramblings, School Life

Happy 1-year in College to Me!

Time flew so fast! Before I knew it, it’s already August (and blimey, it’s almost September). I didn’t realize that I’ve been a college student for almost a year already. It seemed like yesterday when I’m frightened and sick with nervousness after I finished my Junior High School (and ultimately, my home-schooling journey), realizing that I will soon be stepping into what most people call “normal schooling”.

Looking back now, I just want to laugh at myself.

Flashback to A Year Ago…

“I don’t think I can do it. I’ve never been or studied to an actual school building ever since I was in Grade 2, let alone studying in a huge college building. I don’t think that I will ever be able to handle the lessons, plus the assignments, and I’m going to fail my tests and exams.”

These are the thoughts that plagued my mind as the day of my college orientation gets near. Sure, this is one of the first steps that I need to take to reach my goal in becoming a fully-fledged software engineer slash ethical hacker, and sure, there will be more opportunities for me out there (as my mom frequently says). But STILL, I feel like I’m going to fail on my first semester. I’m a newbie in “normal schooling” and I won’t be able to handle the pressure of college life.

Hey there, my would be school. Image Source: https://commons.wikimedia.org/wiki/File:Cmglee_Inti_College_Penang.jpg

My mom always told me that I can do it, that I am well prepared for this and that she believes in me. It’s nice to hear that somebody believes in you, that somebody thinks that you can get through. It lightens your load, even if just a bit. But the problem is, I don’t believe it. Maybe I do, somehow, but as the days go by, I doubt myself more and more. In short, my biggest doubter is myself (and I’m trying to fix it).

Of course, in times like this, I know that I must prepare. With the remaining weeks before my college orientation comes, I started reading up some of the books that I think will be covered up on my first semester. I know that I don’t have much time, but at least I can get a grasped on what is to come. Somehow, it gives me a bit of confidence.

On the night of the orientation, I couldn’t sleep. I must admit it, but I was feeling both sick with nervousness and (surprisingly) excitement. Nervous, because I still think that I can’t do it, and excited, because it’s really happening! I’m finally going to study the things I want to study, and no more biology, chemistry, and the sewing lessons from Junior High School. I feel that this is going to be fun.

After Orientation and Beyond

My college orientation wasn’t so bad as I expected. I had vivid imaginations that I will be given a test once I step inside the campus, but all they did was welcome us, gave some opening speeches, and tour us on the campus. I took down some notes, especially during the campus tour. I don’t want to get lost on my first day.

First Steps to Reaching my Dreams!

I went back home feeling sort of elated as I got through the day without getting lost or making a blunder talking to people. To prepare myself for my first class, I printed out a map of INTI’s campus, plus my timetable, and signed-up for the school van that drops by on my place. Everything seemed to be in order now.

Still I couldn’t sleep. I await and dread tomorrow’s first day of school.

I was still uncertain on what time the school van arrives (even though I asked a couple of people during the orientation). It says on their poster that it arrives at 7:00AM at my place, so I woke up at 6:00AM, and went down to the bus stop at 6:30AM, where I waited for my van. Little did I know that my van will arrive at about 7:30AM…

I just can get too jumpy sometimes.

Alright, most of the time.

Once I arrived at the campus, I was just in time for the lecture. It wasn’t so bad as I expected as well; In fact, I started to relax after my first lesson. It did take me some time to look for my respective classrooms. Thank goodness I’m not late on my lessons.

I also met new people on my first day: Shan (whom I got acquainted in during the orientation) and Sara. Admittedly, I never knew that we would stick together for most of our group assignments, helping and learning from each other. I guess being one of the few girls in the class is one major role that made us more comfortable and closer with each other. I’m glad I met them, it made college life more fun and less stressful.

And so, for the next couple of weeks, I officially started my college lessons. I found that my favourite subjects include: Program Logic Formulation, Introduction to Internet Technologies, and Database Management. There are fun and stressful moments (mostly because I overthink stuffs), but I learned a lot on my first Semester.

It wasn’t that hard than I expect it would be, to be honest 😉

Ending Notes

I celebrated my 1st-year-in-college anniversary by studying for my 4th Semester. Sadly, I only got to step on campus on my 1st and 2nd Semester, as the pandemic forced us all to conduct our lessons online. I am more used, I guess, in this kind of studying (being home-schooled and all), but it does limit our person to person interaction (which is much needed on group assignments). Although I’m still alright with online classes, I do hope that I get to come back to campus before my college life is done.

I still have another year to go to before I finish college and step up into University. Aside from the lessons, college taught me that I don’t have to do everything alone. I was used to studying by myself, doing my own assignments as I don’t have classmates. But in college, my classmates are also my allies; We help each other out in group assignments and share important resources in our group chat. We also learn from each other, and we fairly get along. I realized that, although I learn best on my own, there are more things to learn from other people.

Once again, happy 1-year in college to me! 🥳

Posted in Competitions, Programming, ramblings

Wrapping Up Google Code-In 2019

At last, exams are over! Now I have at least a week before my school starts sending out our overall results (and see how “well” we did for this semester). Hopefully I won’t be retaking any subjects.

Anyhow…I finally received all the promised packages of alternative prizes from Google (about time). On my previous post last 4 months ago, after my supposed trip to Google got cancelled because of the virus, Google then arranged to give the winners alternative prizes instead, which include cash and swags. And so, after months of waiting, all the long-awaited packages are finally here at my doorstep, fresh from America.

The “Alternative” for the Trip

Ever since the winners received the cancellation email, Google informed us that they will be sending out alternative prizes instead. I guess this temporarily pacified our broken hearts, as we wait in anticipation what those prizes could be. When I did receive the details of the alternative prize, I must say that I had a so-so feeling about it. It’s not bad, but it doesn’t really replace the lost trip (I mean, what would?). It did, however, gave me another thing to look forward to, plus, in an attempt to cheer myself up, I made myself think that not all 17-year olds receive this kind of stuffs, especially in a time like this.

And so, from April till August, are the packages delivery months. This was my “please-don’t-get-my-package-lost-it’s-all-I-have-now” kind of phase.

Coronavirus played another part in delivering the packages (obviously). It’s the reason why it took months to deliver the items, and why I’m referring to “packages” (plural), and not “package” (singular). The packages (three in all), are delivered separately as there was some problems with delivery here and there. Also, we were supposed to be given a new phone as one of the alternative prizes, but since there is a very high possibility that it will not be delivered as planned, they decided to exchange it with the phone’s money value instead. Oh well, I guess what can go wrong, will go wrong.

Way to go, Coronavirus.

Finally, after months of waiting 😀

Although I like all the swags delivered, my favourites are the thermos, fleece and trophy. My old water bottle is getting its paint chipped off, and it’s about time I have my own thermos. Meanwhile, the fleece is so comfy for wear! I would wear it at home if it weren’t this hot. I guess I’ll just use it for school during long hours of lecture in a freezing classroom.

Lastly, the trophy! It’s my first time having a trophy instead of the usual certificate or rusting medals. The first time the trophy was displayed, I often stare back at it, just to observe it (and probably reminisce the past days on how I earned it).

Google Code-In Trophy!

Googler Speaker Sessions: Another Alternative Prize

Aside from the alternative prizes, we were also given a two-day virtual seminar from Googlers. The topics for the talk include open source, internship, augmented reality, Android, and more. Although I have to stay awake from 11pm to 3am because of time zones, the talks had been interesting, with internship, augmented reality and TensorFlow being my favourite.

Google Code-In Winners’ Virtual Seminar Opening
Google Code-In 2019 Statistics. This was the highest number of participants compared to previous years

On the actual trip, we were supposed to have a “day at Google” as part of our agenda, where we get to listen to Googler’s work experience and what other opportunities we can get. I guess this is the only part of the trip that they can recreate.

The talk had been fun, as aside from it being aligned with my interests, me and my fellow Grand Prize Winners finally had a face and voice reveal and we were also chatting in Telegram during the talk. On the last day of the talk, there was a section for volunteered winners to make a speech. It had been a rather sad part of the talk, as it felt like we were “parting ways” (and I guess it reminded us again that we should’ve been speaking in an air-conditioned, Google hall or something).

During Augmented Reality Talk
Android + Open Source Talk

This wraps up the whole Google Code-In business. It had been fun and sad at the same time, but I don’t regret being a part of it. After all, the contest had officially ended on January 2020 (which means, this is the last Google Code-In contest), and I am blessed to be announced as a winner even if it didn’t go as I imagined it.

Besides, there are other ways to go to Google 😉

Posted in Music, ramblings

Music: The Part of Me that Keeps Me Sane

There is always a time when I don’t feel like coding. Those are the times I don’t understand a single line of code on my console. The language in my computer screen feels like a stranger. I get distracted easily, and there’s this longing to get as far away from my computer as possible. It’s a time where coding doesn’t make any sense.

This is also the time where music comes in. I would feel a sense of longing to sit on my piano, and to play the songs on my sheet music collections. I would also pop in my earphones and scroll through YouTube to listen to classical, Celtic, or modern music (depending on my mood). It’s a time where my musical side “awakens”.

After spending a huge amount of time (and days) playing my piano and doing music-related stuff, I will soon come to a point where I’ll lose my interest on those musical notes, and longed to see my black IDE, with its colorful lines of codes. I wouldn’t know what songs to play and to listen to. It will be the time where I want to code again.

And the cycle goes on.

I guess liking both programming and music is perfect. They “balance” each other. While programming exercises my brain and helps me become more analytical, music gives me rest and keeps me sane from the ever-overwhelming lines of codes. Although I chose programming as the main career path to take, I can never leave my love for music behind.

Music also keeps me from burning out my passion for programming. I found that I can easily think of solutions to problems in my code after playing my piano. It makes me feel refreshed, and it “de-clutters” my mind, thus giving it space for new ideas and solutions. Music doesn’t take my attention away from programming; rather, it brings back my interest and love for it.

I may focus more on harnessing my programming skills and knowledge, but somehow, I still need a moment to stop, chill, and play the piano. I’m lucky to have these two interests as a part of me, and it’s hard for me to imagine my life without both of it.

Well, I better stand up and head over to my piano, I’ve been in my computer for too long! 😉

Posted in Competitions, Programming

Helpful Advice to Google Code-In Future Participants

Google Code-in was in it’s 10th year in 2019 and had been epic in every regard, no doubt about that. It was unlike any other GCI competition I had before for the reasons that, first, I finally won as a Grand Prize Winner! Yay! . . . Second, it was the first GCI where Google had cancelled the US Trip for winners. Yay again! ( You can read about this here from my previous post )

Despite of that, I still want to encourage teenagers ages 13-17 to participate in Google Code-in. It could be a fun and wonderful experience where you will not just be introduce to the world of Open Source but you will also get to talk to fellow developers and most importantly will be able to contribute to something that could help people.

It took me 3 years to finally become one of the Google Code-in Grand Prize Winners. Although the winning moment was not what I had in mind, I did enjoy my GCI experience and learned a lot of new things.

So, for future GCI participants, here are some helpful advice that I can give which helped me in winning the GCI 2019:

  1. Do your advance research about GCI. Know what GCI’s purpose is, and what is it all about. Moreover, research on its guidelines and contest rules, to make sure you are playing fair. You don’t want to get kicked out in the middle of the competition. By researching, you will get to know what you will be dealing with, as well as gain additional tips from previous winners
  2. Focus on one organization. Each participating organization chooses the students that greatly contributed to them. Jumping from one organization to another lessens the chance of winning. It is also a plus to choose the organization you want to contribute to before the competition starts, as you get to have some time to familiarize yourself with how your chosen organization operates, as well as with their guidelines for contributors, programming languages used, etc.
  3. Balance “Difficult” Tasks & “Easy” Tasks. Google stated in the contest rules that quality > quantity. It’s true, but you also need to get enough completed tasks to be able to proceed to the top 20 participants with the most tasks completed, as the organization will review the works from those who have made it to the leaderboard in choosing the winners, finalists and runner-ups. A good balance between doing easy and difficult tasks is helpful, as easy tasks add more count on your tasks list while difficult tasks are mostly quality contributions to the organizations.
  4. Show that you are genuinely interested to learn. The whole point of this contest is for teenagers to learn more about contributing to Open Source technologies. It is good to ask mentors relevant questions when you need help, or to clarify things that you don’t understand. Keep in mind, however, that mentors are human beings that have lives outside GCI, so don’t bug them when they don’t answer instantly.
  5. Be active in the community. Organizations have their own IRC or chat group. I encourage you to join in it, as this is the place where you can ask questions and talk to fellow participants and mentors. Being active in the community could also be the way to help other students when they get stuck or by answering their questions.
  6. Bonus: Do Beyond What is Required of You. A week before the competition ended, where most participants were cramming to get additional tasks and finishing them, I decided to stop taking anymore tasks after I reached my own task count quota, and just solve open and unfinished issues on my chosen organization for honest and real contibuting.  Doing this shows that you are interested, and really want to help in the open source even beyond the competition.

I hope you find the above tips useful. Google Code-In is a great competition and a good way to get acquainted to fellow developers and students. Good luck to all future GCI participants!

Posted in Competitions, Programming, ramblings

How Coronavirus Stole My Trip to Google HQ

On my previous post, I shared my Google Code-in experience, and the thrill of finally being chosen as one of the Grand Prize Winners for GCI 2019. Each Grand Prize Winner are granted an all-expense four-day trip to Google Headquarters in San Francisco, California USA.

Well, that was before coronavirus became a thing.

Worst than Losing

My father is always listening to news about the virus, and how it is rapidly spreading. He always told me that he’s got a feeling that my trip might be cancelled, as some major events are already getting called off (Google I/O, Facebook F8, Apple WWDC, etc.). Meanwhile, my mom and I always look at the positive side and often dismissed that thought. Postponed might be more possible, but cancelled, meh.

And that’s where I was wrong.

Almost a month after I was declared as a Grand Prize Winner, I received an email from Google saying that they have cancelled the GCI trip. You read it right, cancelled. Not even postponed. They said that they will just provide alternative prizes. It didn’t sink at me first, and went through my day as normal as possible ( even though I couldn’t focus on some of the things I was doing ) but at night time, I cried a lot. I have expected something so much, and for it to vanish, is truly upsetting. As for the alternative prizes, what could be much better than the trip?! Nothing can replace the experiences and new acquaintances that I was supposed to have. Another down fact is that Grand Prize Winners can no longer participate to win. So, I no longer have a chance for GCI 2020.

For the next 5 days, I tried to act normal during the day, trying hard not to think about my loss. I hated it when night comes, as that’s when my mind becomes idle and welcomes negative thoughts. I started regretting reading through previous winner’s blogs, as it only reminds me of the experiences I won’t have. I was so, so disappointed.

Not that I didn’t do anything else to try to get my trip back. I got in touch with my fellow GCI 2019 winners through Telegram, and we all decided to write a letter to Google, asking them to postpone the trip to whatever month or year they want, just not cancel it. Well that didn’t work either. I understand that Google is taking precautionary steps to prevent the spread of the disease, and that it’s not their fault, but that doesn’t stop me (and my fellow Grand Prize Winners) from being upset again.

Grand Prize Winners in a nutshell. Image Source: Memedroid

So much for being a Grand Prize Winner.

Acceptance and Lessons Learned

After almost a week of self-pitying for my misfortune, I came to realize that there’s no more point hoping that I will get back my trip. It’s gone. . . and whining won’t help me. Once I accepted this truth, then the moving on process takes place. I became more comfortable joking about the GCI trip, plotting ways to go to Google Headquarters for the next GCI year (though impossible). I focused on my family and upcoming exams (which wasn’t cancelled until the next week). Although I still feel sad, I know that there is nothing else I can do.

Winning the Grand Prize for Google Code-in to go to Google HQ was what I always dreamed of, ever since I heard of this competition. However (and probably because of a great reason), it was not what I had imagined. Although I didn’t get to step on Californian land, everything might turn out worse if I went there and contracted the virus. I might survive, but the contagious nature of the virus is just too much to risk.

The cancellation of my trip also made me realize that I’ve focused too much on my own plans. I didn’t take the virus and what’s happening around me seriously, as I thought it won’t affect me. I focused more on myself, and my trip. Now that it’s gone, my mind is now open to reality. A lot of people are suffering, whether because they lost their jobs, contracted the virus, or are dying. To continue thinking about what I lost is almost like an insult to those people who lost a lot of things because of this virus. In fact, I haven’t lost everything. I still have alternative prizes, and although it will never replace the trip, it’s better than nothing.

One more thing I learned from this experience is that, no matter how much you dream, hope, prayed and work hard for something you really, really wanted, in the end, it’s always God who has the final say in everything. I have prayed, each night to Him and specifically asked Him to grant me this opportunity. He did answer my prayer, just in a way that I never imagined. I may not know the reason why this has to happen, but I trust that He’s got better plans for me, and that the best is yet to come.

See you in another time, perhaps? Image source: Swim Creative

Posted in Competitions, Programming, ramblings

My Google Code-In 2019 Experience and The Joys of Becoming a Grand Prize Winner

Google Code-in ( GCI ) is an annual programming competition that introduces teenagers ages 13-17yrs old to the field of Open Source through coding, research, quality assurance, or design tasks for an organization of their choice. By the end of the competition, each open source organization will choose two students as Grand Prize Winners, who will be granted an all-expense four-day trip to Google Headquarters in San Francisco, California USA.

The 10th Year Anniversary of GCI was a blast! Image source: Google Open Source Blog

My Brief History with GCI

This was my 3rd year joining this competition and is probably one of the most memorable. I first joined GCI back in 2017, and have chosen Catrobat as the organization which I will contribute to. Wanting to win the contest on the first shot was I think a bad idea for me as it became stressful and no longer enjoyable. I then changed my mind set, that although I still want to win this competition, I want to learn something new and enjoy what I’m doing. This time, I chose Sugar Labs as my organization for GCI 2018.

Images Source: Sugar Labs

There are two reasons why I chose to work with Sugar Labs. First, I liked its mission to provide educational opportunities to children through the Sugar Platform. Second, it uses Python (along with JavaScript, HTML & CSS) as it’s language for developing its apps and games ( known as Activities ). Although I’m more familiar in Python Language, my old computer couldn’t handle the environment required for Python contributions so I ended up programming in JavaScript, which I have zero experience during that time. Obviously, I didn’t win, as I only finished 9 tasks. However, I did manage to be at the Top 20 students with the most tasks completed, and that’s something for me.

To prepare myself for the next GCI, I dedicated my summer holidays to contribute to one of Sugar Labs’ product, Sugarizer, which uses JavaScript. I then became more familiar with the programming language used and more comfortable with the environment I’m working with.

Google Code-in 2019: To join, or Not to Join?

GCI 2019 started on December 3, 2019 and lasted until January 26, 2020. Weeks before the start date, I was having second thoughts whether I should sign up again or not, as the competition would clash with school review and exam schedules, and I have a goal of making it on the Dean’s List. But something tells me that I will regret it if I wouldn’t join the GCI 2019, and this thought went on for a couple of days before I finally signed up on the day the competition started. I chose Sugar Labs again as my organization, specifically working with two of its products, Sugarizer ( web implementation of Sugar ) and MusicBlocks ( visual programming language focusing on music composition ). The first few weeks wasn’t so bad as I expected, as I had a study break where I used to do more tasks and finished about 2 tasks per day during this time. It only went tougher during and after the exam week, where I only get to finish 2-4 tasks per week.

The difference with GCI 2019 and the previous years was that I’ve enjoyed it more. Some of my favourite tasks are:

1. Editing Synthesizer Length for Music Blocks

String and wind instruments should be able to sustain longer note length. Before implementing my fix, Music Blocks’ synthesizers could not fully sustain a whole note, thus creating a rather abrupt end to its sound. Although it was specified in the task description to find new synthesizers, I found it much harder, as I have to consider the license of the audio I’ll be using. Instead, I used the same synthesizer from Music Blocks, and edited it’s soundfont for it to loop a little longer.

2. Adding Automatic Re-initialization Functionality in Open Widgets

Music Blocks students expect that when they change their code, the open widget updates base on their code. However, the student must manually re-initialize the widget for it to show the changes made. I’ve implemented an automatic re-initialization of the widgets for a more user-friendly experience.

The open widget updates when code blocks are changed

3. Fixing Bugs and Regressions

Fixing bugs are one of my favorite things to do. It helps me to be more analytical and creative, as bugs are fixed in different kinds of ways. One fix I did was the regression on the search autocomplete functionality on Music Blocks, while there’s another one from Sugarizer, where the fix requires putting a whole chunk of code above another line for it to be run first.

My complete tasks list can be found here.

The competition went on for about 8 weeks. I finished 31 tasks, surpassing my previous year’s task counts. I felt proud of myself for this new achievement.

Yay! New Achievement Unlocked

The Waiting Begins

I read somewhere from previous winner’s blog that Google privately emails the chosen Winners and Finalists before the actual public announcement on the Open Source Blog, which was on February 11. I felt very nervous. My heart jumps whenever I check my email notifications. There are lots of students who did great job in my organization, but I still hope to be chosen as a Grand Prize Winner, or as a Finalist at least. By the time January was coming to an end, I decided to stop thinking about it, and let tomorrow takes its course.

Then, on the afternoon of February 2nd, I was sitting in our dining area, designing a website for a study group. I just came from a youth gathering event, and my phone buzzed with messages from the other youth group members. I decided to take a break from my website and read through my messages, when I received an email notification. The first thing I saw was the word “Winner” in the email. It didn’t register on my mind, so I read the email’s Subject again, this time fully reading the words “Congratulations! You are a Google Code-in 2019 Grand Prize Winner!”. And because it’s not every day we get to receive an email like this from Mr. Google, I have to read the subject three times before the great news sank into me.

I quickly ran to my parent’s bedroom, told them the news, and broke down into tears. I felt so happy at that moment that my happiness turned into tears of joys. All throughout the contest, I remember visualizing every night, that I’ll win this time, visit Google, and meeting my Mentors and fellow GCI 2019 winners. This dream is becoming more real than ever!

There are lots of things to do before the trip. Lots of documents to fill up and submit for the US visa. After scheduling my visa appointment, all I have to do is wait. I’m going to use this time to look through previous winners’ blog posts and read their amazing experience in Google HQ, San Francisco. I can’t wait for my turn to take pictures on those Android statues!

Image source: Android Police

P.S. : By the way, I also did manage to be on the Dean’s List 😀. I feel so blessed.