My learning diary

Some Git

I didn’t 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()"

Some Similarities

This .some-class { display: flex; flex-direction: column; justify-content: center; min-height: 20rem; } and this .some-class { display: flex; align-items: center; min-height: 20rem; } appear the same to me. CSS-Tricks says, You can think of align-items as the justify-content version for the cross-axis (perpendicular to the main-axis).

Continue reading "Some Similarities"

Redux Poof!

I was at Page A. Page A calls an API and stores the response in the Redux store. After some clicking, I was routed to Page B. I expected to retrieve the API response stored by Page A. But it wasn’t there! The culprit was <a href ...>. I should be using Link or navigate(...) instead. When I refreshed Page B after getting there via Link, the store went poof again.

Continue reading "Redux Poof!"