My learning diary

Multi-step forms

I’ve a few pages which I need to chain into a single form flow. I also need to display a progress bar at the top of each form. I need to do some rearchitecting. Reasons: If we don’t do anything, we will need to insert <ProgressBar .../> and the like into every form component. Sharing the forms/pages across other flows which don’t need the progress bar is difficult. The form flow will become more obscure.

Continue reading "Multi-step forms"

Polling

There were instances where users filled up a time-consuming form but couldn’t submit it because of reCaptcha failure. Users ended up having to refresh and re-populate the form. That’s some harsh user experience. My team uses a forked version of angular-recaptcha. I located the controller, directive and template for the form. I attached a recursive $timeout at the controller and the directive, but as of now, I’ve not gotten them to work.

Continue reading "Polling"

Calculator V2

I made some changes to my compound interest calculator after reading up on “future value”. My calculator will allow users to specify regular deposits. This is so that they can see for themselves the importance of every dollar added to their savings. import nerdamer from 'nerdamer/nerdamer.core'; import Algebra from 'nerdamer/Algebra'; import Calculus from 'nerdamer/Calculus'; import Solve from 'nerdamer/Solve'; const totalMonthsPerYear = 12; export const calcCompoundInterest = ({ principal, depositAmountPerMonth = 0, interestRatePerAnnum, compoundRatePerMonth = 1, totalMonths, }) => { const totalAmount = solveForOneUnknownVariable( 'a=(p*(1+(r/n))^(n*t))+(q*(((1+(r/n))^(n*t)-1)/(r/n)))', { p: principal.

Continue reading "Calculator V2"

Quick Go 3

Chapter 5 and 6 were about basic data structures (like arrays, slices and maps) and functions. package main import "fmt" func main() { // Chapter 5: Arrays, slices and maps var x [5]int x[4] = 100 fmt.Println(x) // No coercing when there is a division operation involving a float64 and int // i.e. (mismatched types float64 and int) // Should do a / float64(b) var total float64 = 0 for i, value := range x { total += value } // Different from Python's range // Compiler will complain "i declared and not used", so we must rename unused variables to '_'.

Continue reading "Quick Go 3"

TypeScript Shortcuts

TL;DR: I learnt how to (invert a map) and (copy a map and override the values of the copy) in TypeScript. Ctrl+F TYPESCRIPT_SHORTCUT_1 and TYPESCRIPT_SHORTCUT_2 to get to the code. Context: Yesterday, I didn’t invest time into inverting a TypeScript Map<string, string>. Today, I received feedback that I should extract the encode logic into a function of its own. I decided to put in more effort. Here’s the new original code:

Continue reading "TypeScript Shortcuts"