Planet CDOT (Telescope)

Monday, October 26, 2020


Chris Pinkney

Release 0.2.4 or, These English Muffins Keep Throwing Stuff At Me

Get it? Throwing stuff? Like errors?

For my fourth and final act... I will make this bug, disappear!

Wait... what the hell's a Flask?

CANNOT RUN PROGRAM: CREATEPROCESS ERROR=5 ACCESS IS DENIED
ATTRIBUTE ERROR: NAVIGABLESTRING OBJECT HAS NO ATTRIBUTE "FIND_ALL"
CANNOT RUN PROGRAM: CREATEPROCESS ERROR=5 ACCESS IS DENIED
ATTRIBUTE ERROR: NAVIGABLESTRING OBJECT HAS NO ATTRIBUTE "TEXT"
CANNOT RUN PROGRAM: CREATEPROCESS ERROR=5 ACCESS IS DENIED
ATTRIBUTE ERROR: NAVIGABLESTRING OBJECT HAS NO ATTRIBUTE "CONTENTS"

⢀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⣠⣤⣶⣶
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⢰⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣀⣀⣾⣿⣿⣿⣿
⣿⣿⣿⣿⣿⡏⠉⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿
⣿⣿⣿⣿⣿⣿⠀⠀⠀⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠉⠁⠀⣿
⣿⣿⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠙⠿⠿⠿⠻⠿⠿⠟⠿⠛⠉⠀⠀⠀⠀⠀⣸⣿
⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⣴⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⢰⣹⡆⠀⠀⠀⠀⠀⠀⣭⣷⠀⠀⠀⠸⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠈⠉⠀⠀⠤⠄⠀⠀⠀⠉⠁⠀⠀⠀⠀⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⢾⣿⣷⠀⠀⠀⠀⡠⠤⢄⠀⠀⠀⠠⣿⣿⣷⠀⢸⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡀⠉⠀⠀⠀⠀⠀⢄⠀⢀⠀⠀⠀⠀⠉⠉⠁⠀⠀⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿

So, this will be my fourth and final pull request for ODS600's release 0.2 assignment (and also Hacktoberfest). Let's jump right into it.

Plain Old Recipe is a Flask-based website (lovingly made with markup based on https://evenbettermotherfucking.website/) that I use occasionally that solves a really interesting problem I never knew I had until I started noticing it. Have you ever been on a recipe site and wondered why the hell there's so much extra text or a story? It's actually related to search engine optimization. (It's actually really interesting) But listen Delish, I don't care about your SEO ranking or how super-fantabulous this recipe will make my nonexistent kids love me more, just give me the fraking recipe- I have people to disappoint doncya'know.

tl;drs aside, I had heard through the grapevine that it's actually open source. Neat. I took a peek and stumbled upon an issue that jumped at me: A particular recipe website was generating two sets of ordered list numbers. Interestingly the author was already talking with someone else about how to fix this issue and mentioned that the issue might be caused by either the website or the underlying recipe scraping library (which I didn't even know was a thing. From the poking around I did, it actually seems like a really well designed library.)


My first approach (titled: BLAME THE DEPENDENCY) was to see if this library was causing the issue. From there I'd know to fix the library or to fix plain old recipe. I installed the library and tried to run it, from here I actually learned a bit about how unit testing was done in Python, as the libraries install script runs a test coverage suite. I also discovered that my Python install somehow broke overnight and needed to be fixed (or at least that PyCharm had become very, very confused.) With Python reinstalled I made a simple script to scrape the recipe in question. Interestingly, the library scraped it just fine. Time for a second approach (titled: BLAME THE WEBSITE.) This library is slick though, I'd love to try to remake it using another stack sometime.

My first step was now to learn how to set up a Flask server. I poked through the documentation to see if anyone or the author had mentioned how to run it locally. His deploy.sh file deploys it on gcloud? Weird flex but okay. Anyway let's not do that. After a bit of digging into Flask (something I've always wanted to learn) it turns out all I had to do was: clone, install the requirements, and run main.py. Great, my local copy was up and running, and reproduces the issue as well. Now it's time to get my hand dirty.

From here I tried to update the recipe_scrapers dependency to its latest version (which coincidentally was just released a few hours ago). I was hoping this would be all that's required, maybe the library had the issue and resolved it? Thankfully it turns out no, it did not, no I don't have to find another issue to work on. From my first PR I learned that I should peek around things before trying to bash my head against something hoping it works, so that's what I did. Turns out the website grabs the URL, checks for a local scraping alternative, if present it'll run that parser, if not, it'll rely on the recipe_scrapers library. From there I figured the best bet was to just write a parser for the website in question and bypass the library entirely. So I figured out what the html template wanted from a recipe object and modelled a parser around that. I also looked at the surrounding parsers and used them as a reference, but a lot of them used JSON which seriouseats.com did not output to.

I started small, figured out how to grab the title, then the description (which plain old recipe doesn't actually grab), then the image of the food we're making, then the ingredients, and finally the actual directions. The directions were the trickiest thing to figure out how to scrape properly from seriouseats.com. I finished the rough draft of the parser in a few hours, but decided to test it on other random recipes which... broke everything. This is when I discovered that seriouseats.com is kind of a mess. Sometimes it renders extra paragraph tags, sometimes it renders blank lines. Luckily BeautifulSoup4 (a web scraping library used in the project which I have a bit of experience with) is flexible enough to just let me grab the string inside of a specified div's .class, which fortunately for me was always the same. After fixing my base issues every recipe I tested my parser on worked as expected. A lot of websites try to obfuscate their templates to detract from scraping, but I guess that's a problem the recipe industry doesn't typically have to worry about (This is actually a really interesting read.)

Funnily enough I actually spent about 20 minutes wondering why a particular recipe kept throwing errors... turns out it was just an article I had mistake for an actual recipe...

I submitted my PR for the author's consideration. Hopefully he's okay with how I did things.

I think I'll also submit some documentation on how to run the website locally. It was fun to learn a bit about Flask, it seems like a really neat technology. I'm not sure how relevant it'll be though, I surmise that JS/TS will continue to eat... well, everything that the market has to offer as the world pivots towards everything being a web app.

But that about does it for my Hacktoberfest 2020 adventure (even though two of the repos I contributed to didn't count towards the 4 PRs necessary for a shirt.) I had a lot of fun and learned a ton from the various projects I worked on. I'll be making a final Hacktoberfest blog post detailing everything shortly.

Man, it's nice to be able to just work on this stuff without having other course work.

by Chris Pinkney at Mon Oct 26 2020 17:10:51 GMT+0000 (Coordinated Universal Time)


Jennifer Croft

Hacktoberfest - The 3rd PRRrrrrr... hmmm...

For my third contribution for Hacktoberfest, I wanted to contribute to a C# project. I browsed the Hacktoberfest website and came across UtilityBelt. I looked at the files to see if this was something I'd like to try... I think C# has become one of my favorites. So um...Utility Belt, a console application that handles multiple smaller console applications using API's. Completely unsure of how I was going approach this and the format of the project was unique in comparison to what I have seen before. At Seneca I had taken a web class on ASP.NET using C#. The only thing is, I had not looked at C# since the Hackathon in June!

I created my branch and then just sat there. Reading the project so I could figure out what I would do. Since the original suggestion to me was not going to workout because I was unable to get the API. I needed to come up with something. While going over the project and discussing it with my friend, he suggested Elephants. The girl in me said "Perfect, I absolutely love Elephants!"... wait, I said that out loud!

So I went to work. I had viewed some other files so see what was necessary to include in my contribution. I also needed to view the Elephant facts. Once a basic code was made, I ran it. Not the results I wanted. Thought some more, read some more and discussed a few approaches for different outcomes. Finally figured out that I needed all the the variables to get the results and then I decided that I wanted to only print the "names" of the different elephants. After I achieved the desired results, I pushed the code and sent the pull request.

Well look at that! My contribution was approved and merged. This was a fun refresher to using web API's in C#. I feel like the memory of this process is much more preserved then doing an assignment with a deadline. It is certainly more fun when you can decide what the outcome should be!

by Jennifer Croft at Mon Oct 26 2020 03:55:50 GMT+0000 (Coordinated Universal Time)


Sanjida Afrin

Contribution in Ember

Another issue, Another PR, Another contribution and Another blog. You know the rule! This is my 3rd PR towards Hactoberfest. I have been looking for the “perfect” issue since last week. I even started working on two of them, SUI components and a Tic tac toe app, but halfway through I was lost. Either it was difficult than I thought or there was not enough information to guide me. After searching and getting frustrated, one of the ember’s framework’s issue caught my eye at 10am today.

https://github.com/emberjs/ember.js/issues/18060

Though there was not enough details about it on the issue, some people had already contributed on that issue as this issue contained multiple parts which guided me. To be honest, I was scared to contribute such a big framework and was overwhelmed by the amount of files and instructions. Then, I remembered my open source prof’s talk on slack from this week, “Removing code is a super power.” I thought why not have some power 😎

As always I followed the basic steps of contribution: forking, cloning, crating a separate branch, installing all necessities and running it. To run it, I needed to install yarn which also required updating npm to the latest version. While everything was installing, I started working on it. As you can see the main task is removing flags, but removing something from somewhere means you have to be aware and keep track of where else it has been used and needed removing. Now, I have a question for you: What’s your first impression when you see this issue? I guess it was something like this, “Oh! It is just removing some code, just press backspace. You are done!” Actually I would lie if I said I did not think the same. Later, I knew how wrong I was. Removing code is a delicate process.

As you can see, there has been multiple flags to remove and just one was left. I picked the last one.

To find which files used EMBER_GLIMMER_SET_COMPONENT_TEMPLATE_FLAG , I took advantage of grep command.

grep -rl "EMBER_GLIMMER_SET_COMPONENT_TEMPLATE_FLAG" .

Easily, I got the list of files and read each files carefully to see where and how this flag has been used. After I had some understanding of the code, I started removing the initialization of the flag, the export of the flag and the flag from if condition. After each changes, I ran yarn start. I committed the changes to my branch. I ran yarn test from master branch to compare the result to make sure I did not break anything. The test passed 😃Finally, I made my PR.

https://github.com/emberjs/ember.js/pull/19229

I wish it ended right here!! My PR failed their linting test twice😢First time, it was double whitespace in one of the file which I fixed easily. The second time, there were 3 errors and I easily fixed 2 of them, but the last one was confusing. The error and the line were:

Delete ‘.’ from prettier/prettier

As can be seen from the above line, there isn’t any . character that needs to be deleted. When I ran the linter test on my computer, it was producing hundreds of similar errors.

After awhile it was obvious that something was seriously wrong because my change only involved 6 files and yet the linter was reporting errors on almost every file. After a bit of researching online, it seemed this may be caused by line endings. I am using a Windows computer where line endings in text files are always of type CRLF. And the above error in CI test was pointing to the line that I did modify. So, perhaps the linter configurations in this project/repository is not setup to handle Windows style line endings.

I had access to another non-Windows computer. I cloned my branch and ran the linter test again. In there, my linter test matched exactly as the CI test. I wasn’t getting hundreds of errors from so many files. So, that confirmed my findings mentioned above. After opening that file in VS Code, the status bar showed that the file now has LF style line ending. After saving the file, I ran the linter test and it passed successfully this time. I committed the changes to all 3 files as needed and pushed my change again. This time the CI completed successfully.

This repository may need to be updated for better cross platform development experience. I’m surprised that a popular framework like this has this problem and there weren’t any existing issues about it. Lastly, I feel thrilled to successfully contribute on such a big framework and hopefully my PR will get merged.

by Sanjida Afrin at Mon Oct 26 2020 02:50:51 GMT+0000 (Coordinated Universal Time)


Raymond Rambo

Lab 05, or how to refactor code

This week was all about tightening up our code. For me, that meant looking at what I wrote that added bloat, and what I wrote that broke modularity rules. Oh, I also cleared up some variable names.

This stuff is really important! Having messy code is something that's totally possible and honestly, pretty likely given how much time you can spend working on one project.

Let's start with my first and easier improvement, clearing up variables names.

fs.readFile(`${argv[2]}`, (err, fileContents) => {
    try {
        var linkList = generateLinkList(fileContents);
        linkList = Array.from(linkList);
    } catch (err) {
        console.log("The app has recieved a wrong filename.")
        console.log("Please enter a correct filename.")
        exit(1);
    }
    validateLinks(linkList)
})
Enter fullscreen mode Exit fullscreen mode

This is an excerpt from my code after I changed a few variable names. For one, all my linkList variable names were one work linklist which made 1. it harder to read and 2. not in line with best variable naming practices. So I fixed that up. Secondly, the fs.readFile(`${argv[2]}`, (err, fileContents) was originally fs.readFile(`${argv[2]}`, (err, data) which I found to be quiet uninformative. I changed it because I frankly want to be able to know what I'm referencing in the future. There were a few other changes like this that I made, again just to make the code more readable and follow best practices.

Second, I decided that I was doing 2 things in 1 function that I thought ought to be relegated to their own.

const isValid = (link) => {

    return new Promise((resolve) => {
        req.head(link, {
            timeout: 1500
        }, function (_, res) {
            if (!res) {
                if (!options.b && !options.g) {
                    console.log(chalk.gray(`[TIMEOUT] ${link}`));
                    process.exitCode = 2;
                }
                return resolve();
            }

            const status = res.statusCode;

            displayStatusCode(status, link);

            resolve();
        });
    })

}

const displayStatusCode = (code, link) => {
    if (code === 200) {
        if (!options.b) {
            console.log(chalk.green(`[200] GOOD ${link}`));
            if (process.exitCode != 1 && process.exitCode != 2) {
                process.exitCode = 0;
            }
        }
    } else if (code === 400 || code === 404) {
        if (!options.g) {
            console.log(chalk.red(`[${code}] BAD ${link}`));
            if (process.exitCode != 2)
                process.exitCode = 1;
        }
    } else {
        if (!options.b && !options.g) {
            console.log(chalk.gray(`[${code}] UNKNOWN ${link}`));
            process.exitCode = 2;
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

These 2 functions used to be 1 but after thinking about it, I felt that it was pretty important to separate the act of finding the status code and displaying the good or bad message into 2 different functions. It just makes sense. The code is more modular, another person can now edit the display function without messing with the isValid() function and vice versa. This change was common sense and was obvious from the moment I read about refactoring our code.

I think there's a possibility of further restructuring like taking the status code returned from the promise and sending that to the displayStatusCode function instead of calling the function within the promise, but I'll think about that over the study week.

Finally, I decided to just cut down on some unnecessary lines of code.

fs.readFile(`${argv[2]}`, (err, fileContents) => {
    try {
        var linkList = generateLinkList(fileContents);
        linkList = Array.from(linkList);
    } catch (err) {
        console.log("The app has recieved a wrong filename.")
        console.log("Please enter a correct filename.")
        exit(1);
    }
    validateLinks(linkList)
})



const generateLinkList = (fileContents) => {
    let list;
    if (options.i) {
        list = getUrls(fileContents.toString(), {
            stripWWW: false,
            exclude: iFileArr
        });
    } else {
        list = getUrls(fileContents.toString(), {
            stripWWW: false
        }); 
    }
    return list;
}

const validateLinks = async (links) => {

    for (const link of links) {
        await isValid(link)
    }
    console.log("=========================");
    console.log("Exiting with exit code: " + process.exitCode);
}
Enter fullscreen mode Exit fullscreen mode

So here we have 3 functions. the fs.readFile() goes through the file and sends the block of text to generateLinkList() to separate the links into a linkList of links which it then returns. Finally, the fs.readFile() sends that list to validateLinks() to validate them by calling isValid() which we looked at previously and finally, end the program.

Before this, there were actually 4 functions. The 4th was called separateLinks() and all it did was call generateLinkList(). Pretty superfluous, no? So I got rid of it.

I think I may also want to find a way to remove global variables and separate these things into separate files. Again, more changes I can make over study week.

The interactive rebase for this code went well! I only wrote 3 commits, one for each change, and I didn't have anything extra to add at the last second. I simply squashed the commits together and we on my merry way. I'm concerned that my ignore function isn't working properly - or at least when I change it to check for the -i argument in a different function it seems to break. Something to definitely take a look at because I think that portion of the app can use an overhaul. Changing my project's history was... odd. It felt wrong in a certain way. I understand changing commits to reflect actual changes (and not "...commit" like so many commits are) but I'm concerned that this can lead to exploitation. However, the maintainers or anyone else looking at a commit can clearly see what was changed on any given commit so I don't think there's much to worry about.

Anyway, that was my experience for Lab 5 and in general, refactoring my code. I think this is a process I should undergo more often in my projects if only to keep myself honest when a project gets even a few features larger. I'm going to definitely come back to this project and do some more refactoring over the next week.

by Raymond Rambo at Mon Oct 26 2020 02:09:27 GMT+0000 (Coordinated Universal Time)


TJ LeBlanc

Hacktoberfest Week 3: One letter off

Hey guys, I’m back with the 2nd last Hacktoberfest post I’ll be making. Time really flies when you’re busy repo hunting…

Last week, I worked on 2 different repositories: EnigmaVSSUT and josa-web-portal. Since I worked with CSS for week 1 and did some work with Javascript for week 2, this week I wanted to to do something that would hopefully have elements of both in it while also preferably being a project done in VueJS.

Well, things did not quite go as intended, but at the same time they kind of did? It’s a very weird situation to say the least.

NextJS, not Nuxt.js

So I’m gonna cut to the chase: I was running off of 3 hours of sleep, and I found a repository called moonshot-chingu-quiz. This project is a WIP website that contains interview questions and general coding practice questions designed to help people learn and prepare for job interviews. These questions are contained in quizzes that are separated by programming language, making things nice and organized. It’s a cool idea for a website and something I could see myself using in the future when I’m out job hunting. On top of this, one of the issues I noticed involved fixing theme switching functionality for a component on the screen, which was coincidentally something that I worked on last week but for a much, much smaller repo. This would give me the perfect opportunity to use what I learned to help out in a bigger project, which got me excited.

Now the issue was that my illiterate, tired brain failed to comprehend the text on the screen and I read NextJS as being NuxtJS, and by the time I forked the repository, set up everything and looked through the code, I was left with a nasty realization that I had made an oopsie. Truly fantastic.

I didn’t want to just scrap the repo and continue looking for something else because I was having problems finding anything, so I decided to just suck it up and attempt figuring it out. I started off by doing some research on NextJS since I had never heard of it before, and I quickly learned that it’s a framework for React. That by itself was going to be a problem as the last time I used React was in BTI425 last year, and admittedly I’m a lot better at Angular than I am React for whatever reason. So there were 3 major problems that I’d have to deal with: my mediocre knowledge of React, my nonexistent knowledge of NextJS, and the fact that I was half asleep on top of all of this. Any sane person would’ve just scrapped everything, went to bed, and contemplated what to do next afterwards. But that clearly does not apply to me, so I pressed on.

Figuring Stuff Out while Contemplating my Life Decisions

I decided to take the approach of looking through some of my old React work for BTI425 as a refresher, and then brute force my way through this situation by just figuring out the structure of a NextJS project as I looked through the code in the repo. It was kind of a pain, but it pretty much worked. I eventually got a solid grasp of the project structure and after a while, I was ready to begin working on the issue.

I located the file containing the problematic component and began trying to figure out the problem. After 10 minutes, that’s when it hit me: I really did not have a solid grasp of the project structure and I was completely delusional. I decided to look through every folder and file in the project thoroughly once again, and then I returned back to what I was doing. After a while, I actually managed to figure out what the problem was.

When theme switching was incorporated into the website, not all of the components/pages were properly updated to support this new feature. Some of them, including the component I was working on, were still using static colors that had nothing to do with the theme switching code. To fix this, I had to update code such as this:

    color: ${props => props.theme.colors.text};

To this:

    color: ${props => props.theme.colors.textPrimary};

Adding Primary to the end of the colors would make them the versions that are affected by theme switching. I initially thought that there might’ve been a problem with the props that were being passed in and was focusing on that, so I was surprised when I finally realized what was going on. It’s another good example of how the most subtle errors can be the most annoying ones.

I submitted my pull request, and it was merged. However, I was informed that I had forgotten to make a separate branch for the issue and that I need to remember that for next time. I’ll have to be more careful of that in the future.

Conclusion

Good learning experience.

Also, don’t code while half asleep.

Until next time

by TJ LeBlanc at Mon Oct 26 2020 01:56:21 GMT+0000 (Coordinated Universal Time)


Nathan Pang

Release 0.2 Pull Request 3

This week, I decided to work on a HTML project that uses JavaScript and SCSS, it was basically a cute memory testing game called gundoosmean that tests if you can remember where fish appear in a grid. This is the issue that I worked on which was modifying the SCSS to work better for mobile users.

Wow. This issue was tough to work on because any method I tried to test the program didn’t work. I tried installing and using http-server from NPM, deploying to Heroku, and deploying to Netlify, all of these methods didn’t show the website correctly or didn’t even work.

I got a bit frustrated while working on this code, I couldn’t see any of the changes I was trying to make and that made it difficult to see any progress. I eventually had to submit a pull request because I believed that the code I made solved the issue, but, to my surprise that ended up solving my problem. When I made a pull request, it create a deploy preview that I could check and that was how I ended up testing the program. Although I made a lot of commits in that pull request, I eventually figured out my issues and finished the pull request to my satisfaction. This is the pull request that I submitted, I only recently submitted the request so I am waiting for it to be merged.

Incorrect Website View from Netlify and HTTP-server, using Chrome’s Device Viewer
Heroku Error\

by Nathan Pang at Mon Oct 26 2020 01:12:45 GMT+0000 (Coordinated Universal Time)


Roger Yu

Release 0.2 – Third Public PR

Yes, finally another PR completed. For this week project I decided to continue exploring rust. Eventually, after some searching I stumbled on to this project. This project is called Onefetch. It essentially shows you information about a Github repo on your computer. It makes looking at git information interesting as it tells you things such as the languages used, the authors, and commits etc. Since a picture tells a thousand words, please see below:

Onefetch original

I liked the fact this project included ASCII art in the information screen.

Now, the issue for this PR was adding the ability to colorize the text. To be more specific, the issue is found here. A picture of the request is found below:

Locations where text should be colored.

I found the issue to be straightforward but many problems started to appear as I worked more and more on the issue. The first issue was the fact I needed to change a lot of code in order to add a new ColoredString class to the output statements. I had to make sure, I didn’t change too much so that the code was still legible. Another issue, was the entrance point for the command --text-color. I was not too sure how to do this, so I decided to just convert the string in to a vector and compare the colors of each.

    fn get_color_set(text_colors: &[String]) -> TextColor {<br>        let mut custom_color: Vec<Color> = text_colors<br>            .iter()<br>            .map(|color_num| {<br>                let custom = Info::num_to_color(color_num);<br>                match custom {<br>                    Some(custom) => custom,<br>                    None => Color::White,<br>                }<br>            })<br>            .collect();<br>        if custom_color.len() < 6 {<br>            for i in 0..6 {<br>                if i < custom_color.len() {<br>                    continue;<br>                }<br>                custom_color.insert(i, Color::White);<br>            }<br>        }<br><br>        let color_set: TextColor = TextColor {<br>            title: custom_color[0],<br>            tilde: custom_color[1],<br>            underline: custom_color[2],<br>            subtitle: custom_color[3],<br>            colon: custom_color[4],<br>            info: custom_color[5],<br>        };<br>        color_set<br>    }

I am not sure if this is the best way to do it, but I guess the reviewer will let me know. And lastly, the compiling time of rust is still very annoying and tedious, especially when your making small changes and want to perfect the output of the program.

Overall, I was finally able to finish the issue.

The colored output.

I requested a PR which is found here. I think I am done with adding new features for a bit to open source projects, especially since my previous PR still needs work and I am anticipating this one will need some work too. (Time to go hunting for bugs). Overall, open source is interesting, but some issues I’ve noticed are:

  • Constant need to update project with master
  • Redoing code since they refactored their project or changed a lot
  • Reviewers are sometimes busy and can’t get back to you right away
  • Deadlines suck (for school)

I would definitely, like to work on some bigger issues, but once you add deadlines to projects and some other school tasks, it starts feeling like a job. Oh well, part of school life unfortunately. And at least I am almost done Release_0.2

Anyways, thanks for reading. And have a Happy Halloween!

by Roger Yu at Mon Oct 26 2020 00:52:10 GMT+0000 (Coordinated Universal Time)

Sunday, October 25, 2020


Matthew Stewardson

Week 6: PR#3

  Release 0.2: Pull Request #3

This time I wanted todo more with this pull request. Before I added a documentation file and the other was renaming a function throughout a program. For PR #3 I worked on a project called UMusic which is a webpage that allows users to search for music from SoundCloud and make/play playlists straight from page. 

My job was to make the website mobile responsive. This was actually quite time consuming as a lot of the previous code was not designed with mobile devices in mind. 

To start I looked over the code in each of the files to see how the maintainer setup the base of the code before. Most of the work I did was in a CSS file, but I had also implemented two function in a JS file and a single div and button in the html file.

I never really made a site mobile friendly before so this took a little bit of research to know how to get the job done. To not tamper with the original CSS styling I did most of the new CSS work in a block of code that is only used once the screens width lowers enough. 

A lot of the CSS work was trial and error to get it just right to match the style setup before, but I had reached an issue when it comes to the amount of content displayed for smaller screens. The code was originally designed to have to Divs with all the content, one floating to the left, and the other to the right, issue is there is just way to much content to display. To solve this I added a button that only appears when in mobile mode. This button switches between the playlist and searching content sections so it is more readable for the user. This was possible by creating a function to linked to the button that sets the display to "none" for certain Divs and then the CSS would make the new pages look better.

Here is the content split between two pages:



After the first PR

After my first PR was accepted the maintainer asked me to fix a bug that happen during mobile view. The bug was a div stretching down to far which was fixed with a little CSS work. I was also asked to implement a new feature to redirect to the playlist tab when selecting a song. 

Once that was done I made another PR for the maintainer to review. The maintainer came back to me to report a bug that happens while viewing on a mobile device. The bug hide some of the page content when you would select the search bar. Here's a photo: 

This problem was caused by my event listener for checking when the user goes from mobile to desktop wrongly hide some content. To fix this I reworked my checks on the screen width.

The reason I didn't notice this was because this bug could not be replicated through chromes debugger on my desktop via changing views. I had to actually use surge.sh to make a temporary page I could go to on my phone to see the bug. Once I finished fixing the new bug I pushed my changes up which GitHub automatically tied to to my current PR which was great. The maintainer accepted my PR after this point.


What did I learn?

From this weeks PR I learned how to update a desktop viewable only webpage so it could work on mobile devices. I don't typically work with CSS that often so it was nice to refresh my skills with it and learn how to detect screen width changes on the go. I tried to commit every major change I did during this PR and I used rebase from lab 5 again to organize my commit history.

I also learned how to use Surge to test my frontend work. I actually really liked how simple it was to setup and use so I plan to use this more in the future.

by Matthew Stewardson at Sun Oct 25 2020 13:11:00 GMT+0000 (Coordinated Universal Time)


Paul Sin

Pump up the Jam.

 On October 19th 2020.

   This week, I worked on a web scraper, while I was browsing on the python repositories on Github, I found this issue. Web scraping, web harvesting, or web data extraction is data scraping used for extracting data from websites, such as Google. I have used web data extraction before when I was harvesting urls for a website. The repository owner for this weeks project, was looking to purchase some weights for at home workouts during quarantine. The repository owner wanted an email sent to his personal email when the scraper found weights in his price range. You can check out the implementation of SendGrid here

    Another project I decided to work on this week was Python-Binance, this is an unofficial Python wrapper for the Binance exchange REST API v1/3. For those of you who are not familiar with Binance, Binance is a crypto currency trading platform. It allows you to buy, sell, and trade currencies. In layman's terms it is a currency exchange. With Covid-19 happening, cashless payment systems and cryptocurrencies such as Bitcoin are a trending discussion. For a project, I thought it would be interesting to automate interactions with Binance. 

    A challenging pull request I did this week was for the game Pong. While studying their code, I was able to learn about the turtle library. Turtle graphics is a popular way for introducing programming to kids. I remember learning about this pen and paper object orientated programming approach to coding when I first learned about Java. The Instructor taught us programming by asking us to draw shapes and lines, such as, the fibonacci triangle. The library was easy to use and was locally installed on my Mac-book. The Pong library closely resembled the pen and paper approach. The program had a simple set of rules that made the game easy yet entertaining. This was the first time I had ever worked on a game. The details were very important to every functionality. If one pixel is off, the entire game will be broken. The issue that I had first encountered was about the paddle not working correctly. This took some time to examine the code and identify the issue. After multiple failures, I had deciphered the problem. The paddle was one pixel ahead of the score zone, which resulted in paddle_A always hitting the ball. It took some thinking about the logic behind the score zone and paddle collision, however, after locating the problem the solution was fairly easy.

by Paul Sin at Sun Oct 25 2020 12:14:22 GMT+0000 (Coordinated Universal Time)


Nesa Bertanico

Rewriting git history

To start this lab, I made a separate branch off the master called refactoring: git checkout -b refactoring master.

I then (1) Split my existing Cleaner.java into 5 different classes: Cleaner.java, Handlers.java, HtmlHandler.java, UrlHandler.java, and JsonHandler.java. I added and committed this to my git: and git

$ git add .
$ git commit -m "Split Cleaner.java into Cleaner.java, Handlers.java, HtmlHandler.java, UrlHandler.java, and JsonHandler.java"

The next upgrade I did was to (2) Improved function naming, I removed the ‘apple’ theme so the code is more readable.

$ git add .
$ git commit -m "Improved naming function"

The last upgrade I did was to (3) reduce the duplication of code by creating functions and calling them inside multiple functions, this made my code 50% smaller.

$ git add .
$ git commit -m "reduced code duplication by creating shared function"

And now I am ready to rebase and squash by:

$ git rebase master -i

And now ready to amend the commit:

$ git commit --amend

Checking the git log to make sure we are ready to merge our work

Everything is now ready to be merged! Here’s the commit for this merge.

by Nesa Bertanico at Sun Oct 25 2020 07:53:14 GMT+0000 (Coordinated Universal Time)


Jie Yang

Hacktoberfest 2020: week 3

After completing the project telescope, I suddenly found that I didn’t know what else project I could get involve. Then, I watched the video Strategies for Finding Projects and Issues again, it gave me a lot of ideas.

Since this week I learned refactoring, I tried to use “label:"good first issue" label:hacktoberfest no:assignee language:JavaScript created:>2020-01-01 refactor” to search issues. Later, I found this issue#7, it was about refactor and modernize. However, it was blocked by another issue#5, therefore I submitted a PR for issue#5 and left a message to the maintainer, let him know that I was interested in issue#7.

Until now, I have not received the feedback from the repository owner yet, but once the issue#7 is unblocked, I want to give a try on that.

In addition, I also searched by “label:hacktoberfest no:assignee language:JavaScript test“, “label:"good first issue" label:hacktoberfest no:assignee language:Java created:>2020-01-01“. Knowing how to use advance search in github is a short-cut to find those issues that you are interested in.

by Jie Yang at Sun Oct 25 2020 04:40:44 GMT+0000 (Coordinated Universal Time)


Nathan Pang

Lab 5

We had to work on lab 5 this week which was all about using git commands to add multiple changes with one merge. I found that the instructions on the lab 5 wiki was very clear and easy to understand, I got through this lab pretty quickly and with pretty much no problems with git commands. I originally focused on making the readability better on my code, like changing variable names, the date, and the version. I thought that it would be better to make little changes at a time to get the most out of this assignment, and I did so. I then added a function to my code that reduces code duplication for the “file not found message” which was a good one to add. As mentioned earlier, I had pretty much no issues with this lab, the only thing that went wrong was me forgetting to save my changes on the “git commit –amend” fine and having to add them again, but that was it. I like these labs that focus on working with git and learning more about it by using commands. Here is the link to my GitHub merge, and I’ll add some images because I don’t think I can write this out.

Also, using git show

by Nathan Pang at Sun Oct 25 2020 03:38:44 GMT+0000 (Coordinated Universal Time)


Mintae Kim

Release 0.2 Third hectoberfest

This assignment was very challenging for me. I had to find a more complicated task than the last one, so I searched a lot of Gits and searched for the issues I could do. So the issue I found this time was to produce an algorithm. Add more algorithms #14

What did I create?

I decided to create a new Sort that relatively many people are interested in. I couldn’t make an existing Sort, so I searched Google for various sort methods, and among them, I found Tree Sort. Wikipedia explained that “A tree sort is a sort algorithm that builds a binary search tree from the elements to be sorted, and then traverses the tree (in-order) so that the elements come out in sorted order. Its typical use is sorting elements online: after each insertion, the set of elements seen so far is available in sorted order.” I read the guideline carefully and started the production by referring to the Tree-Sort produced in Python.

My code was executed successfully. And I could learn a lot about the new Sort method while proceeding with this coding. I went straight to PR my branch and asked the flag owner to PR my code. Added Tree Sort algorithms #513

What next?

Next time my final Release 0.2 task begins. But what I felt while looking for this assignment was that there was a lot I could not do. Most of the issues I don’t know much about. But I want to finish the last assignment well even if it takes a lot of time.

by Mintae Kim at Sun Oct 25 2020 03:14:52 GMT+0000 (Coordinated Universal Time)


Ekaterina Grinberg

Hacktoberfest — DPS909- 3rd PR

Hacktoberfest — DPS909- 3rd PR

Survol

This week I continued to work on Survol project. I found an issue that requested to add a badge on the extension icon. The purpose of the badge is to make it more clear whether the extension is enabled or not. The badge should display ON/OFF depending on the state of the extension on the page. I thought that this is a nice feature that I could work on and replied to the issue.

First I forked and clone the project on my local machine. Then I added the unpacked extension to the Chrome extensions so I can test my changes. I created a new branch called issue-130 and started to learn how the code is designed. I also search for the file that responsible for enabling/disabling the extension on a page. Then I searched how to add a badge to google extensions. This can be done by adding the following line of code:

chrome.browserAction.setBadgeText({text: });

I created a function that changes the text of the badge depending on the status of the extension (ON/OFF). This function is called when the state of the extension is changed. The code was placed inside popup.js file.

After testing, I created a pull request. A few days later, the owner of the repository reviewed the changes and stated that the code should be placed in a different file.

Well, here it became a little more complicated. Since I moved my code to the different file, I needed to create an event listener to the chrome.storage. chrome.storage keeps the URL of the current tab if the extension is activated. Basically, when the URL does not exist than badge should be OFF and vice versa. Here I had another problem, chrome.browserAction.setBadgeText only works in the background file. To overcome it I had to send a message to the background file every time the state of the extension changes. When the background file receives the message with state request then it changes the badge accordingly.

Ok now everything works, but I got into another issue. When I opened multiple tabs and changed the state of the extension then the state was changed in all of the tabs. So I found the following solution: when the message is received in the background it also gets the sender info. Sender info includes information as sender tab id. Then I use this tab id for setting the badge. Now the badge is working independently in different tabs.

chrome.browserAction.setBadgeText({
text: state,
tabId: sender.tab.id
});

I tested the code and now everything was working as needed. I pushed the changes and replied to the pull request explaining all the changes I have done. The owner merged my pull request a few days later. Hooray!:)

by Ekaterina Grinberg at Sun Oct 25 2020 00:48:22 GMT+0000 (Coordinated Universal Time)

Saturday, October 24, 2020


Pedro Fonseca

NO ANSWER

For my third PR, I decided to learn the surface of Docker by creating Docker files.
So I found one issue asking for a Docker file with some instructions.

I created the Docker file and submitted my PR, but I haven’t received an answer so far.

CONCLUSION:

Research more about the repo before filling an Issue.

by Pedro Fonseca at Sat Oct 24 2020 23:23:50 GMT+0000 (Coordinated Universal Time)

REFACTORING URLPILGRIM

BEFORE THE BEGINING

URLpilgrim needed a significant refactoring.
In the last one, I had changed the flow of the program and its folder structure. The program becomes faster; this speed causes some issues that I will address in the future. But if you are using the published npm version, you are okay because of tests’ reliability.

REFACTOR(OCTOBER 23, 2020)

In this refactoring, I polish the functions and removed repeated codes.
The code is more readable and has more maintainability. I want to explain a little more about these factors.

I have been in contact with the Open Source community, which means I have read much code from different coders, languages and projects, and these are my main focus on today’s post:

1) You start to notice the difference between a “coder-friendly code” and a code that is not so readable or not so friendly. Then you begin to improve your coding style. After all, we are a community, and our primary language is our code.

2) The importance of keeping the documentation updated.

3) The importance of maintaining our projects so that if someone wants to contribute or expand our projects in another direction; They can do it in the smooth way possible.

So let’s follow the good practices.

Thanks.
Pedro

by Pedro Fonseca at Sat Oct 24 2020 04:18:33 GMT+0000 (Coordinated Universal Time)


Abu Zayed Kazi

DragonFruit.Six – Rainbow 6 Seige API

DragonFruit.Six is a C# application that returns profile data of players who are playing Rainbow 6 Siege. According to the difficulty rank, I was not sure if this project is the second or the third most difficult project compared to the first project. Yet I have learned a few new things in C# and in this blog I will talk about my experience with contributing to DragonFruit.Six application.

Over the last few weeks, I have looked at a lot of C# code. Especially with hacktoberfest happening, there are a lot of amazing developers creating interesting projects. So I haven’t given up working on C# as yet. As long as you don’t fail me, I am ready to “commit”.

When I saw the first issue which is tagged “good first issue” and it wants me to work with switch cases, I immediately jumped into work on this issue. The method was creating an array of object type RankContainer and my job was to convert that into a lookup function; preferably using switch statements. Only after opening the project that I realize it yet another game project, which is going to be hard to test especially when I don’t have the game to test it with. But that was the least of my problems. I asked for more information on the issue and they told me to use the switch arm technique. Basically, the switch arm uses the arrow function (=>) and the switch argument could be more than just an int. This is the first time I am looking at a syntax like this and the owner of the repo wanted me to implement this syntax. I was worried the owner might turn around and say “Let’s give it to someone who is more experienced”, and I would have been okay with that. I was wrong. He was very understanding. We chatted in Discord and he seemed nice about the fact I am a beginner in C#. That was the motivation I needed to continue working. I researched switch arm, write my changes and pushed my commit. I approached it in a way to use a big function that was doing two things instead of having to create two functions. The function was too complex to maintain later on if the code was to refactor sometime in the future. What the task was looking for was something similar to this kind of syntax

Once I knew what he was looking for I made the changes and created a PR, which was then approved.

The owner liked what I did and asked me to work on a small enhancement issue. Well, why not. The more PRs the better. At this point, I am a little familiar with the code so I knew what he was asking for; so I thought. This issue is looking to add either one of the two lookup functions I created into a backing field. As usual, I don’t know what a backing field is so I look at the links he shared and sure enough, I know what to do. Or do I? The owner also wants me to use the null-coalescing assignment operator(??=).

Hear we go again stumbling upon a new concept that I need to understand before implementing it. As programmers we will come across new terms and syntaxes we have never used before; how well and fast we understand the concept will determine our success as developers. The ??= basically checks the left-hand side of the operation to see if it returns null; if it does then everything on the right is assigned to the left. Having understand that I pushed my first commit for this issue. I was doing a lot which wasn’t acceptable. Remember we talked about backing-field earlier? Well its basically a private variable/object. I had to find a way to assign the RankContainer value to the backing field. The class I was working on is similar to a design model class, I never though of using a public field to set values to a private field in a design model class. Sure enough, that was the commit which was approved.

So far everything looks great so the owner is back with a third and last issue. Basically, to cleanup the code that I have written so far. I thought there was some twist to this issue since I had to change the data types from an uint(unsigned-int) to int. No twists, no surprises. I made pushed one commit for this issue and it was approved.

To sum up, it was a great experience. What makes this my third PR and not the UtilityBelt project is because of the effort I put on this project. I learned the switch arm syntax, the ??= syntax and also what a backing field really is. Yes, Web APIs are more complex than I what I did here. In contract, our third PR should be hard than the previous ones. This was harder for me because it pushed me to go out of my comfort zone to communicate with a stranger, learn and implement new things on the spot. For which I was awarded…

…as a Recognized Contributor to the DragonFruit.Six API project by the owner

Thank you for taking the time to read my blog posts. I hope they are giving you an idea of my journey with C# this semester. In my next blog I will talk about my Hacktoberfest achievement.

Whoever is reading my blogs, I wish you good health and stay safe.

by Abu Zayed Kazi at Sat Oct 24 2020 23:20:52 GMT+0000 (Coordinated Universal Time)

Lab 5 – git rebase

OSD600 has taught me a lot about git in the past few weeks. Every week we learn something new that will help us manage our contribution to other projects. This week we learned about git rebase and how to use a useful feature when making commits. This blog will talk about the these git features I used while refactoring my code

My first commit removed the state variables that were returning a count of good, bad and unknown links and created methods for each of them at the end of check link check. My second commit shortened the HttpClient object by stating the timespan (when checking a link’s status code) during initialization so that we can two things in one step. My third commit simply replaced a ternary operator with a null coalescing operator (??). This operator basically assesses the left-side of the operand to check if it’s null, if it is then everything on the right-hand side is declared to the left-hand side of the operation. Finally, I created a new function in my last commit that parses through every link in displays it in the console.

Now that I have all these commits I realize that anyone reading these commits would be confused as to what’s happening here. I could have just made all of the changes into one commit. Introducing git rebase -i, which basically provides a way for us to handle our commits.

Interactive rebase shows all my commits and their messages

What I would like to do here is pack all my commits into one commit so that anyone who is reading git log doesn’t see a dozen commits by one person in a day. Just like how ‘pick’ chooses to keep the commit, ‘squash’ will take that commit and compress it to the above commit.

Three commits ‘squash’-ed into the ‘pick’-ed commit

The above interactive rebase basically shows us how we can compress the selected commits into one commit. Once I save this change I am prompt to either delete my previous commits or keep my current commits.

Here I can see the commit messages of the number of commits I have made

Since I only need the first commit I delete the rest and save the changes.

Oops.. what does that commit message mean?

Oh no, I just realized that the first commit message doesn’t make sense now that I have squashed all the commits into the first commit. Thankfully, I can use git commit --amend which allows me to go into an interactive git and change my commit message. What a save, thank you --amend.

Now my commit message makes sense

If you notice, the commit hash doesn’t stay the same. The commit hashes changed when I combined and commits, and they changed again when I amended the commit to rework the message. Every time a change is made that may potentially compromise the integrity of the data that the commit promises, the new change will always have a different commit. So, is it safe to believe that the previous commit disappears? Maybe I will research about that and write that out in my next blog.

Thank you for reading my blog on git rebase and git commit.

Stay safe and stay healthy.

by Abu Zayed Kazi at Sat Oct 24 2020 04:18:53 GMT+0000 (Coordinated Universal Time)


Ekaterina Grinberg

Lab 5 -DPS909

Code Refactoring

This week we practised code refactoring.

First I created a new branch called refactoring in order to make all the changes there so it won't affect the master branch.

In my code, I found that some variables needed to be renamed to make the code more clear. In addition, I removed the commented lines that were not necessary. This made the code more readable and clear. Finally, I moved the code that relates to the custom output to its own file. This makes the code more organized which helps to navigate more easily through the code.

After committing each change in a separate commit, I used the Interactive Git Rebase to squash all of my refactorings commits into a single commit. Then I renamed the commit and listed all the changes that were done in this commit.

Overall I didn't face any issues during this lab. However, the refactoring experience was new to me and I will definitely use it in the future.

by Ekaterina Grinberg at Sat Oct 24 2020 22:23:06 GMT+0000 (Coordinated Universal Time)


Plamen Velkov

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

by Plamen Velkov at Sat Oct 24 2020 21:40:03 GMT+0000 (Coordinated Universal Time)


Junyong Liu

My third pull request for Hacktoberfest

Picking the Issue

Since I never deal with bugs for my first and second pull request, I decided to find a bug issue to work for my third pull request. The funny thing is that I just noticed that one of the contributors of my second PR's project issue-collab listed a bug about "Page not reloading after clicking next on pagination". The owner of the repo wants someone to share a video/gif about the issue because he not really clear what the bug exactly is. I tried and uploaded the gif of the bug. 



Then the owner reproduced it as following:
  • Click Find Issues
  • Scroll to bottom of page and click Next page
  • Click Find Issues again (observe it doesn't work)
  • Click Find Issues a second time (observe it loads the first page)
I asked him assigned the issue to me and he did it immediately.

Practice the git commands

I checked the requirement of release 0.2, and I am able to work on at least 3 different repos for my PR. That means I can work on this repo twice plus 2 more different repo.

Because I worked on the same repo I did for my second PR, I had the fork to this repo already and I am out of date to the upstream too. I add the upstream repo to my remote and fetched it.


 

Then I did the fast-forward merge using "git merge upstream/master".

Finding the bug 

Before I actually found where is the bug, I never know how easy or how complicated the solution can be.  Fortunately, the solution of this bug is much easier than I expect, but it still took quite a while to find the fix the code.

apparently, the bug something related to the page number. It is either the findIssue() function did not reset the page, or the nextPage() function made something wrong. Firstly, I always try to console.log some data out to see the data change in each state. 

    const preFetchState = {
      isEmpty: true,
      isFetching: true,
      isButtonLocked: true,
    };
    if (shouldResetPageNum) {
      preFetchState.pageNum = 1;
    }
    this.setState(preFetchState);
    
    const finalUrl = this.createUrl();
    console.log(preFetchState);
    console.log(finalUrl)
    await fetch(finalUrl)

when I console the preFetchState and the finalUrl, I found the page number in each of them is different when clicking findIusse() on the second page.

App.jsx:98 {isEmpty: true, isFetching: true, isButtonLocked: true, pageNum: 1}
App.jsx:99 https://api.github.com/search/issues?q=type:issue+label:react+state:open&sort=created&order=desc&per_page=20&page=2

 I checked the createUrl() function, but there seems nothing wrong there. I also stupidly change the preFetchState directly to setState, but also not work. After I check a few other functions, I suddenly realized that that might be the same problem I had that which my ignored feather sometimes works, and sometimes not work --- asynchronous problem. I  googled online "is the setState asynchronous or synchronous", and it turns out that my guess is right -- setState is an asynchronous function!

fix the bug 

As I said before, the solution of this bug is much easier than I expect after I found out what cause the bug -- setState is an asynchronous function, it called createUrl() before it actually changes the value of this.states. I just easily fix this bug by adding the keyword await in front of "this.setState(preFetchState)". I sent the PR of this one line change, and the owner gladly accepts it.


Links


by Junyong Liu at Sat Oct 24 2020 18:31:00 GMT+0000 (Coordinated Universal Time)


Joel Azwar

Git : Rebasing Refactoring Amending

As if I still don't know everything about git. This week learn about rebasing and amending, rewriting git history as the prof described it. So let's say you're writing a word document and you're in the editing phase. You violently mash Ctrl+S every time you make a small fix. Adding punctuation, deleting a word, making a new line, you save again and again and again. Now imagine if you had a log for every time you save that file, like a git commit. Now that's a lot of entries, and we as coders do this with git commiting as well, but with git saving and tracking each one of those commits, our logs get a bit convoluted and messy. That's why git rebasing and amending is here to save the day.

So for this week's lab our prof wanted us to practice these new git concepts by polishing our code and git commiting to our hearts content, since we will be rebasing in the end. So I made my changes and made a couple of commits to the code. Once I was satisfied with the changes it was time to do a interactive rebase. P.S. I keep forgetting to screenshot actual progress of these labs so don't mind the throwaway branch and commits for the sake of visual examples.


Interactive Rebase
Amend
  
The interactive rebase is quite a useful way to edit your past commits with a lot of options and functionalities, the generated git file you interact with is quite a neat tool. For the lab, we were instructed to pick our first commit and squash the rest, which basically means that all the commits will be merged into one. After that amending it to edit the name to indicate the 3 commits in a better format. After that the branch is ready to be merged with the master.





I wish I knew about this feature even a week earlier, my last PR to a repo was filled with 3 commits since I keep finding small discrepancies that I make a new commit for, to the point that I just stopped making edits to not clog up the commit for the PR. Anyways, I see myself git rebasing/amending a lot in the future. 

To Git-ting better at git.

Thanks for reading.

by Joel Azwar at Sat Oct 24 2020 14:20:00 GMT+0000 (Coordinated Universal Time)


Thanh Tien Phat Nguyen

Clean your code by using Git Rebase!

Introduction

As usual, my assignment this week is to keep improving my code's readability. In my previous commits, I always keeps all my functions under one entry point file. As a result, it would be such a struggle for me and other to maintain and understand my code efficiently.

What I do

Improvements

I am fully aware of the inconvenience that I would end up if I don't make any improvements. So there are some changes:

Move all functions to separate helper files
  • All functions working with URLs will be moved to an URLs helper file.
  • All functions interacting with files will be moved to an fileInteraction file.

Whenever I feel like using any of these functions above I would easily import it from the files. Therefore, my code structure would be way more organized and easier to maintain if there is any problem.

Reduce code duplication
  • All blocks of code that is used multiple times will be convert into a function. So, I can reuse them without rewriting them over again.
Squash all commits into one by using git rebase

Difficulties

  • Sometimes we will be in trouble if I forget to import the functions after separating them since all of them are tightly connected to each other. By which, I mean fileInteraction functions sometimes call URL helper functions and we have to import them properly in order to make our app run smoothly.

Conclusion

Knowing what to do to enhance your code performance could give you chill. However, I know so clearly that my work is still flawed and I am more than welcome if any one can suggest any improvements I could make. You could check my latest commit at c22a005.

by Thanh Tien Phat Nguyen at Sat Oct 24 2020 07:37:26 GMT+0000 (Coordinated Universal Time)


Chris Pinkney

Release 0.2.3 or, Pivoting- by a beautiful little fool

My life is the great Canadian tragedy.

You see, in my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. Whenever you feel like criticizing anyone, he told me, just remember that all the people in this world haven't had to start working on front end testing with Gatsby only to be told three days before a due date that we're switching to Next.JS, thus pausing all progress made... GASPby!

For the last week I've been slowly but surely researching tech like React/Gatsby, Jest & Enzyme, and the React Testing Library in preparation to make my modest contribution of some front end tests for Seneca College's Telescope project. Telescope is made by students from my OSD600 class, as lead by our benevolent dictator for life, the one and only Humph. This small contribution is part of my month long assignment (see: Hacktoberfest) to make four pull requests to any open source project. This was to be the third. And yet, it was not meant to be. At least for now.

I, however, did thoroughly enjoy the time I spent researching, talking, and joking around with Calvin, Josue, and my partner in crime with this act; Tony. But it did leave me in a bind. Enter, plan B.

About 8 or 9 days ago I noticed a post on reddit's /r/firefox titled: A dictionary extension better than Google's and on both Firefox and Chrome. I'm always down to try new toys so I looked into it. Turns out it's open source, written in Coffeescript, a language I've been interested in for a few years now. Neat! Why would I not want to play around with it? What else am I going to do? Grow cumin? It's actually pretty slick and well made, if anyone is looking for a good dictionary extension or has an interest in learning a new language I highly recommend it.

So naturally I thought to add a Klingon translation. Shut up, it's not weird.

My first instinct was to search for a translator that supported Klingonese. There's actually a few, but none that I found had an API I could exploit. Then I found the Klingon Pocket Dictionary which had an open URL query string, great! Their database is actually open too. I thought of scraping only the translations to add a small sqlite database with a couple of functions but felt that was a bit excessive for something as silly as this, maybe one day I'll get around to it and build a small API around it for fun.

There's actually people who speak Klingon too, and have varying opinions on translators, and even services to translate things for you. Isn't that awesome? After all, why the hell not?

Anyway. Revir Yang, the project creator, has documentation on how to add dictionaries to his project. I forked it, cloned it, and researched how to properly run and build a node app, then realized his main page actually says how to at the bottom. I figured the process was different somehow because it was generating a browser extension, something of which I have no idea how it works. Turns out browser extensions are actually just made in HTML, CSS, and JavaScript. Neat eh? I had no idea, and it's only natural too I suppose. Plus CoffeeScript actually compiles to JavaScript which is even cooler. I quickly added the translation website to the API and then I just had to point Firefox to the build directory... which it didn't like for some reason, so off to Edge I went, which did like it. Go figure.

From there it was just a process of figuring out how to actually add the new dictionary to the now built extension, as just adding the API was not enough:

addExtraDict (
    {
        dictName: 'Klingon', 
        windowUrl: 'http://klingonska.org/dict/?q=', 
        css: '#searchform,#top_nav {display: none;}'
    }
)
Enter fullscreen mode Exit fullscreen mode

Once that was done everything worked as expected. You click on a word and it'll define and dictate the word in English by default, but if you right click "look up word in dictionaries" it'll give you the full list of translators available which will bring up their respective site upon click.

Finally, my last task was to add custom CSS to run upon each successive translation sent to the Klingon pocket dictionary website. Personally, I'd rather have left this step out but all the other additional dictionaries added had it, and I felt like this already small PR just wasn't enough by itself, so I decided to research how I could hide everything except the necessary details for the translation page. I searched around using Firefox's dev tools to find the element (

) I just wanted and worked around it. This was by far the longest process in the PR and made me realize how little I actually remember from my intro to web development class, though it was enough to let me google my way to victory via stack overflow.

I saved a local copy of the translation page and played around with it in VSCodium and Live Server until I was happy with the results which you can see a before and after picture of below. Also, turns out the site's HTML and CSS is obfuscated/minified so uh... thank Kahless for Prettier.

And that was about it. I submitted my PR and await his response. He seems like a cool guy, he's from Wuhan, China actually. I'm sure he has some stories to tell. I've always wanted to go to China so maybe one day.

I know this PR was considerably smaller than my previous one, but I weirdly feel like I learned more from this meager PR than I did from the previous one. I learned a little about CoffeeScript, node, browser extensions- not to mention what I looked into before hand about the front end testing.

I guess the tl;dr is I made some new friends, got in some research, had a fun nerd moment, and feel overall excited about whatever is next. We'll see.

In other news i also installed the GitHub CLI. It's awesome, and I did everything around this PR with it and Git bash. Very cool. I'm also extremely excited to start working with next.js and to see my first conference in a few days. Although I may be big n00b and will likely have nothing of significance to contribute, I am nonetheless passionate and elated to move forward.

by Chris Pinkney at Sat Oct 24 2020 04:15:41 GMT+0000 (Coordinated Universal Time)


Leon Li

Practice git rebase in Lab5

 This week we start to how to use git rebase in open source project. Git rebase is used to rewrite git history and make your project a bit of a clean-up. 

In the lab5, I will try to promote my test link project to be more concise. Fist of all, I split my index.js file into two separated files, index.js file and read-file.js file. The read-file.js file will include all of the logic to read a file. After completing the changes, I try to execute the project and it works well.



Second, I modify the code about showing the version of the project to make it more readable.

After modifying the code, I test the code well and make a commit.


Third, I change the code about showing the help information. Then, I test the code and make a commit.


After completing above steps, I use git rebase master -i command to squash everything into a single commit. Then, the three commits are combined into one commit.


I also use git commit --amend command to change the combined commit message better.


At last, I use git merge command to merge the new branch to master branch. Then, I push the commit into my GitHub repo. 




by Leon Li at Sat Oct 24 2020 03:52:00 GMT+0000 (Coordinated Universal Time)


Sanjida Afrin

Squashing Commit is FUN

Hi, beautiful people! This is my second last blog before the study week. I am genuinely looking forward to it. My soul and brain need a break though I have a tons of to-do list to finish before the break is over.

Anyway, I guess most of us already guessed what I am going to talk about today. This week I had experience working with the powerful elegant git rebase command. I absolutely LOVE it.

To know about git rebase, first I made a separate branch where I can safely play with my code. In this branch, I refactored some of my code to improve maintainability. The changes I made are little because I had no intention to break my working code.

I made a new module named “version.js” to print my version information in details. Before making it, I had two global variables in my main file, index.js. Now, in version.js, I made a function which returns the version details and exported it to use it inside index.js. By doing so, I eliminated two global variables. After testing, I added and committed the change.

Next change was a basic one. One of my variable name was jsonObj which is very very bad and ambiguous. Even when I read it now, my reaction was “What was I thinking then?” I changed the name to a meaningful name which is now UrlDetails, a JSON object, that contains URL and status. Making any change requires to check where else I need to update the change. I checked and updated any place I used this variable. This ends my second add and commit.

Last one is similar to first one. My main file, index.js, is getting bigger. My goal is to break it down into smaller chunk with help of different modules. To do that, I move my another function to a separate module. I also move the library there, export and import it. Finally, I tested and made my final commit

Now the FUN PART! I typed my very first git rebase master -i command and it opened a text editor which is a new and unique things I saw git to do. All my 3 commits were there. I edited it by changing “pick” to “squash” for my last 2 commits. Oddly, it was satisfying. After I was done, I saved and exited from the editor. I did git log to see the magic. And, you know what!! My 3 commits turn into a single commit. AAAAAA!! HOW!! WHAT!! WALA!!

Another command peeked through me which is git commit --amend As my 3 commits turned into a single commit, I need a meaningful message which can represent 3 commits and this command can help me do that. I tried and did git log The message looks perfect now.

Now time to merge and push my branch to the master and spread the magic on my repo. Here is my merged commit. Thankfully, I did not run into any issue. git rebase and git commit --amend spare me today! Thanks to their kindness! For today, goodnight, beautiful people! Hope you dream about squashing the commit 😂

by Sanjida Afrin at Sat Oct 24 2020 03:41:54 GMT+0000 (Coordinated Universal Time)


Isabella Liu

git rebase

how to refactoring code using git rebase

I used my repo to practice git rebase. First, I created a new branch to do the changes.

git checkout -b refactoring master
Enter fullscreen mode Exit fullscreen mode

Then I tried to find some improvement in my code. I found four improvements. After I finished each improvement:

git add .
git commit -m "message"
Enter fullscreen mode Exit fullscreen mode

When I finish all my changes. I checked my commits with git log, add all the changes are in the log.

All the magic happens next step:

git rebase master -i
Enter fullscreen mode Exit fullscreen mode

And I squash all other commits which I don't need to show on the log.

// change commit message.
git commit --ament
Enter fullscreen mode Exit fullscreen mode

merge and push

git checkout master
git merge refactoring
git push origin master
Enter fullscreen mode Exit fullscreen mode

by Isabella Liu at Sat Oct 24 2020 03:32:13 GMT+0000 (Coordinated Universal Time)


Mintae Kim

Lab5. Refactoring

In this Lab, I need to make my tool’s code simple and readable. I needed to understand code refactoring and had to create a new Branch to modify the code. I had to modify a total of three codes and merge them into Master Branch at once.

What did I modify?

I first checked the variable names of the code. Corrected the confusing part of the variable name and executed the first commit. Secondly, I looked too complicated because my code was made up of one file. So I divided the main files and functions into a group of files. Of course, after that, I had to make the program run. Finally, I wanted to make the duplicate code simple. So I combined the function to print the result value of the function that gets the status code into one and made it print out.

I had to make all the commits one after another and then commit to Master Branch.

https://github.com/sonechca/Dead_Link_Checker/commit/855f65368aad3863571a1e168d2852cf0bd9282e

Having Problem

I followed the professor’s teaching materials but made one big mistake. I didn’t designate a commit that combines the three commit into one. I used the visual studio code to proceed, but I clicked the wrong button. I didn’t know that I had created a new commit, so I pushed it to the master Branch.

The first refactoring commit I made became the name of this whole commit. But there was no big problem with my code modification. And I think it will be very good to add or modify the code next time because it is very readable. I was able to correct what I thought wrong through this rap. When I changed the code, I was just going to change it from the master Branch, but using this refactoring makes it easier to modify the code. Because if there is a problem with the code, I can go back to the original Master Branch.

by Mintae Kim at Sat Oct 24 2020 03:18:18 GMT+0000 (Coordinated Universal Time)


Philip Golovin

Squashing Commits

In Lab 5 we are tasked with refactoring our code and committing our changes to a new branch and then squashing the commits with a rebase and amending commit comments to reflect our changes. It goes a little something like this:

First I created a new branch called refactoring based off master and began refactoring code. I ended up extracting a piece of code which ignored urls and turned it into a function which returns and array rather than modify an existing one. I then took all the functions, structs and global flag variables and put them into a utils (utilities) folder as I took a scripting approach by shoving all the logic into a single file, cause you know.. why not? Anyway, every change I made I would commit them to my local repository and when the refactoring was complete I was ready to squash my commits and push it to github.

First I ran git rebase master -i whilst on the refactoring branch and was provided with a menu that allowed me to ‘pick’ and ‘squash’ commits. The first commit is mandatory to be picked so I let that option alone and ‘squashed’ the rest of my commits. Now all my commits are squashed into a single commit but my commit message is misleading so I run git commit -amend and am treated to another menu where I can change my commit messages, so I changed the first commit message (the commit I squashed my other changes into) to something more clear.

I checked my git log to see the changes made and saw all my commits and what it was squashed into and was able to checkout back to master and merge it with refactoring and push it to the master repo.

Once pushed my final git log looked something like this:

Maybe I should clean up my PRs with this newly found power…

by Philip Golovin at Sat Oct 24 2020 03:10:55 GMT+0000 (Coordinated Universal Time)


Jennifer Croft

OSD600 - Lab 5 Refactoring and Rebasing??

This week we learned in Seneca OSD600 about refactoring and rebasing.
Lab 5 required us to view our Release 0.1 code thoroughly. Clean it up by removing unnecessary comments, improve proper naming and just making it better without changing the outcome.

I thought it was more complex then it really was. So there I was staring at my code trying to figure out what to change. My friend told me I should change all the "let" and "var" to const. He also said I should make sure I have proper naming. I had learned from some awesome professors at Seneca to use proper naming and use good coding practices to make it more readable. This was a problem!

I didn't know what to do because I had proper naming and no global variables. Luckily I did have some minor things I could do.

    1. Remove unused const colors = require('colors');
    2. Remove some comments // 
    3. Remove unnecessary bloat console.log(process.argv) 
Enter fullscreen mode Exit fullscreen mode

As began to take my steps in the process, I had an internal thought that I was wasting my time with learning these tedious steps. After each change, I commit with a comment. Then I had to do the rebase. I was worried about messing this one up. I honestly found this experience weird. I amended the commit, merged the refactoring and pushed to the master.

To my surprise, I finally understood the necessity and simplicity of not only refactoring but rebasing. I'm glad I learned these steps and will definitely seek the opportunity to do this again.

by Jennifer Croft at Sat Oct 24 2020 01:39:15 GMT+0000 (Coordinated Universal Time)


Matthew Ross

All Your (Re)Base Are Belong To Us - Lab 5

 This lesson couldn't have come at a better time!

While putting the finishing touches on one of my PRs for Hacktoberfest earlier this week, I ran into some issues with having numerous commits, and all around making a mess of the place. So eventually, it was suggested that I tackle squashing my commits into one. After a bit of research, I felt I was ready to tackle this feat (mistake #1). With this newfound knowledge, I dove head-first in this new task, thinking that I was properly prepared (mistake #2). I was able to get the problem solved, but not before causing more harm than good.

Now that I have been able to take a step back and see the fault of my ways, the second attempt at rebasing went smoother. My main mistake seemed to be pushing to the branch first, and trying to rebase after. Maybe this strategy will work if I get more comfortable with the technique, but by the time I finished this lab, I knew that rebasing AND THEN pushing to the necessary branch was the proper order to avoid that trouble all together.

As for the improvements I made to my link checker, I was able to find 3 things to work on:

  1. Removing some unneeded lines of code that were in the program.
  2. Implementing shorter options for arguments.
  3. Fixing a bug that had crept into the feature to save the processed links to a text file.
When searching my code, the first thing I did was go through and see if there was anything that I needed to simplify/shorten. During this search, I did a scan on the regular expression variable that I had globally initialized. Knowing that it would be better if it were located within whichever function it was being utilized in, I set off to find where I had used it. In the end, I discovered that, along the way, I had replaced it with BeautifulSoup for my HTML parsing. With that discovery, I removed the declaration of the regex, and ran some tests to ensure I didn't miss something.

My next step was to introduce shortcuts for arguments. While the current options worked well, since they were verbose, it was inconvenient to type them out. To fix this, I included an additional option for users to use a shorthand version of each option. During this process, however, I found that I needed to update some naming conventions so that they aligned with the options I was planning on using. The main culprit was my '--parse_url' option along with my '--unknown' link filter option. Since they both required the letter 'u' for their shorthand to make sense, I instead altered '--parse_url' to read '--parse_link'. Since I made that change, I then proceeded to look through my naming conventions and ensure that the rest of the program matched the change I just made in terms of naming.

My final alteration came as I was testing my new options. When I reached trying to use the '--save_file' option, there was an error that occurred when a message was returned to my main function. It turns out that the data being returned when the links timed out (a string) didn't match the data being returned when a link was successfully inspected (an array). Due to this, the data being written to the file had the chance to fail due to the code that was expected. To fix this, I introduced a second piece of data to return (a dummy status code) so that both pathways worked seamlessly.

I'm happy that this lab came during this time, since it happened to fall into when I was also trying to delve out on my own to solve my own rebase. It allowed me to work through the issue on my own first, learn from my mishaps, and then sit down and work my way through it in a more controlled environment, where I was able to reflect on the things I approached the wrong way, and see the error of my ways.

Anyways, it's time for me to get back to my next PR for Hacktoberfest. I'll get another post out soon!

by Matthew Ross at Sat Oct 24 2020 01:18:43 GMT+0000 (Coordinated Universal Time)


Hyunji Lee

Hacktoberfest: Third Pull Request - FindMeBeer

In this post, I will describe the steps of my third contribution to the Hacktoberfest. At this time, I tried to find the open-source which used the web programming language. The one I picked up is the project named FindMeBeer with the React (Javascript, CSS, and HTML). This website takes a location from the user and returns a list of nearby breweries and their relevant information. It uses the Open Brewery DB API. The issue I got assigned is issue #17: Add link to repository which. The owner of the repository wanted to add a GitHub logo on the right side of the navbar so when users click the image, they can visit the FindMeBeer GitHub repository.


To resolve the issue, I downloaded the GitHub logo from the GitHub website (https://github.com/logos). I put this image inside the folder the file created. When I added the image next to the title already existed, it does not seem good. Therefore, I added styles to the image so the image can be located on the right side of the navbar. I applied styles such as absolute and right to the <a> component. I tried to follow the coding style of the author so I put the styles on the file named 'index.js' instead of creating another file named 'Header.css'. After I've done all the works, I created a pull request to the repository.


I've learned how to find the code I want to edit and the knowledge of the React frontend. It was an interesting journey. I got the confidence I can do it better next time.


The links of the project, issue, and the pull request are the following:

by Hyunji Lee at Sat Oct 24 2020 01:17:00 GMT+0000 (Coordinated Universal Time)


Muskan Shinh

Lab 5

Rewriting (Git) History

The goal of this lab was to clean up our project- Urltester, by refactoring the code. That is, refactor the code so that it’s easier to read, maintain and modular. This involved three steps:

Creating a refactoring branch

git checkout -b refactoring master

This command made an isolated refactoring branch. I made the following changes to my code, and after each change I committed it with an appropriate message.

  • Removed variable ignore that wasn’t being used
  • Moved the styling that was used to display the version and tool name to a separate file style.js
  • Renamed a function that printed coloured output to console from coloredOutput to printColoredOutput
  • Renamed function that displays manual from messageOne to printManual
  • Fixed indent and use of whitespace for consistency
  • Renamed function that ignored urls provided to it from ignoreFilter to ignoreUrlsFilter

After doing this when I ran the command git rebase master -i

This opened an editor where I squashed the last 5 commits (squash) into the first (pick) and saved the file. I had to tackle with merge conflicts but I had already learnt how to deal with them so it wasn’t too hard for me. And then I did

  • git commit --amend
  • git checkout master
  • git merge refactoring
  • git push origin master

Now, when I went to remote git repo online, I saw the following commit message for the commits I had done which was not how it was supposed to look.

The actual ‘clean up’

Now, I had to do something. This wasn’t how it was supposed to look. I panicked and contacted my professor on Slack, showed him this picture and he said you can solve this using git commit --amend

So, I ran the command – git commit --amend and the editor opened

I had the video posted by my professor on the side, and I realized I hadn’t done this properly the last time and that is why my commit message was messed up. So, I did it right this time and force pushed it to origin

git push origin master -f

I looked up origin master again and I saw I forgot to edit the last line ‘Refactoring index.js to improve code maintability’

So, I did the above steps again – changed the commit message and force pushed the changes to origin master and I could see the desired result…

by Muskan Shinh at Sat Oct 24 2020 00:41:16 GMT+0000 (Coordinated Universal Time)

Friday, October 23, 2020


Michael Brackett

Release 2.0 PR 3

For this pr I found a pretty cool tool that squashs a bunch of json files into 1 json file. I thought it would be cool to work on since in our lab we are learning about rebasing and squashing. Now you may think, "The squash and rebase tool has nothing to do with merging json files", and you'd be 100% correct and their is no connection other then the name...

Nevertheless, the issue that I worked on was: https://github.com/Blank1611/jsonmergeutils/issues/1

I thought it was going to be a fairly good issue to work on seeing that I have previously implemented an argument parser in my link-check project. And while the code was fairly easy to implement I ran across something that was very important during this issue...

It was a linter, something that goes through your code and makes sure it has the same programming style as the owner set it as. I've never encountered a linter previously and while it is a little annoying to see my builds fail because I have a space after a function definition, I can see that it is incredibly useful.

Another thing about this pull request is I actually got my first suggestions to fix with my pull request! This was very exciting and the owner of the repo had some incredibly ideas to implement that would clean up the code and make it a lot better. You can check out our conversation here: https://github.com/Blank1611/jsonmergeutils/pull/14

That's the beauty of open source programming, others can look at your code and ask for improvements. While some people may take this as a bad thing, the reason why they ask for better is 1. They obviously want the code to be better, and 2. It gives you the opportunity to learn even more. It was surprisingly fun to implement the suggestions that were made.

by Michael Brackett at Fri Oct 23 2020 23:18:24 GMT+0000 (Coordinated Universal Time)

OSD-Lab5

This week I was tasked with refactoring some code, committing it, then rebasing and squashing.

Obviously, I did this to my ever-upgrading linkcheck program where you can find at: https://github.com/MLJBrackett/link-check

In general this lab was pretty easy for me and I had no issues, reason being is I tried very hard when I first created the program to keep the code very clean and small so that maintainability would be easy in the future. But as always, we miss a couple of things here and there. For instance, in this Lab I removed some global variables, removed unused variables and removed a string concatenation between my output strings. While the string concatenation was not needed and my code worked fine with it, it seemed like this was a much better way to implement the change and give a layer of separation between me changing the colour of the output and printing the string afterwards.

You can find my rebased and squashed commit here: https://github.com/MLJBrackett/link-check/commit/bee1842b6de4228ad85b2b32b64292520acde8d1

It was a funny lab because I literally just was researching about rebasing and squashing for my lab 4. You can find more about my experience researching about it at: https://dev.to/mljbrackett/osd-lab4-35l0

by Michael Brackett at Fri Oct 23 2020 22:11:26 GMT+0000 (Coordinated Universal Time)


Abdul Abdi

Second Hacktoberfest PR - Making Some Improvements

My Issue/Addition

      As I was searching for a new project/repo to contribute too, I just couldnt get over the feeling that my last PR was not complete to my satisfaction and I needed to make some changes to it before I could feel like I was done with it. I decided to create another issue on the repo to address these improvements


Creating the Script/Making a Pull Request

    I started out by researching the most popular online pc games and finding the servers that are used for most major regions. In my initial script, I was thinking on a more personal level and included only games that I play and that would really limit the usefulness of the script. Once I found as many games as I could, I added their information to the json file I had created to hold the game server information. I then had to modify the script code to accommodate these new games. Afterwards I updated the readme documentation to include the new functionality and made my pull request

Review Process

    The review process this time was more streamlined as I was already familiar with linting and flake8 and how this repo went about approving pull requests. 

Final Thoughts

This experience definitely taught me that you are never really done with a project and you can always continue to improve it. I will continue to keep this script in the back of my mind but now I am ready to move onto to something new and continue to gain more experience. 

by Abdul Abdi at Fri Oct 23 2020 23:11:00 GMT+0000 (Coordinated Universal Time)

First Hacktoberfest Pull Request - Release 0.1

 Introduction

    The idea of working on and contributing to an open source was something that caused me a lot of anxiety, seeing how large and in depth most of the repos I was looking at made me feel like I would be of little help or have very little to offer. As this stress kept building I defaulted to procrastinating and avoiding having to find a repo to contribute to. Finally, I decided that I would just need to jump in and begin to build my confidence if I wanted any hope of becoming a better programmer or succeeding in this class. I thought for my first pull request it would be easier to work in a language I was already working on for my release 0.1 and ended up finding a repo that was centered around curating python scripts. So I thought I would try contributing my own script to this repo. 

My Issue/Addition
    
    I was playing an online game one night ( league of legends) and I had got into a game and noticed that my latency was very erratic and needless to say that ruined my experience in the game as it was hard to play with the lag. I had been thinking about what kind of script to make for my pull request and that experience made me think it would be useful if a script existed where you can quickly check your average ping to a gaming server before you got into a game. So I created this issue in the repo and hoped it would be accepted. 

Creating the Script/Making a Pull Request

    I started out by researching the best way to check for latency from a desktop and found out that there was a command line command that would accomplish just that. Then I did some research on how to call a command line command within a python script and found that for my specific usage the subprocess package would be the best course of action. From there I needed to figure out a way to organize the games I wanted to include and store them in a way that would make them easily accessible within in the script and also allow for games to be added easily. I ended up deciding that storing the game and server information in a separate json file that the script would read would be the best course of action. Finally, I put it all together in a CLI which I was able to do by repurposing some of the code I had written for release 0.1. I created a pull request from the branch I created to work on this addition and awaited approval and review. 

Review Process

    The review process on this repo introduced me to a new automated process I had never used before. It was called linting and the repo recommended a package called flake8 to do this. Flake8 ran analysis on my code and flagged any potential errors or stylistic errors and that allowed me to fix any mistakes I had made. This was something that was great because now I have a tool that can use to allows make sure my code is cleanly styled as well as help to stay mindful of it will I am coding. After I passed all the lint check, an admin of the repo successfully merged my pull request. 

Final Thoughts

This experience definitely helped me to see that making pull requests and contributing to open source projects isnt as scary as I thought but I definitely now would like to move on to contributing to a more major project and engage in a review process that involved more scrutiny and feedback so I can continue to grow as a coder and contributor.  


by Abdul Abdi at Fri Oct 23 2020 10:08:00 GMT+0000 (Coordinated Universal Time)


Mohammed Ahmed

Release 0.2, Depreciation for Days

My second PR that I’ve found was a simple fix. It wasn’t too demanding, and was pretty easy to test.

Good ol’ Python tends to depreciate certain functions and or libraries whenever it gets an update. In our case, Python depreciated fractions.gcd() since Python 3.5; it was left for backwards compatibility, but as of 3.9, they’ve officially removed the function from “Fractions” and added it into “math”.

The documentation that says officially removed

I was browsing through GitHub’s “explore” tab, and found a really cool Repo that deals with Artificial Intelligence. I was looking at the code, and I noticed they’re using fractions.gcd() instead of math.gcd(), so I just made a quick change.

My Changes

All I did was add a try-except statement for my code, and it seems to work great.

My changes

Release 0.2 is going well! Now off to contribute more code! Weeeeeeee!

  • Mo

by Mohammed Ahmed at Fri Oct 23 2020 18:31:23 GMT+0000 (Coordinated Universal Time)


Plamen Velkov

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

by Plamen Velkov at Fri Oct 23 2020 18:35:02 GMT+0000 (Coordinated Universal Time)


Badal Sarkar

Refactoring and Rewritting Git History

This blog is about refactoring the codes of Blink and usage of some Git commands which helps to manipulate already committed codes, more specifically git rebase and git commit --amend.

by Badal Sarkar at Fri Oct 23 2020 18:21:00 GMT+0000 (Coordinated Universal Time)

Release 0.2 Week 1

I have worked on this repository, as part of my release 0.2. This repository was for a website built with Jekyll. I worked on this issue which was to update the website by adding a link. The issue was fairly simple. However, I had to read about how the Jekyll works.

by Badal Sarkar at Fri Oct 23 2020 00:33:32 GMT+0000 (Coordinated Universal Time)


Kimin Lee

Refactoring findBreakURL to improve maintainability!

Before Start

While I am participating "2020 hacktoberfest", I realized that some of the projects on github are not really easy to get start as a new contributor for them. The reason is their codes usually written by one or two contributors and didn't really think about maintainability and let others join in the project. Most of the my projects are also done by me, so to be honest, I didn't really care about the maintainability and conventions as well. findBreakURL is also one of them. However, being a open source developer is not only improving my coding skills but also learn how to interactively work with others and effectively maintain the existing codes.

So, this week, I have decided to improve the code style of findBreakURL

What should be changed?

So far, the program has 4 different .js files.

  • fetch.js : With axios, we will do 'header fetch' to check status code
  • json.js : This file will make a json style output
  • yargs.js : This file handle the arguments and options and read directory to find files
  • index.js : This is the entry for the program, will read files and following functions

Wait, What? index.js will read files? and yargs.js read directory to find files?
This looks not so consistency and maybe a little bit irrelevant for their desired functions. Maybe we can split the functions to another files.

let's start with git checkout -b refactoring

Step 0 : Make a fileRead.js

It will be better if we extract reading a file/directory function from index.js and yargs.js and make a separate file for the change.

Step 1 : Make a fileRead() function

In index.js, fileData is extracted.

...
try {
        fileData = fs.readFileSync(`${__dirname}\\${file}`, {
            encoding: "utf-8",
        });

    // wrong file name
    } catch (error) {
        console.log(file + " is a WRONG file name");
        return process.exit(1);
    }
...
Enter fullscreen mode Exit fullscreen mode

Maybe we can make this part as a fileRead() function:

const fileRead = (file) => {
    let fileData = null;

    try {
        fileData = fs.readFileSync(`${__dirname}\\${file}`, {
            encoding: "utf-8",
        ...
    return fileData
Enter fullscreen mode Exit fullscreen mode

After change, commit this change.
git add index.js + git commit split index.js to index.js and fileRead.js

Step 2 : Make a fileDirectory() function

In the yargs.js, files are declared globally. And all conditions are not inside a function. It looks better if the variable is only used inside a function and the conditions are also in the function.

Before:

let files = [];
    if (yargs.argv._.length === 1 && yargs.argv._[0] === "start") {

      // decide the option if it is -f or -a
      if (yargs.argv.a && typeof yargs.argv.f !== "string") {
        const tmpFiles = fs.readdirSync(__dirname, { encoding: "utf-8" });

        // if -a, store all files into the files variable
        files = tmpFiles.filter((file) => {
          return file.toLowerCase().endsWith(".html");
        });

      } else if (typeof yargs.argv.f === "string") {
        files = [...yargs.argv.f.split(",")];
      } else {
        console.log(chalk.yellow("Please enter filenames or -a following -f"))
      }
      return files;
    } else {
      console.log(chalk.yellow("Wrong argument: use [start]"));
    }
Enter fullscreen mode Exit fullscreen mode

After:

const readDirectory = (yargs) => {
    let files = [];
    if (yargs.argv._.length === 1 && yargs.argv._[0] === "start") {

      ...
Enter fullscreen mode Exit fullscreen mode

Commit the changes as extract fileDirectory(), put that into fileRead.js

Step 4 : Split index.js and yargs.js

Now let's move those functions to fileRead.js:

const fs = require("fs");
const chalk = require('chalk')

const fileRead = (file) => {
    ...
}

const readDirectory = (yargs) => {
    ...
}

module.exports = { fileRead, readDirectory }
Enter fullscreen mode Exit fullscreen mode

And index.js should be used fileRead and yargs needs 'readDirectory'
index.js:

// Start testing files each
files.map((file) => {
  const fileData = fileRead(file);
...
Enter fullscreen mode Exit fullscreen mode

yargs.js :

...
const files = readDirectory(yargs);

module.exports = {
  files,
  arg: yargs.argv,
};
Enter fullscreen mode Exit fullscreen mode

Step 5 : Squash the commit and merge!

We have currently 4 changes. However, we only need the last finalized version of changes. We can do this using with git rebase master -i
It enable us to squash all the previous changes and make them a one single commit

pick 4710009 split index.js to index.js and fileRead.js
squash 0c01069 extract fileDirectory(), put that into fileRead.js
squash fd8e932 variables name changed
squash f9d85bf squash index.js and package-lock.json
Enter fullscreen mode Exit fullscreen mode

Also, we can change the commit name with git commit --ammend:

commit d740f80e8c0e2b1d4c9d50613e5812016bcf86de (HEAD -> master, origin/master, origin/HEAD, refactoring)
Author: klee214 
Date:   Fri Oct 23 12:25:19 2020 -0400

    Refactoring findBreakUrl to improve code maintainability

    *extract fileDirectory(), put that into fileRead.js

    *variables name changed

    *split index.js to fileRead.js and index.js
...
Enter fullscreen mode Exit fullscreen mode

More information

Visit and see this

by Kimin Lee at Fri Oct 23 2020 17:28:35 GMT+0000 (Coordinated Universal Time)


Zongwei Yang

Refactoring code - git rebase

To practice git rebase and Refactoring my code, I worked on my goURL repo.

I planned to do three commits with three different refactors.

  • extract functions to reuse.
  • improve variable names.
  • split the util functions to a new file utils.go

Extract functions and improving variables go smoothly. However, when I split the util functions, all my code is broken. all my imported library is still on main.go,
I checked all the libraries needed by the new file and deleted the old imports from main.go. Then, everything works.

The process of refactoring:

git checkout -b refactoring master
// refactoring 1
git add .
git commit -m "Extract functions to reuse"

// refactoring 2
git add .
git commit -m "Improve variable names"

// refactoring 3
git add .
git commit -m "split the util functions to a new file utils.go"

// git log to check the commit history
git rebase master -i
// change commits message.
git commit --amend


// merging
git checkout master
git merge refactoring
git push origin master
Enter fullscreen mode Exit fullscreen mode

git rebase is a way to clean our commit history. we also use git rebase to
update our working branch to fetch the latest commit from the remote repo.

by Zongwei Yang at Fri Oct 23 2020 15:19:41 GMT+0000 (Coordinated Universal Time)


Bing Pan

Git Rebase

I primarily focused on removing redundant codes and functions because initially when I first designed and implemented my tool, I separated the command line parsing from URL parsing by using two objects, ArgParser and LinkValidator, to handle those functionalities. There is only one static variable “MAXNUMPATHS” in my tool, which is defined in the class LinkChecker in which the main() function is located. It is used by other classes via static imports.

I believe in making atomic commits to make my development process to be easier to perform. After watching the professor’s video instruction on how to perform an interactive rebase, my actual practice is quite smooth. Of course, I did find some bugs while I was modifying my code. Since all of them happened at the level of local methods, all are easy to be fixed. However, I did run into instances previously that I had to modify multiple locations across 3 to 4 classes in order to accommodate the data type change of a method’s parameter.

Since I am using Windows Subsystem for Linux (WSL) version 2 for Windows 10, the change of my project history without running into too much trouble. Of course, I primarily relied on using Vim rather than Eclipse.

by Bing Pan at Fri Oct 23 2020 06:36:42 GMT+0000 (Coordinated Universal Time)


TJ LeBlanc

Lab 5: Code Cleanup

Hey guys, I’m back with another post.

This week’s lab focused on fixing our code via refactoring. There were some changes that I’d been planning to make to my code for a while now, so I found this to be a good opportunity for me.

The biggest issue with my code in the state it was in before I made any changes was that it had become extremely bloated. The number of lines of code in my tool had reached 150 lines, and it had become much harder for me to read over and maintain.

To cut down on lines of code, I first determined that the biggest offender was the methods used to check for ignored links. These alone were about a whopping 70 lines of code, which is almost half of the entire tool. To fix this, I decided to use the implementation I made last week for the dead_link_checker repository. After making some adjustments to it, this was the final result:

try:
with open(sys.argv[2], 'r') as f:
line = f.read()
if line[0] == "#":
comment = True
ignoredUrls = re.findall(r'https?://[^\s<>"].[^\s<>"]+', line)
if len(ignoredUrls) == 0 and comment is False:
raise FileNotFoundError;
urls = [x for x in links if x not in ignoredUrls]
checkLinks(urls)
except FileNotFoundError:
print(Fore.RED + "Error: invalid text file.")
sys.exit(2)

I managed to keep it just under 15 lines, which I pretty satisfied with. I can’t really think of anyways to cut it down any further as of now and I’m not sure if it’s even possible, but if I can I’ll update it down the road for fun.

The rest of the changes I made were fairly trivial, mostly being some function rearranging and renaming to help with readability. You can find the final commit here.

Working with refactoring didn’t end up being too difficult for me. After figuring out how everything worked based on the instructions, I managed to make my commits, rebase and squash them, then finally amend and merge with little issue. It still kind of spooks me when I see vim open up out of nowhere and ask for me to write comments since I don’t use vim very often, but I feel like I’ll get over it eventually.

Anyways, that’s all for now. I definitely feel like I’ll be making use of refactoring a lot more in the future because of how convenient it is to turn multiple commits into a single commit that you can merge and push rather than having to push every commit individually. It’s also nice to have code that’s much more readable now, which will make future changes much easier to make.

Until next time :]

by TJ LeBlanc at Fri Oct 23 2020 01:56:36 GMT+0000 (Coordinated Universal Time)


Jasper Mui

Refactoring and Rebasing Me Check Link

This week I refactored my Me Check Link, a command-line tool check for the status of links. I focused on improving my code to be more readable. I move a part of the code into a function, making my prior function half the size. I moved many of my functions into a helper file rather than having all my code in one file. Finally, I renamed some of my variables to be clearer. Overall, my code is more readable now. Surprisingly, when I refactored, my project did not break my code other than forgetting some small things, such as passing enough variables to my function and importing.

 For my commit, I also did a rebase to make the commit much cleaner. To do this, I did an interactive rebase. It was my first time doing an interactive rebase, but I did not run into any problems. Rebasing may commit nice as it shortened my project history.

Update: Ended up messing up my rebase somehow. I am not sure how I messed it up but it ended up missing my last commit. So to fix this I ended up rolling back my master branch and then squashing what should of been my third commit into my two other commit where were already rebased.

Links

Me Check Link project:
https://github.com/Jasper-Mui/me-check-links

My refactor rebase commit:
https://github.com/Jasper-Mui/me-check-links/commit/2ce67cd9bd8be3c60356cf650ae53cadf63750bf

by Jasper Mui at Fri Oct 23 2020 01:34:39 GMT+0000 (Coordinated Universal Time)

Thursday, October 22, 2020


Junyong Liu

OSD 600 Lab5


In this week's lab, we are going to refactor our code of release 0.1. Since we have learned some git history commands this week, we are going to practice the commands git rebase, git commit --amend to rewrite the history of the previews commits after the refactoring.

Refactoring my release 0.1

The first change

I rewrote the code about sending asynchronous requests. I was using sync-request dependency for sending the asynchronous request. It makes the request super slow since they were waiting for the preview request to finish. I removed the sync-request dependency and installed the request dependency, then I created my checkUrls() function that returns an array of promise(Promiss.all). 

const checkUrls = (urls, json, status) => {
    return Promise.all(
        urls.map((url) => sendRequest(url, json, status))
    );
};

The second change 

I changed my readFile() function can readFile asynchronously. I just simply make the function return a promise. In the main file, I put everything into an async function run(), then add the keyword await to readFile();

The third change

I created a class named MyFile and put all the File related functions and those properties (status, json, filter) into it.

class MyFile {

    constructor() {
        this.status = 'all';
        this.json = false;
        this.filteredUrl = null;
    }

    readFile (fileString = this.fileString, json = this.json, status = this.status, 
filteredUrl = this.filteredUrl) 

Before

            let status = "all";
            let json = false;
            let i = 3;
            let filter = null;

            if (argv.good) status = "good";
            else if (argv.bad) status = "bad";
            else if (argv.json || argv.j) json = true;
            else {
                status = "all";
                i = 2;
            }

            if (argv.u) readUrl(process.argv[3]);

            for (i; i < process.argv.length; i++) {
                await readFile(process.argv[i], json, status, filter);
            }

After    

        else {
            let myFile = new MyFile();
            let index = 3;
            if (argv.good) myFile.status = 'good';
            else if (argv.bad) myFile.status = "bad";
            else if (argv.all);
            else if (argv.json || argv.j) myFile.json = true;
            else index = 2;
            if (argv.u) myFile.readUrl(process.argv[3]);
            for (i = index; i < process.argv.length; i++) {
                await myFile.readFile(process.argv[i]);
            }




Practice git commands

firstly, i ran "git rebase -i HEAD~7" to edit my 7 previews commit, then I squashed all 2-7 commits. After
that, I practiced git commit --amend to change my commit message. Since I completely changed my
commit history, I cannot do a faster-forward push. I used "git push origin master --force" commit to
pushing my new commit to my Github

by Junyong Liu at Thu Oct 22 2020 22:47:00 GMT+0000 (Coordinated Universal Time)


Roger Yu

Lab 5 Refactoring

Hello everyone! For this week’s OSD600 labs we were tasked to refactor our program for maintainability. This was done to help us learn about git rebase, git commit –-amend and git merge. I decided to focus my refactoring improvements on variable, function, and method naming. Additionally, I tried to create new methods to limit expansive methods (e.g. methods that do too many tasks at once). To fix my code I pretended to be a new developer that was tasked with refactoring this program. This helps me understand the weakness in my naming scheme as some naming schemes were abstract or nonsensical. I also wanted to create new methods and limit the expansive methods so that the class url_checker and its methods can be reused in another program if needed.

An example of a method being broken up, so its pieces may be used elsewhere if needed.

Refactoring code is hard and finding good names to use. I think this is because, there are many ways to refactor code, and it is hard to determine what is the best way. Additionally, naming variables and methods have always been a weakness of mine. I just find it hard to find descriptive and precise words without repeating myself. I am still not 100% happy with the current naming conventions in my program but it will have to do for now. Overall, refactoring code helps you see what areas of your program you can improve.

It was also nice to learn about git rebase as when opening PRs on open source projects, I can provide a precise description of the commit instead of small undescriptive things.

Git commits on refactoring branch:

Final commit to master branch here.

by Roger Yu at Thu Oct 22 2020 20:51:12 GMT+0000 (Coordinated Universal Time)


Hyunji Lee

Lab5: Refactor the code to improve maintainability

Thanks to the people's contributions to my link-checker command-line tool named url-fi, my tool gets a huge improvement. However, it has some coding style inconsistent because my code has other people's code as well. I took some time to walk through my link-checker tool and made some refactoring.

There are five commits I add to improve my code

  • Move the global variable to the top
  • Add comments to the variables and functions
  • Rename variable name
  • Erase unnecessary code
  • Update help message

Firstly, I found some global variables named rFlag, ignore, ignoredLink was located in the middle of the file. Therefore, I move those variables on the top of the file. Secondly, I added comments to the variables and functions so other people can easily get what my code is. Thirdly, I renamed variable names ignore to iFlag to make the variable name consistent. Fourthly, I erased unnecessary code. There was code duplicate that the process.exit(1) and the process.exitCode=1 was written in a row. As the process.exit(1) already made the process.exitcode 1 and then exited the program, the process.exitCode=1 is unnecessary. Finally, I got the help message my tool display is out of date so I updated the message.

The git log after I've committed all the commits are the following.

I rebased the commits to squash those five commits into one commit and these are the images to squash them. I entered 'git rebase master -i' to squash them.

The git log after I've squashed all the commits is the following

The git log after I've amended my commit is the following: 

The merge commit URL after I've merged my refactoring branch is the following: https://github.com/hyunjiLeeTech/URL-FI/commit/e7bcb976c0a703e504a0ad15ad8e3659c4739079

I did not get any errors and conflicts to follow these steps. Also, the concept of refactoring was interesting. I felt it is powerful. Also, I did not know I can amend the commit message so the process of the rebase and the amend message was really impressive. I had confidence I can do better in the future when I need this knowledge.

by Hyunji Lee at Thu Oct 22 2020 20:23:00 GMT+0000 (Coordinated Universal Time)


Jie Yang

Git Rebase | Refactor

Code refactoring is the process of restructuring existing code to make the code cleaner, more readable, less complexity and more maintainable. There are a variety of refactoring techniques to improve the design, structure as well as implementation of the program source code.

Git rebase, my understanding is a kind of refactor for git commits, which helps to clean commits by squashing, rewording, editing and picking commits.

What I did to refactor my CmdLC project are:

  • extract a JsonPrint() function
  • extract a colorPrint() function
  • get ride of a global variable

After refactoring, my source code reduced 30 lines. Moreover, function JsonPrint() and colorPrint() could be reused in this project or other projects.

Then, I updated CmdLC.jar for users to execute directly. If I pushed these 4 commits to the master one by one, it was meaningless. Those commits were all about refactoring, so using git rebase -i to squash them into one commit would be more trackable.

Additionally, git commit --amend was used to rewrite the commit message.

Git rebase is very useful, as it often happens that I need to make another commit after a commit because of a tiny typo in .md file. I think I will use this command frequently.

by Jie Yang at Thu Oct 22 2020 19:11:34 GMT+0000 (Coordinated Universal Time)