My learning diary

Some Git

I did not realise my pull request was between branches of the same repository. Not sure if my friend realised. I moved the feature branch’s latest updates to my fork’s feature branch. I then made another pull request. I used the following commands to straighten things out: # Create a local branch with the same name as the origin remote feature branch git checkout -b feat/simple-compound-interest-calculators # Pull in the changes from the origin remote git pull # Set the upstream to the origin remote feature branch git branch --set-upstream-to=origin/feat/simple-compound-interest-calculators feat/simple-compound-interest-calculators # Check the remotes and their URLs git remote -v # Add the remote for my fork git remote add jiayee git@github.

Continue reading "Some Git"

Constants

I thought consolidating constants was evil. Just two or three dozens of them were enough to become a huge headache for me. In Java, this practice is frowned upon. In JavaScript, it seemed alright. The answer which received the bounty recommended the following: // Warning: This answer was written in 2014. module.exports = Object.freeze({ MY_CONSTANT: 'some value', ANOTHER_CONSTANT: 'another value' }); It was my first time encountering Object.freeze, so I went to google for the difference between Object.

Continue reading "Constants"

Captcha isValid()

I needed the client to check for the captcha failure when a user loads a form. In the captchaService abstraction for angular-recaptcha, there was isValid() which does: /** * Check if the response has been set, assuming captcha is enabled. */ this.isValid = () => this.response || !this.enabled; I had a way to trigger the captcha failure. In the same WiFi network, I accessed a form from localhost through my mobile phone.

Continue reading "Captcha isValid()"