Saturday, 7 November 2020

Through the Looking Glass of Telescope

 


Hello my fellow open source followers.

I have been AFK for quite some time (reading week).
Although I have kept busy with studying for my last two midterms I have been looking into some interesting repos to continue my OS dev adventures.

Just when I thought I was all caught up and have gotten ahead on school work, I got slammed with so much stuff after reading week. Thus, this week was a busy one for me. #ThankGeorge (Game Dev professor)

Nevertheless, I pulled a couple of late nights and got through it...

Anyways, this week's lab was an interesting one. We were tasked with installing telescope, Seneca alumni made website to gather open source blogs together in one place using RSS Feeds, and YOU GUESSED IT, use our never ending link checker tool we had made way back in Release 0.1. 

Man it feels like ages ago

So, I dreaded setting up telescope because when I tried to set it up last time for hacktoberfest, I was left only in disappointment and quickly lost interest in setting it up because who RTFM... 

To my luck, of course our professor wants us to work with telescope for Release 0.3 and lab 6. Meaning I was forced to figure out how to set it up and actually RTFM. To my surprise everything installed properly this time and everything went pretty smooth. I also took my sweet time installing it... 

YEP... 5 HOURS

To be fair it only took that long because I was taking down Halloween decorations before it snowed again. I don't even know why I decorated this year, only two, TWO, kids showed up. 

EH! Whatever, I am not complaining. Now, I have a good reason as to why I am stuffing my face with so much candy. (#SorryNotSorry Dr. Roberts, my dentist)

Anyways, back to the point.

Everything went buttery smooth, so I ran telescope, ran docker, opened up and saw the JSON that the backend was returning for the 10 latest posts and began to think about how I would implement yet another functionality into my DeadLinkage. 

Thank god I had refactored my code from the previous lab, otherwise this would have been a NIGHTMARE.

I made a new file that would be dedicated to handling and parsing the JSON formatted array and pass back links to the actual main driver.
I then simply duplicated my logic for checking through all the links but added an extra loop to switch each link that was passed back from the JSON parser. To my avail it worked perfectly. I had to tweak it a tad to make it look pretty and all but I have spent so much time with this code I know all the ins and outs of it by heart and line (man I have no social life).

The ending result was something like this:


I am actually pretty happy with the results to be honest. This continuous expansion on the link checker tool is turning out to be a neat little app (especially after refactoring). 
OH, here is the diff if you want to check it out.


I will leave that with you and go bang my head on the desk spend hours in front of the screen because of DSA. #ThanksCathy

Till next time,
XOXO,
Gossip Plamen

Saturday, 31 October 2020

Season 1 - Hacktoberfest Recap

 

WHAT A RUSH!

A race against time and other open source devs to qualify for open issues on repositories you are interested in.

What a great past time activity that is also accredited for school. 

Hacktoberfest! What a great idea. Especially in these interesting and difficult times.

It has finally ended. The busiest month I have ever lived through. It was not that bad to be honest. I have gotten through a lot worse (I think). 

Welp, this blog will serve as a recap to the most interesting event I have participated in, Hacktoberfest. The point of Release 0.2 was to contribute to at least 3 different repos and make 4 different PRs. 

What a great experience to gain knowledge in different projects and languages... UGH Python. 

Without further adu, Season 1 Recap of my Hacktoberfest journey.

Release 0.2.1 - Entry into Open Source

To get into the swing of Open Source contributions, I wanted to start off with something small. The first repository I chose was of a website that I had used on occasion to keep up with VR news when I first bought my Oculus Quest HMD. Unfortunately, I found a more intriguing website that contained more up-to-date information and game release/news. My first PR was to locate a script that was returning a status code 404. This was not that hard, like at all (thanks chrome dev tools). I made an issue on the repo and created a PR that had simply commented out the script returning a 404, which was doing nothing anyways. I think the maintainer does not check his github often since the issue and PR still remain open, Oh well.

Release 0.2.2 - Entering Another (Virtual) Reality

This was by far the most exciting repo I worked on throughout the whole month. I love virtual reality and I am really glad I got to contribute to this repo because the whole idea behind it is very neat. Oculus Quest is a standalone headset and has no connection to your PC. This owner of the project created a link to your HMD and PC through your LAN so that the Quest can communicate with discord and update your "discord presence", or simply put what game you are playing at the moment. I felt really accomplished with this PR because, I was finally doing something I have a passion for. I made a PR to update his JSON file which contained all sorts of applications and games. I even chatted with "MadMagic" on discord and we are now friends and talk regularly.

Release 0.2.3 - Avoiding Boring People with Chat Automation

My third PR was actually two smaller PRs. Why two? Well, because I didn't think it was enough for the fixes I made on the first one. I found this really neat repository that was basically a chat automation bot for the whatsapp web-based platform. The chatbot did everything you could imagine a chatbot doing. The maintainer was looking for a small refactor on his code by including a different style of CSS selectors from calling his constant selector class file. I replaced the selectors the way he wanted and got acquainted a little more with python, my arch nemesis. For the second PR of my third PR I had to basically copy the basic logic of his whatsapp bot, but make slight modifications so that a facebook session is made (click link above for more details).


Release 0.2.4 - More Pythonic Automation

This was yet another contribution towards automation bots. However this was tailored only to scraping elements from the whatsapp web-based platform. The maintainer (Navpreet) wanted me to write a function to scrape and return a phone number of a specific person that the user has an existing chat with. Really neat and as it turns out not that easy. It was interesting seeing how code varies from machine to machine. A problem I encountered was that the code ran fine on my machine and did the intended task, but once Navpreet ran it on his end it gave him an error (see blog for more details).

That was it for the month. Overall the experience was amazing and I will definately participate in next years Hacktoberfest. I really enjoyed getting involved in various projects and most importantly I made friends and (Hopefully) connections by interacting with the project maintainers. There are a lot of people that are like minded and have the same cores and interests as I do, no matter where in the world they are. a big thank you to my professor for picking something so interesting to get us involved. 

Oh and I made my 4 + 1 Hacktoberfest accepted PRs even though 2 of the PRs I made for Release 0.2 were not in hacktoberfest repos.


Now, all that is left is to wait for the PRs to mature and for me to get a sweet T-shirt. 
That was everything that happened during Season 1, stay tuned for Season 2 of my hacktoberfest journey next year around the same time... obviously for hacktoberfest.

Till next time, 
XOXO, 
Gossip Plamen


Release 0.2.4 - More Pythonic Automation

 


Hello again, my fellow programmers.

The end of the month of October is here and a fourth and final PR has to be made in order to fulfil the requirements of my 0.2 Release.

I will keep this post short and sweet (again)... because it is Halloween and I have candy to eat... erhm give out O.o 

So, this week as I mentioned above I had to complete my final PR for Hacktoberfest. I was stumped on what I actually wanted to do and contribute to as I was also pressed for time due to spending time on my ever growing open world concept level for my Game Dev. course. #ThanksGeorge

I searched and searched for something interesting to do with knowledge I already had. I then remembered that the point of each consecutive contribution was to learn something new. I remembered the Selenium/Python automation bot from my previous PR and saw that there was open issues the owner of the repo wanted help with. I picked one where I needed to scrape a phone number from a specific "open" chatroom in whatsapp web.

I got to work and I completely forgot about asking the maintainer to assign me to this problem, which I think is a big NO NO in Open Source Dev. 

So, I thought that since I used selenium in my 0.1 release to scrape a web page for links using Java, it would be similar. 

I mean it was not that different but the way the maintainer does the scraping is weird and I was not familiar with it. He finds/scrapes data by using the CSS selector class. Which I found to be an interesting approach, it is risky because whatsapp can change the layout and selector class and that can cause everything in the bot to break. But, I am not one to judge.

Nevertheless, I started searching how to scrape exactly what I was looking for:


Now, that I had the exact selector for the specific class I put the parent div selector class into the constant file class that Navpreet (owner of the Repo) had previously made.

In order to scrape the telephone of a specific chatroom with a person I had to:
  1. Use his already made function to Open a chat with a specific person
  2. Open the chat info
  3. Scrape the phone number from the person's info
  4. Close the chat room
  5. Return the scraped phone number
I ended up using a lot of already made functions throughout his code to avoid code duplications where it was unnecessary, and finished with something looking very simple and clean.

I tested and everything ran fine on my computer... KEYWORDS: "My Computer"
I made a PR thinking everything would be fine.

Navpreet reviewed the code and merged it. YAY!

He then messaged me on discord a couple of hours later saying that there was a bug scraping the number. This was happening because the element that contained the phone number was not yet loaded but the bot scraped something that did not "exist" yet... I have no idea what could be causing this since everything ran fine on my end.

Eh, whatever, I hopped on a call and we started debugging and we thought to implement a "wait" functionality for the bot to hang and wait for the element to be available in order to be scraped.

It worked!
Navpreet made a PR addition to my PR and everything was fine and dandy. 

He is actually a really cool dude. He lives in India and his English was perfect! I was surprised. We exchanged a couple of stories and laughs after we finished debugging. Needless to say I made a friend all the way across the world. Awesome feeling when you can connect with someone on a personal and intellectual level.

Anyways I am off to go HaNd OuT candy and watch a bunch of scary movies. 

Till next time, 
XOXO, 
Gossip Plamen

Saturday, 24 October 2020

Release 0.2.3 - Avoiding Boring People with Chat Automation

 


Hello my wonderful followers, aka my professor.

These past two weeks have been a nightmare for me (and many of my colleagues). This is due to the overwhelming amount of work that I have to do in my final year of my Computer Science program. #ThanksGeorge... BTW, George is my game development professor.

Anyways...
I will begin this blog by asking a question. Have you spent too much time on social media? Do you have boring/ignorant people that chat with you on a regular basis but you just have no interest in talking to them at this specific time? Yeah, you know who I am talking about. AND, if you don't know/have, you are one of those people.

So this week I decided to break away from the VR scene and continue my studies on my automation skill set. I found this really cool github with all kinds of automation bots that do various kinds of things. I found the most "popular" repo which was on the whatsapp platform. I saw one issue that still had no assignee so I acted quick. When I say quick I mean I commented asking to take on this issue quicker than my girlfriend changing her mind about where she wants to eat (and that's quick).
I got assigned to it probably within the hour.

Anyways, the issue was not hard at all. It was to replace some code with a modified version of an already made CSS selection "library". It really was not rocket science and any python beginner could do it. Now, re-read what I just said....
YEP, Python. 
But, Why Plamen, I thought you couldn't stand python and that the snek and you despised each other.
Yeah, well... I don't know, I really do not have an explanation to it. Maybe I enjoy being punished, maybe I am a masochist. Who knows.
No, the actual reason was that it was using selenium and I have a little experience with selenium from my 0.1 release. I wanted to see what else selenium can do so I forced myself to slowly start learning python.

Moving on.

I began to do exactly what was asked of me and began making the appropriate changes, as follow:
# from 
MAIN_SEARCH_BAR = '._3FRCZ'
EC.presence_of_element_located((By.CSS_SELECTOR, selector))
relement = element.find_element(By.CSS_SELECTOR, selector)

# to 
MAIN_SEARCH_BAR = (By.CSS_SELECTOR, '._3FRCZ')
EC.presence_of_element_located(selector)
relement = element.find_element(selector[0], selector[1])
 and so on...
I made my PR and it got merged the next day.
I thought this was not enough though so I looked through the person's other repos and saw they had began making a similar automation bot for facebook, a dying social media platform.

This issue was a bit more challenging as I had to make the base file for opening a browser with facebook as opposed to whatsapp and retain similar logic to his whatsapp file waobject.py 
I fiddled my thumbs around for a little bit and began examining how his code exactly worked. I soon realized that he did not want me to make any implementations but simply make the base file to open a session with facebook. Kinda lame but gotta give the people what they want I guess.
I finished my implementation and sent him a quick PR. Honestly, I believe that two small fixes/contributions were enough to call a combined 3rd PR for my 0.2.3 release. 
I just hope my professor sees it like that.
Even if they were not I came out with a lot more knowledge of python and selenium than going in. Quite frankly I enjoyed contributing to this person's repo as automation is becoming a more popular and growing idea of the current times. 

Well that was it for this week my friends. Short and sweet (again...)

Till next time, 
XOXO, 
Gossip Plamen

Friday, 23 October 2020

Lab 5 - Changing the Course of Time

Oh Boy oh Boy!
I am back with another week's worth of (meaningful) knowledge.

This week we were tasked with refactoring our code for our never ending assignment, link checker (DeadLinkage) for those of you who have not been keeping up with the Kardashians blog. 

I had to pick and choose at least 3 things I wanted to refactor about my code... TBH, I wanted to throw the whole thing away and never look at it again. SERIOUSLY! Although it worked flawlessly the whole thing was held together by a piece of reused duct tape that had fallen on the carpet.

Anyways, I started thinking about how to refactor this whole gigantic mess that looked like my current room state, into something that was modular and easier to look at, as well as easier to work with and maintain.

I came up with something similar to the suggestions put out from our professor.

  • I decided to get rid of global variables such as the CLI ANSI colors and store them into a completely separate class.

  • Split the main driver of the program into smaller more maintainable components and naturally moved them to other classes/files.

  • Refactored how the parsing of the arguments was being handled in the main driver program and split into components based on whether the user provides a URL or a local html file.

Now that the "hard" part of the lab was done, it was time to do some git...git...git outta here...

First thing I had to do once my final commit had been made into my refactoring branch was to rebase and squash the previous commits into one final commit.
This was done by: "git rebase master -i" which opened an interactive rebase editor where I was to pick which commit I wanted to squash the others into.

That went pretty smooth. I was expecting some sort of conflict to occur, but no. ðŸ’¯

The next step before I merged into master was to make a meaningful commit message because frankly the rebasing commit message was not doing it for me.
This is achieved by: "git commit --amend"

IT IS TIIIIIIIMMEEEE!

Let's merge to master ~sweating profusely~. 

uhhhhmmmm... WHAT?!? No merge conflicts second week in a row?
Am I doing this right? I mean I will take it and go on about working on designing my game for yet another time consuming course GAM537. #ThanksGeorge

I will leave you guys with that for this week.
Expect more of my greatness O.o in the upcoming weeks.

Till next time, 
XOXO, 
Gossip Plamen

Saturday, 17 October 2020

Release 0.2.2 - Entering Another (Virtual) Reality

 

Hello my fellow gamers.

Today's blog will be a continuation on the festivities of Hacktoberfest.

As I mentioned on my last hacktoberfest blog, I am a big VR enthusiast. I absolutely love escaping reality and jumping into the virtual world where I can be whoever or... erhm... whatever I want to be without any judgements. 

So as you all know I bought an Oculus Quest roughly a year ago and have been dabbling into VR open source lately. There are a lot of cool apps/games that are made specifically for the Oculus Quest.

Anyways,
for my second PR I wanted to contribute to something I recently found and have been using ever since I found it. The discord rich presence application for the Quest. It is basically an app that runs on your computer and updates your discord status based on the packets sent from the quest to your local network. The Quest sends packets based on event driven tasks, so every time you open an application a packet is sent. The PC application picks it up and updates your discord status to whatever the packet was.

The creator of this application mentioned that he is looking for contributions to their games/apps json list. 
I got into contact with him and chatted for quite a bit. He told me how to properly test the updates and how the application itself works (see above).

My chat with him went something like this.



Extremely cool dude.

Awesome, I got the OK from the owner to go ahead and contribute to his repo.

The first thing I did was open up his json file to find that there were already over 100 games/apps that were being picked up by discord... That did not make my job easier.

I opened up a third party store (SideQuest) tailored for Oculus Quest developers and got to searching for games that were not in his list.

I found content that I can update his json file with and got to work.

I added about 20 games to the list. Might not seem a lot but it definitely is for the amount of time I spent searching.

Everything was working as expected I fed the package name, the state and the description for each app.



I then pushed it to my fork on github and opened an issue on his repo. I made a PR and linked it with the issue.
To my satisfaction he merged my PR. I felt so good about contributing to an actual VR project. It was awesome. 

I will contribute something more in the future to this repo as it is very useful for Quest owners.

Well... that was it from me for this week. Stay tuned for my next contribution in the VR scene.


Till next time, 
XOXO, 
Gossip Plamen

Friday, 16 October 2020

Lab 4 - More Python Nightmares

 


Hello my fellow programmers/coders/readers... ah w.e.

Just an update on my academic career, or mainly my open source endeavors.

Now I know I said this in my past blogs, You've been following right??, but I absolutely hate Python. I don't know what it is the Snek is just not compatible with me.

So WHY for the love of god did you choose to work on Python again, you ask? Well, the answer is quite simple because I am a loser work well with my friend @chris. Mainly because I like his coding style (similar to mine) and his bald head. 

Anyways, this week in my open source dev class we had to pick someone else's previous 0.1 release and implement a rather easy but tricky feature to their program. We had to implement a feature that reads a text file and scans links to be ignored from a file or URL.

Alright, Cool! I've worked on Chris' code before this should be a light summer breeze. Boy little did I know that Chris wanted me to do a lot more than just implement this feature...

My guy basically wanted me to restructure his whole program to look cleaner.
Yeah... good times. But, w.e. I told him I'd do it and I am a man of my word.
He had this gigantic code block that was an eye sore. 

This was the first thing I did. I made different functions that were called and outsourced a lot of the work for each type of link with a specific status code. In a sense it is not more modular (I should probably make my code as neat as his TBH! But... then again who really cares).

Once that was done, it was time to get back to the issue at hand. My initial step was to add a "-i" argument option for ignoring links from the file specified.
Super easy. I wish Java had something similar of how it handles arguments. I had to write the following to the "-i" argument option: "nargs=2, action='append' " nargs allows me to take in multiple arguments with a single option. Neat! Yet again Python proves to be superior than Java.

*Actual representation of me dying on the inside*
The other option I had to handle was "concatenating" the arguments into a single list/array. This is done by the " action='append' " pretty self explanatory.

The actual file checking of the links was not that hard to implement. A basic try and catch.
  • Try to open file
  • if file opens call regex function to search for links that do not start with a "#"
  • return array if it found any links

I actually contacted Chris and asked him how he would like me to handle the removing the links that were to be ignored. He told me he would like to continue using BeautifulSoup. 

In all honesty, that actually made my life much easier, as I did not have to use a separate function for checking links. I simply modeled the checker around his old function.
That's it. I didn't really have any issues with the implementation, more the cleanup... (Damn it Chris)

The second part of the lab was to Review and Test the the code via Remote. so I did just that
I reviewed the feature that Chris had worked on for me and I was thoroughly impressed.
lol O.o
I did not have any issues or remarks towards his code. I am actually thinking of refactoring all those nasty if conditions to match his style of logic (as mentioned earlier, "cleaner"). 
For real, Great job as per the ujee.

I merged the code and to my favor there was actually no merge issues. 
Sweet! 
I honestly learned more about Python from this lab than about git. It's a neat feature but I would find it easier to make a pull request via github than on bash/cmd. 

Till next time, 
XOXO,
Gossip Plamen

Release 0.4.3 - The End of Something Great

  Hello my wonderful followers! It is here... It is finally here. The end of this nightmarish semester is finally here. I have to say the pa...