“Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.” (Heroku)
Setting it up is quite easy, first you need to sign up for a free account:
Once you have a free account, you will need to download the Heroku Command Line Interface (CLI) here.
Sleep deprived as exams are approaching. I hate this feeling. Here I am, spending time studying instead of enjoying my bed. What can I do to ease my mind? I might be odd, but I find that coding is relaxing to me. As mentioned before, I love breaking and fixing stuff. The bug I chose (mozilla/thimble.mozilla.org#1887) doesn’t involve breaking, but it involves fixing! So let’s get started.
Fixing issue #1887
As mentioned by @pomax, if the user imports and existing file/folder, the conflicting item will be overwritten without notifying the user. The code for importing file/folder lies here.
Following the same pattern before, I chose 2 bugs that were not related to each other. Why do I keep doing this? I try not to be a picky developer. This way every bug is “new” to me and I’m able to better understand how the whole project works.
In this release, I fixed 2 old bugs (mozilla/thimble.mozilla.org#591 and mozilla/thimble.mozilla.org#889).
Fixing bug #591
As you can see, the issue with this bug is that, if a widget is open (In this case “Quick Edit” or “Quick Docs”), and the user opens it again, the widget closes and re-opens. The expected outcome should either be: “The opened widget closes” or “The widget stays open and nothing happens”. I choose the former.
In this release, I focused on 2 issues that were quite different from each other (adobe/brackets#11862 & mozilla/brackets#596). I’m always is the lookout for new things to learn, so by choosing 2 different issues, I was able to accomplish my goal and delivered 2 fixes.
Fixing this bug was really time consuming. Even though I didn’t write much code, I spent quite sometime thinking which file names are invalid and which are valid (I still don’t know if I’m right or not haha).
Here’s a scenario:
I have an important file named
file<3.txt. In Windows, this file name is invalid (Because of the char
<), but in macOS/Linux, this file name is valid! So… do I disallow
file<3.txt for every OS? Or just for Windows? Lets say I disallow it for Windows and I import a project that came from a macOS machine. If that project contained
file<3.txt, this file wont be imported. Do you see my conundrum? The user will be annoyed and clueless as to why the file is missing.
To avoid this issue, I disallowed
< in general (I’ve included other chars too).
This conundrum wasn’t even the main issue! The original issue was that users were able to “folder hop” by creating a file that contained a relative path in its name (Ex: A user created a file and named it “
../../file2.txt"). This allowed users to create files in unexpected places.
To fix this, I created a function that checked if the filename and file path where valid.
Bam! Now if the user gives a “bad” file name, Brackets will throw an error 🙂
I remember when I first installed Notepad++ on my computer. It was the best feeling in the world! It felt like I went in a time machine and jumped a few years ahead. A text editor with plugins? Colour scheme? Themes? Wow! What more can you ask for? In 2008, notepad++ changed who I was.
I never thought of using notepad++ as a development tool (I used it as a replacement for notepad). I was actually shocked and a bit annoyed (Still am) when I saw people use Notepad++ as a development tool (Use an IDE you fools!). It gets to me when someone asks for programming help and I see that they’re using Notepad++ as an IDE. Why?!?!
Putting my saltiness aside, a lot has changed since 2008. There are tons of other editors! Here are the 2 editors I’ve been using latelly and some of the best plugins for them.
Atom is an Open Source hackable text editor (As in, you can add/remove parts of it. Sort of like Legos). At this time, its free, and it has over 5,000 plugins! In the beginning I wasn’t comfortable with the layout. It felt like there’s were too many stuff on the screen. but once ignore it, Atom is actually a really nice editor.
Here are 3 cool plugins for Atom
You guessed it! It’s a colour picker! What’s cool about it is that you can change between outputs on the fly (RGB, HEX, etc). To access Color Picker, you press
C (macOS is
C). For some odd reason, those key combinations were already taken, so I had to change it to
E on my machine. It can easily be done under settings.
Because lab 7 and lab 8 are similar, I’ve decided to combine post blog posts into one.
As with any piece of code we write, a good programmer always tests before releasing (I mean, you should be haha). As your program becomes more complex, you might fix a bug and unintentionally break something else. This is where
unit testing can save you! Unit testing is a style of coding which allows you to test a specific function and check it’s output with known data. For example: I have a function that returns
true if my email is valid. I know that
firstname.lastname@example.org is a valid email, thus my function will return true. But let’s say that a few months went by and I made a modification to the function which causes
email@example.com to return false. When I execute my unit tests, I will see that my new changes broke the email function.
There are many unit test design you can use but the one I’m familiar with is JUnit. For this lab, I will be using Jest (Which I’ve never used before).
There’s a saying that goes like: “If it ain’t broke, don’t fix it“. As a programmer, I’ve changed that to: “If it ain’t broke, break it then fix it” and that’s exactly what I did. While trying to “break” Thimble, I noticed that I’m able to create/rename folder and file and give it a name which includes a relative path(Like
Choosing a bug
At the time of this writing, Thimble has 185 opened issues (so choosing a bug to fix shouldn’t be that hard). After a few minutes browsing, I decided to go with this one (since it’s one of the oldest bug and its been opened for almost 2 years now). Before I could fix the bug, I had to setup my environment. Oh man, what a nightmare! I’m sort of like a robot when following
README.md instructions (I follow them line by line and never assume anything). I found it confusing and it didn’t mention that Bramble needed to be executed with Thimble (I mean, it sort of did, but since I already had Bramble installed, I didn’t read the Bramble installation part). I correct myself, I’m a broken robot haha.
So I decided to read the Thimble source to understand what needed to be installed. After a day or so, I decided to rewrite the instructions. I was a bit worried that they might refuse it (since I’m new to the project) but everyone in the project was really friendly and helpful! After about 3 revisions, I landed my first PR. Awesome! Time to fix my bug!
Have you ever wanted to combine multiple git commits into 1? I know I have! I’m a bit embarrassed to push a piece of code to github and have 10 commit messages while I only edited 1 file. Since I work on 3 different work stations, I constantly push code to git and continue working on it from my other work station. You can imagine how ugly the commit history looks by the end of the day. Here’s an example:
The “inherits” module (written by the creator of npm, Isaac Z. Schlueter) is quite an old piece of code (First published in 2011). It has over 1 million downloads per day, and over 25 million downloads last month! One might think that a popular module like this one shouldn’t have any errors in them. Well… after looking at its package.json file, I noticed that it didn’t follow npm standards.