Showing posts with label Stress. Show all posts
Showing posts with label Stress. Show all posts

Thursday, 10 December 2020

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 past two weeks have been really tough for me, with all the final assignments/ labs/ projects.... AND exams bearing and breathing down my neck as the due dates approached.

Needless to say, I got through it. Pulled a couple all nighters and multiple 14/16 hour days worth of work. It feels GOOD though. I found this semester to be the hardest/ most amount of work that needed to be done. Yet, I finished and cannot express how many things I have learned over the course of this semester. 
I have to give my koodos to the very knowledgeable and helpful professor HumphD (OSD600 - Open Source professor). Without him, and this course, I would never have entered the world of open source and have my transition into becoming an open source dev/ contributor go so smoothly. 

Anyways, back to the point. For my last PR of this wonderful course, I chose to do yet another issue for the repo of automating whatsapp web platform. This one was tougher than the last or any previous issues I've done for this repo. 

I think my biggest downfall is finding out how to get python and selenium to collaborate with me without an issue.


So. Let's start by explanation of what I had to do.

I had to open whatsapp. Once connection was established through the bot, I had to cycle through all individual chats and open them.
Once opened the chat info drop down had to be clicked and navigation to delete chat (of the opened already chat) was to be made. Once over the delete element (which is found using a CSS Selector), the element had to be clicked. 



Clicking the "outter" delete would trigger another pop-up box/event to be opened. The bot would have to wait for the presence of the element to be available. Navigates to the element using a CSS Selector and clicks the element.


I ran into problems with the above step because the bot would hang even after the element appeared. I contacted my friend Navpreet (maintainer of the repo) and asked him why this was happening. He quickly glanced at my code when we were on discord with him (late at night because he lives in India) and he explained I was not waiting for the element to become available. So as I mentioned above. The bot would have to wait for the presence of said element "delete" and then execute the follow up functions. He told me it was hanging because it was throwing an uncaught exception and did not know what to do after the exception was thrown. Interesting stuff to be honest. I would have to remember that for next time I contribute to his repo, or other projects :D

After adding that little function in. All I had to do was close the chat info with the function "close_info()". I tested it one final time and made my PR.

I noticed a small problem with the bot behaving strangely on other functionalities that were implemented previously.

I noticed that some of them were not working how they should have been and mentioned it to Navpreet. He said he is aware of this issue and it was happening because of whatsapp changed their CSS Selectors. Thus making pretty much all the main functions break since the selectors did not exist anymore. He thanked me for noticing it as well and said he will make an issue about this when he has time, or fix it himself. 


To be honest, I will probably help him over the winter break since we are buddies now.

Well. Now that I am done with OSD and all my exams. Which by the way could not have ended on the most perfect date than the 9th of December... because CYBERPUNK 2077 came out. AND let me tell you guys. WOW. what an amazing game it has been so far. I have only played about an hour because I was dead tired yesterday, but I was at a loss for words. 8 years in the making was well worth the wait.

Anyways, 

I would like to thank professor Humphrey one last time this semester for giving my colleagues and I the tools and knowledge to gain tremendous amounts of experience this semester and work on whatever we wanted and found enjoyable. 

THANK YOU!


For the last time this semester...

Till next time, 
XOXO,
Gossip Plamen

Thursday, 3 December 2020

Release 0.4.2 - Progression Tree

 

Hello fellow programmers/ followers.
I sincerely hope this past week has been treating you great, because I sure have gotten stomped to the ground due to various things in my academic career -cough- Game Dev... #ThanksGeorge
I also got shot down hard by someone in my personal life. But that is too personal for the internet.

So anyyyyways.......

This week is a little bit of a continuation of the plans I made for my open source development ventures last week. A little bit of a recap.. Last week I decided to pick a repo that I have contributed to in the past. Seeing as my schedule is super tight until the end of the semester, I decided to go back a month and revisit the automating whatsapp web platform. I picked two issues because one was easier than the other and I had created something similar.

Ok!

So I saw that most people on the issues that have been assigned have made little or no progress. I asked Navpreet (the owner/maintainer of the repo) if I could take this issue. He gave me the green light. Although, to be honest I already had started working on the issue before he said it is fine (I knew it would be fine). 

I was tasked with creating a function similar to one that already existed. I had to create a function to remove Administrative privileges from a person/people in a whatsapp group.

As I began working I first examined the steps I had to manually take to remove admin privileges in order to replicate them and adding them into the automation bot.
Since the main logic is being done by Selector constants I had to find the selectors that were responsible for removing admin status from a person in a group.


I inspected the element with the chrome dev tools and quickly found exactly what I was looking for (this took me a while in Release 0.2, but I knew what to look for now).


P.S. The steps you take to removing an admin all lead to using the same selector regardless.

Now that I had my selector. It was time to actually put it in the constants .py file that is used for everything.
GROUPS__REMOVE_ADMIN = (By.CSS_SELECTOR, '._1OwwW ._3oTCZ[title="Dismiss as admin"]')

After that was done it was time to start writing the actual code.

The first thing I had to do was to iterate through the groups and find group name with the passed in one. This is being done by querying the selector and looking for it to match with whatever element you are on. Once the group chat was open, the bot needed to open the group chat info and navigate to the participants section. From there it searches for the name(s) passed in to remove admin privileges from, this is done by finding if the admin logo is present on their name. Clicks their name box and selects "Dismiss as admin". 

Everything worked. there was a couple of bugs at first. I was not checking if the user of the group was already an admin or not and the bot started hanging because it was trying to find an element to click on that did not exist yet. Another problem I actually ran into was that I had to tweak the CSS selector a bit because it is the same selector for making an admin and removing an admin. This is why in the above snippet I decided to include the title as well so it does not create an admin by accident.

Now, that I was done with this feature I could hurry back to Navpreet and have him run it on his end. I submitted a PR and since Navpreet and I are somewhat acquainted from my previous contributions, he knows my secret love most hated feeling is towards python and everything python related. So he gave me a little praise to help me with the next big issue I was going to do for him.


Everything is going swell. My PR even got merged. ONTO better things... not really. OSD is probably my most enjoyed course right now. Everything else feels like such a drag and there is sooo much work.

Anyways this is where I end things for my ventures of open source this week. I have actually started working on my other issue for Navpreet but it is proving to be a little more difficult than I expected. 0.4 amiright?!

I am now going to crack open a beer and enjoy the rest of my night, and try not to think about stupid little details.


Till next time,
XOXO,
Gossip Plamen

Tuesday, 24 November 2020

Testing to Pass the Time


What is going my good people of open source dev?

Have you ever dreaded those damn tests in school? Have you always put your heart and soul on the line to get that 'Pass'? Yeah, me neither...

This week's lab in my open source class we were tasked with creating unit tests for.... 
**queue drum-roll**
Our link checker program... Yes that again. Those of you who have no idea what is going on, good... you don't need to know. DeadLinkage (just incase you are interested)

Anyways,
As I mentioned, we had to integrate unit testing in our link checking programs. Let me start off by saying #$%! unit testing on java... OH MY GOD! What a pain in the ass this lab was.
I mean I loved the way java handles everything... But for real though. Unit testing on my code was a nightmare. I spent roughly 3-4 days trying to get JUnit (the testing framework for java) to cooperate with my IDE. 
BIG MISTAKE
It was a mistake primarily because everything had to work on a CLI. 
Anyways, at first I tried to get stuff working with JUnit5 everything was fine and dandy up to a point where I had to mock objects and classes such as the HttpUrlConnection and URL.

This posed a problem because the mocking API that I had settled on using was mockito. There was not a whole lot of documentation and examples of Mockito cooperating with JUnit5 so I decided to backtrack a version of JUnit to 4.12.

A good chunk of my time was spent walking back and forth while reading documentation on my phone about how mockito works. On my off time I would try code only to have it fail miserably.

I decided to take my problems to stack overflow and see if anyone else has run into this issue. I spent about a day reading through stackoverflow pages/questions and came to the conclusion that mockito, while a powerful mocking tool. Could not mock Final classes, the exact classes I was trying to mock (of course...)

While reading similar problems from other people trying to use mockito to mock final classes I came up on a forum that described an API that was used in parallel with mockito, Powermock. Powermock had an API of its own that works with the mockito API and served as sort of an extension to it.

So began my readings of the novel called "The Documentation". The way powermock is used was very similar to the way mockito is used to mock. Actually they were almost identical, slight variations from version to version in syntax, but that didn't pose much of a "threat". 

OK, COOL.

Theoretically, it should work right? WROOONG!
I was so close to making it work until I ran into another problem. Version compatibility.....
AGGGGGGGGGGHHHHH

The first thing I did was ask this cool girl (who unrealistically also likes Java like me)... and a lot of other things but anyways. Nesa had no idea what the issue was and proved to be of no help. She actually said she hadn't started the lab herself so she had no idea what to do. Here is a little proof.

Thanks for the compliments Nesa, but nice habits don't write the unit tests. (or at least not yet)

So, powermock 2.x is not really compatible with most versions of mockito. The same goes for the opposite. A full compatibility list can be found here. (note: I did not find the compatibility list right away) Learn from my mistakes and get the right versions.

Awesome! I found the right versions, downloaded the correct JAR files to stash in my external library list and now it was time to write some tests. 

For my first unit test I picked an area of my program that would be easy to work with and wouldn't be dependent on many mocked objects that needed to be passed in. That area was my function to load an ignore-urls.txt file. The only parameter that this function needs is the filename which is given through the system arguments (which are stored as Strings) when the program is ran. I had to mock the file name being passed in which was as simple as making a string hold a "filename.txt" and running the function with that argument. The function returns an array list of strings which I then had to iterate through a loop and assert that they were returning the correct thing. Easy peazy.

Hazaah! and so I had written my first unit test. I ran the test (remember in my IDE) and everything was working correctly. I decided to try and run the test on the CLI. aaaaand more problems started occurring. I was not able to compile my test java file due to the terminal that I was using not being able to see environment variables. I took my problems to the very helpful and knowledgeable professor HumphD. 



What do you know, the professor was right. Everything compiled fine in command prompt and another version of PowerShell. Thank you for the help! I was pulling my hair out and almost ended up looking like my buddy Chris.

It compiled, sweet! I only hoped that was my biggest issue at the time. I tried to run my compiled Test Runner only to have it crash and burn for missing dependencies. There was way too many for me to add and I did what every sensible person would do. 
PROFESSOR! I NEED HELP... again.
I explained what the problem was and David (yeah first name basis, we are cool like that) told me something I dreaded of hearing ever since I started this damn link checking program at the beginning of the semester. 


"
Make a build project!" That is all I was hearing and my ears were ringing like I had been standing next to a speaker at a rave/club (ah what simpler times we lived in before all this pandemic stuff started happening).


Well I guess it was time to do the right thing. It was time to use a build tool like maven to "manage all this crap" as HumphD put it. 

Integration into a maven project really was not that hard. The IDE (IntelliJ) I use actually makes it really easy for you to setup a maven project structure on a Java project. I will link it here, in case others are trying to do the same.


Once maven support was added into my project I began to add the dependencies from the maven general repository, where you can find almost anything and everything. It is extremely easy to add a dependency into a Java project with maven... Literal click of a button.
Anyways once everything was setup, I ran the test I had written from before (The maven way) on cli and everything compiled and ran PERFECT! I was so happy I got over this hurdle and could finally move on after 3 days of pain and torture on my way back from the depths of hell.

Oh man, maven opened my eyes to a whole new world with Java. Maven is now my new best friend. Everything is so easy with this build tool.

Anyways, I moved on and started to write my tests for the core of my program. Testing my CheckLink logic. These functions basically take in a URL (string) to be checked and a HttpUrlConnection to get the status code of said URL. Remember 10 minutes ago when I was explaining about mockito and powermock being used together to mock final classes such as HttpUrlConnection? Well, this is what I needed this mocked connection for. I had to mock the status codes for a specific url, I chose google.ca because why not. I set the status code of the mocked huc to 200 and 404 so that they would pass my goodLink and badLink functions and basically checked the output the function returned against an expected output I had preset. This was not that bad once I already had the knowledge of how to do this. Once I finished writing the tests I ran all tests and to my amazement everything works flawlessly.

I am so glad I spent a couple of hours rebuilding my project as a maven build. PHEW. In the long run it probably saved me so much time.

Next on the task list was to incorporate a code coverage tool. I chose to work with JaCoCo because it was the first one that popped up on google it was in the maven repository and was easy to work with. Guess how long it took me to get it up and running. Roughly 15 seconds!

MAVEN BAYBEEHH! but for real I just copy and pasted the JaCoCo dependency code into my pom file and specified the directory I wanted my new reports to go in and ran my tests. Boom I now had code coverage (although not a lot of code was covered with 3 tests LOL)!

Next up on the task list was to add integration testing via github actions. This was not hard at all. Github actually has already made templates for executing maven tests. I just had to change the platform that the project was being built/ran on from ubuntu to windows although I doubt that makes a difference anymore since I added maven support. 
If you are interested in my workflow file it can be found here.

All I do in this workflow is the following:

  • Setup Java
  • Cache dependencies
  • Compile the project
  • Run tests
Running tests is dependent on whether the project compiles or not. If the project does not compile there is no point in running the tests. That is it. Pretty simple. Github documentation on maven CI was probably the clearest documentation I read throughout this whole lab. 

Anyways this is how executing the tests look like on each commit to master.

                              

The next item on the agenda was to write some tests for a fellow class mate. I did not even give it a thought I messaged my bald headed friend Chris right away to ask if he wanted to work together on this lab as well. To my surprise he said sure. I really did think he hated me.

Anyways, as I have expressed my feelings about Python before (utter hatred). I asked Chris to give me a little crash course on using pytest to see how everything works. He did a great job of explaining everything. We then discussed what exactly he wanted me to write tests for. He mentioned that he would like tests for the functions that print out each status code...(like why was this necessary for you to make Chris) uhm yeah sure let me do that.

So I decided to add the following tests to ensure they were returning proper status codes and that nothing was broken. If these functions stopped reporting the correct code the entire program will break. so anyways this is what I came up with.

For:
def test_status_check_unknown(capsys):
  • this function is used when a link is unknown
  • I had to figure out how to capture stdout and read what was being returned from a test
  • I also had to find the ansi codes to verify the texts match from stdout since the text color was white
The next test I just made a mockresponse() class and assigned a status_code of 300 and checked that the object had a status_code member which was set appropriately. I did this because the 'requests' library in python returns an object containing these details so I mocked that. 

The rest of the tests are more or less the same, I just had to ensure the ANSI code was correct. 



I tested this on my end using the Pycharm IDE, I also changed the function I was testing in question and the tests did in fact fail because the underlying functionality of the base function failed. 
This reminds me of the matrix checker for our submissions in IPC/OOP/345.

FINITO!

Overall this entire process was a nightmare, I would never want to repeat it again. 

HOWEVER, with that being said I learned so much about java, build tools, unit testing and integration testing. It was a really big learning curve to say the least but it is now done and I can finally do some Game Dev work for my final project. Thanks for the learning experience David. It really was a lot of involvement and reading on this one cheers.

Working with Chris was always a sad reality that I had to settle to work with this bald little man 😐 LOL I'm joking Chris, it was a pleasure as always.


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

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

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

Monday, 12 October 2020

The Merge Conflicts of Life


Hello my fellow strugglers,

This week in Open Source Development we were tasked with making a couple of small features to our ever growing and glorious link checker program.

TBH. 
I feel like there is nothing glorious about this program and the way I did it. I am realizing this the hard way. Even though Selenium gets the job done, but at what cost, something like this would be written better in plain java. Eliminate all these dependencies.

Anyways, before I go off topic too much, we had to implement 2 small features or "upgrades" if you will.

The first feature I chose was to add in exit codes, really simple. Since I had made a separate function to check links all I had to do was put the function call in main in a nice little try and catch. If anything went wrong an exception would be thrown and a boolean variable would be made false and would exit with an exit code of 1. Super simple even my cat could write it.

My second feature however, took a little thought. I implemented a command line argument to check for good, bad, and all links with their respective arguments. Sounds easy, but  I had to refactor a lot of my old code to make it happen.

BUT!

That was not the point of the lab. The point of the lab was to merge the 2 branches together and see if we get any merge conflicts and deal with them.

Alas, my two features were complete and it was time to merge them. Naturally my first merge went without a sweat.

Time for my second merge.

MERGE CONFLICT!!!!!!!!

Of course there was a merge conflict, why wouldn't there be one. Life couldn't have just given me this one favor this week.
Meh, W.E.

I opened up my IDE and checked out what the issue was. To my benefit it was just a couple of lines that were having problems with each other. Easy fix!
Thank goodness that was over because I had just came off a whole nighter for one of my other courses (Game dev....)

I had to fix a merge conflict before and it got real messy because I didn't know what I was doing I never encountered one before and had no experience with them.

TBH.
I would not change anything next time when merging something because working on different branches and having these small merge conflicts are just part of the fun road to success.

I am now going to stare at my screen pretending I know what is happening work on some data structure labs.

Till next time,
XOXO,
Gossip Plamen

Thursday, 1 October 2020

Open Source Progression - Lab 2

Heya Everyone

I hope everyone is enjoying the week so far. It sure has been a busy one for your boy.

So, I'm going to try and keep this one short.
Just as a refresher, in my last post I talked about how I reviewed Chris' repo and filed issues and even submitted a small PR.

Well, I jumped the gun on that a bit showed initiative last week because contributing something useful was the task for this week. We were tasked with adding 2 optional features that had not been implemented yet. So naturally, I chose the feature I thought would be easiest to implement I could do since I absolutely detest python. 

Going down the list and reviewing his code once again I noticed that he was using the request "get" as opposed to "head". I figured this wouldn't be much of a PR as it was fairly simple. I decided to make another feature because Chris was doing two why not. Next on my hitlist was the 300 redirection. It sounds pretty simple right?!

Well it was and it was not at the same time. I had troubles storing the URL of where you were being redirected. A quick search and I found my answer on a stackoverflow thread.

In order to store the history and allow redirecting I had to implement another request.

req2 = requests.head(test_link, allow_redirects=True)

Awesome everything worked out and redirects were now being followed. I don't know what happened when I was trying to create a PR for this feature but I had an issue with pushing my updates. Super weird... I had no idea. After a little tinkering I figured it out but it was annoying.

That was the feeling I was getting.

Anyways...
I got some features implemented on my own repo. Chris copied my idea for added redirection feature which was really neat. I completely understand the battle with getting the web driver to cooperate with what exactly you want to do. Maybe selenium isn't the best way to do this sort of thing, but then again anything can be done. I also saw that he fixed my status code ranges. Chris added Linux command line support which shouldn't have been that hard, aka adding more conditions in the if statements.

HAHA. Jokes aside, thanks for the contributions my dude. That is two less features I have to worry about. I really appreciate it.

Something I agree with Chris on is that we should have communicated ALOT more in regards to implementation. Instead of spending hours searching for an answer on threads we could have just asked each other, but I guess you live and you learn right?! Doing this I confirmed my initial thoughts that I HATE (love) PYTHON.

Till next time,
XOXO,
Gossip Plamen

Friday, 25 September 2020

New Issue -> PR, New Issue -> PR, New Issue -> PR ... Hold Your Horses

 


OK!... 

Now I know I am no expert or even come close to it, but how do you find issues in my code?
Not to boost my ego or anything but I have been programming in Java pretty much since "Day 1", and consider my knowledge slightly above average than the regular newbie acceptable. 

This week we were tasked with finding a person on slack to work with and I did just that, Chris - Bald (🦲) dude with a bad attitude. We had to fork, analyze and create new issues on their (Chris') repository.

OH BOY!

So I began forking, cloning, analyzing/ reviewing, fixing... the whole nice yards.

Chris did his 0.1 release on python EW. If you guys should know something about me, it is that I absolutely from the bottom of my heart despise python and anything built with python... but Chris looks like a smart dude and I figured looking at his code might not give me a brain aneurysm. P.S. it did not.

Anyways, it was time to begin. upon cloning his repo locally I began to read the README file he had provided with instructions on how to setup the tool and get it running. That is where I ran into the first issue. Since I hate python (as mentioned above) I had no idea which version I needed to install on my machine to get it running. I suggested he add a download link in the readme. The rest of the setup went pretty smooth.

Time to analyze

This was fun! Looking at how someone else handles the same exact problem is fascinating. Chris did a great job on his code, I did notice some exceptions that could be handled a little better but with my knowledge in python (basically none) I could not make a PR for that. Instead, I found something small that was confusing at first glance. His variable naming conventions, although fine for such a small tool, were not to my liking. So... I made what any other sensible person would have done. My first PR BABEEH. He actually merged it. I felt a sense of accomplishment, a sense of contribution. 

Likewise, Chris found several issues on my 0.1 release. They were not anything ground breaking but he did help me clean up my code a bit. He edited my instructional README quite a lot, which was a punch in the gut I thought was clear enough but with the edits it looks and sounds more clear. Thanks bud.

All in all, this experience with communicating, reviewing, and fixing other's "mistakes" was a very insightful experience on how the real world operates. 

Chris was an awesome partner and I agree with his words (some) "We Learned", however I would say...

We didn't grow, We didn't laugh, I definitely hate him.

Till later,

XOXO,
Gossip Plamen

P.S. I don't actually hate you that much Chris

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...