Blog

These 7 Tips Will Make You A Super Productive Programmer

These are some of the general programming tips I want to share with you. Some of these tips might sound trivial but they can sure help you be more productive. Here goes my 7 tips to help you become a super productive programmer.  Learn touch typing Touch typing is typing with all of your 10 fingers. Many computer users don’t know how to touch type and they use one or two fingers to type out. Even I was a two-finger typer for a long time. If you learn touch typing, you can type without looking or even in the dark. …

Read More

Notes on Jest, JavaScript Testing

Jest is from Facebook, it comes pre-installed in Create React App. It’s a good idea to install Jest globally since I will be using it from now on. Or install as a dev dependency: Run it with npm test by adding jest –watchAll in the package.json file. 3 ways to add test files: Put all the test files in __tests__ directory within the project folder Add files with .test.js Add files with .spec.js I like to add .spec.js inside each of my React component files. Each test per component stays on their component folder. For tesing general JavaScript, I will …

Read More

Notes on Algorithms 3, Insertion Sort

Insertion Sort is yet another way to sort a list in ascending order just like we did with Selection Sort last week. Similar to selection sort, it will keep comparing the current value with other items and place it when it finds a suitable position. Given an array of unsorted integers, it will divide the list in 2 sections. The sorted left array and the unsorted right array. It will take the 1th item of the array as the key (or the right index) to make the comparisons. Since we start with the only one item in the left, we …

Read More

Notes on Algorithms 2, Selection Sort

Last time I practiced the binary search algorithm and then implemented it on JavaScript. This time I learned about Selection Sort. A selection sort is a sorting algorithm that will take an array of numbers (or strings) and then sort them into ascending order. If I give an input of [1, 5, 3, 4, 2] it will output [1, 2, 3, 4, 5]. In a nutshell I start with the first item of the list. Then I check the other items one by one and see if any of the other items are lower than my first item. If I …

Read More

Binary Search Algorithm in JavaScript

Binary Search algorithm cuts the list in half to find the given item. Here I will be implementing binary search algorithm in JavaScript. Pseudo code: Create a variable min, set it to 0 Create a variable max, set it to array length – 1 Create a variable guess While min is less than or equal max, keep going Add min and max and divided them by 2; make it an integer if the target value equals the value in the index of guess, return the guessed index If the guess is higher than the target value, set max to guess …

Read More

Notes on Algorithms 1, Binary Search

Algorithms are recipes to come up with a solution. Large algorithms are actually a collection of lots of smaller algorithms. When it comes to working with lots of data, making an efficient algorithm becomes important. The study of algorithms is needed to build big systems. This could result in the saving of computer time which translates into money saved. There are bunch of popular algorithms in the computer science land. Since computers like to work with a lot of data, it makes sense to come up with better ways to sort and search all these data. Data structures and algorithms …

Read More