Skip to content

Blog

#100daysofcode Day 2: Toastmasters, Nx, Commitlint, Husky

It’s 23:31 at the time of starting this blog! I just returned from a Toastmasters event.

I didn’t get time to work on the challenge today in the coworking space as I was busy with a few meetings and the goal of completing the skeleton of the data management flow of our Create post page with custom hooks. I am happy that it was finished before I left for the Toastmasters.

Tomorrow, I will complete the integration of data management hooks with the screens.

A fellow at the coworking space invited me to join him at the Toastmasters event. Toastmasters is an organization that encourages people to learn public speaking and communication skills through regular events, usually weekly.

It’s an incredible stroke of luck that I recently talked about improving my speaking skills, and today there I was as part of a community that’s doing just that. The participants were half Czech and half expat.

The topic of today was confusing: Reverse Toastmasters. It was about doing all the things they usually do, but in reverse.

It kicked off with an ending farewell note, feedback on the speeches (that were yet to come), and lastly the introduction of what the Toastmasters event is. It was confusing for all the participants! However, it was fun and interesting.

I am inclined towards joining one of these groups. I found the people to be kind and supportive. Everyone seemed to have come with a shared ambition of learning how to speak in public. That is just what I was looking for!

I still struggle to find the right words to communicate well. The easier, straightforward topics for me to talk about are differences in culture, work, and jokes.

But my goal is to give an informative presentation on a specific topic. It’s easy to do small talks about random topics with a handful of people, but it is challenging to keep a large audience engaged when you have all their attention and expectations to gain something out of the time they spend listening to you. It’s daunting!

When you learn to write, you learn to think

One of the ways I feel I can overcome this hurdle is by writing. It’s very late now, but I want to write a blog daily; no excuse! So here we are.

For the challenge, today I will create and publish the 100daysofcode repository with support for nx, commitlint and husky. Let’s get started.

We will initialize our 100daysofcode challenge monorepo using the create-nx-workspace command. I will talk more about monorepo and their benefits in the coming days. For now, let’s create our repository.

$ npx create-nx-workspace@latest @rishabhmhjn/100daysofcode --preset=ts --package-manager=yarn

This should initialize your repository with the following files.

Screenshot-2023-03-06-at-23.14.44

I suggest you also install the VSCode extension for NX, which will make it easier to run NX commands directly from the editor.

Screenshot-2023-03-06-at-23.16.17

The recommendation to install Nx console is already added to your .vscode/extensions.json file, so it should appear in your Extensions tab under the Recommended window.

I will also add some of the extensions I use daily to my list of recommended extensions.

I could type in their IDs directly into the JSON file manually.

I can also search the extensions and press the Add to Workspace Recommendations file directly from the UI. The extension IDs are added to the .vscode/extensions.json file automatically.

Screenshot-2023-03-06-at-23.24.07

This is how my .vscode/extensions.json file looks like

{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"formulahendry.auto-rename-tag",
"jannisx11.batch-rename-extension",
"aaron-bond.better-comments",
"wmaurer.change-case",
"naumovs.color-highlight",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"oderwat.indent-rainbow",
"ecmel.vscode-html-css",
"eamodio.gitlens",
"davidanson.vscode-markdownlint",
"pnp.polacode",
"medo64.render-crlf",
"ms-vscode.sublime-keybindings",
"angular.ng-template"
]
}

Now we can start adding our custom configs, starting with prettier. I use the following config for our projects.

{
"singleQuote": true,
"useTabs": false,
"tabWidth": 2,
"semi": true,
"trailingComma": "none",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "strict",
"printWidth": 80,
"overrides": [
{
"files": ["**/*.html"],
"options": {
"printWidth": 120
}
},
{
"files": "*.{yaml,yml}",
"options": {
"singleQuote": false
}
}
]
}

Commitlint helps you create consistent commit messages. You can follow the instructions at https://github.com/conventional-changelog/commitlint.

# Install commitlint cli and conventional config
$ yarn add @commitlint/{config-conventional,cli} -D

I tend to follow Angular’s commit message guidelines. We can install the package containing their commitlint rules.

# Install the angular commit lint config
$ yarn add @commitlint/config-angular -D

Now, although commitlint manual suggests using a commitlint.config.js file, I will go a different route and use a .commitlintrc file.

echo '{"extends": ["@commitlint/config-angular"]}' > .commitlintrc

I will also instruct the VSCode editor to fetch the schema of the JSON file so that I can get a neat explanation of what the various property means. To do that, I will add a new file .vscode/settings.json.

.vscode/settings.json
{
"json.schemas": [
{
"fileMatch": [".commitlintrc.json", ".commitlintrc"],
"url": "https://json.schemastore.org/commitlintrc.json"
}
]
}

Once the schema is fetched, you can hover on to the properties and also get code completions:

Screenshot-2023-03-06-at-23.53.24

We also need to add husky that automatically runs the pre-commit hooks for commitlint and the eslint later.

# Install Husky v6
yarn add husky --dev
# Activate hooks
yarn husky install
# Add the pre-commit hook
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'

This should add a few files to the .husky folder.

To ensure the git hooks are installed automatically if you move systems or when someone else works on your repository, you need to add the following command to your scripts in package.json

"scripts": {
"prepare": "husky install"
},

Before committing the above changes, we should add our own commitlint config. I foresee using the following config for the coming time, so I will add it manually. This is what my .commitlintrc will look like.

{
"extends": ["@commitlint/config-angular"],
"helpUrl": "https://commitlint.js.org/#/reference-rules",
"rules": {
"type-enum": [
2,
"always",
["build", "docs", "feat", "fix", "perf", "refactor", "revert"]
],
"scope-max-length": [2, "always", 16],
"scope-min-length": [2, "always", 2],
"scope-empty": [2, "never"],
"scope-enum": [2, "always", ["infra"]],
"subject-case": [2, "always", ["sentence-case", "lower-case"]],
"header-max-length": [2, "always", 72],
"body-max-line-length": [2, "always", 72]
}
}

I will add more scope-enum in the coming days of the challenge. You can read more about the commitlint rules here.

Now, if you would try to commit with a non-conforming commit message, you will get an error, and the commit will fail.

# 1. Without any format
$ git commit -m "Any Commit"
⧗ input: Any Commit
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ scope may not be empty [scope-empty]
✖ found 3 problems, 0 warnings
ⓘ Get help: https://commitlint.js.org/#/reference-rules
husky - commit-msg hook exited with code 1 (error)
# 2. Following the format but exceeding max header length
$ git commit -m "feat(infra): Adding .prettierrc, .commitlintrc and recommended vscode extensions"
⧗ input: feat(infra): Adding .prettierrc, .commitlintrc and recommended vscode extensions
✖ header must not be longer than 72 characters, current length is 80 [header-max-length]
✖ found 1 problems, 0 warnings
ⓘ Get help: https://commitlint.js.org/#/reference-rules
husky - commit-msg hook exited with code 1 (error)

This means that our pre-commit hook with commitlint is working. We can now commit the current code with a proper message.

$ git commit -m "feat(infra): Adding .prettierrc, .commitlintrc and .vscode/extensions"
[main febffba] feat(infra): Adding .prettierrc, .commitlintrc and .vscode/extensions
7 files changed, 1010 insertions(+), 18 deletions(-)
create mode 100644 .commitlintrc
create mode 100755 .husky/commit-msg
rewrite .prettierrc (84%)
create mode 100644 .vscode/settings.json

Success! Now I will push this newly created repository to my github profile.

https://github.com/rishabhmhjn/100daysofcode

It’s 01:33 now! I planned to do more, but I need to sleep to be able to finish my ComposePage tomorrow.

Tomorrow, for the challenge, I plan to work on the following within the new nx monorepo:

  1. Create a simple Angular/React/Vite project
  2. Create & test custom eslint-plugin
  3. Update the Readme.md

It was a very crude post today, but I hope it will be useful to you.

See you tomorrow.

#100daysofcode Day 1: Taking the first step

“I can’t see a way through”, said the boy. “Can you see your next step?” “Yes” “Just take that,” said the horse. The Boy, the Mole, the Fox and the Horse

I have been going over this for long, and it is high time I do this. Rephrasing, It would be a waste of my time if I don’t do this!

I have been a developer for most of the last 13 years. I have built tools and libraries consumed primarily internally at my company, Statusbrew.

I used to be active in building communities of creators, developers, and startup/small business owners in my home city. I had many occasions to meet new people and share knowledge with them. We were also covered frequently by the local press. Many people in our city knew about us and were following our work.

After the pandemic started, I passed on the opportunity to become active in the social space as I focused on sales and revamping our web and mobile applications. It’s been nearly 2 years since I also gave up even on talking to my own customers and delved deeper into coding behind my work desk. That closed work focus was the need of the time, but now most of the hard work is done.

I have temporarily moved to Prague and have spent a significant chunk of the last 2 years here but working from home. I moved to a co-working space in November and saw my communication and social circle improve. I am inspired by the tech talks I get to attend nowadays, and I envision being part of the core community soon.

It was not easy getting back within groups of people and talking. Often I find myself in the situation I was in 12 years ago when I moved to Japan – my accent and the words I use are hard for people to understand. I am also stumbling during simple discussions. This is due to the lack of social interactions in the last years.

So things need to change. I needed push myself to become more active virtually and in daily dealings for my growth.

Thus, this challenge.

I am taking up this challenge to work on the following aspects:

  1. Knowledge sharing
  2. Communication
  3. Time management

Every day, I work on exciting solutions, designs, and architecture that goes into building a complex application. A portion of that knowledge gets shared with my team, but most of it gets lost as I move on to the next problem.

Occasionally, I get to attend tech meetups and discuss challenges with other developers. Most expressed excitement when they learn about some unique designs we have worked on our with our application architecture. I reciprocated similarly when I learned something new from them.

I started to take small steps of knowledge sharing and technical discussions in my current workspace. When I am stuck, I reach out to developers in the space; those discussions have benefitted me.

A simple example:

I could find a workaround for using Components with Generics and memo (or even forwardRefs) that helped enforce strict type definitions in my component designs. This solution was given by a fellow react developer in my coworking space.

100daysofcode-generic-type-memo

There is no doubt that writing and speaking skills are incredibly essential nowadays. We have infinite thoughts, though a majority of them are banal. But there are many ideas that, when shared, can lead to meaningful interactions and connections.

During all that hustle in the last 3 years, I hadn’t been reading, writing, or engaging in public communication. Recently, I had moments when it was hard to express myself and communicate well.

With this challenge, I will focus on articulating and publishing a daily post, however small it will be, on this blog under the #100daysofcode tag.

I will discuss javascript, typescript, mono repo, angular, react, and architecture designs. Currently, I do not plan to publish open-source libraries, but I would love to release something helpful to others whenever possible.

I will also use various tools and modes to share knowledge, an upcoming github monorep, Expo Snacks & gists. I also plan to publish a mundane looking timelapse of one of my daily pomodoro sessions on the @ramenhacker Instagram page.

Without a doubt, my work at Statusbrew has and will likely continue to precede other initiatives. However, I want to push myself to pursue other interests, knowing that now it’s more possible to do so than ever before.

My tentative time divisions would be as follows:

  1. Statusbrew (8 – 10 hours)
  2. Publish a readable gist/snack/monorep (0.5 hour)
  3. Timelapse reel (0.5 hour)
  4. Daily progress report blog post (1 hour)

Undoubtedly, I won’t have the same bandwidth to strictly follow the above time allocation. I reckon it will be a tentative time division when looked at over the course of a week or month.

This blog has taken me about 4 hours to write! Of course, I don’t intend to write lengthy monologues every day. But I don’t want to take more than 20-30 minutes to write the next set of posts

My ultimate goal with this challenge is to give a presentation about a topic I have mastered at a developer meetup.

To achieve this goal, I will

  1. Learn to organize my thoughts into speaking bits and writing
  2. Be more active in the nearby developer communities
  3. Become comfortable in front of an audience or camera

In the coming week, I will set up a high-level plan of action and milestones leading toward my goal.

Tomorrow, I will set up and publish a monorepo with my frequently used configs, such as .dotfiles, eslint, and prettier. Soon, I will be writing about Angular, React, Vite, Monorepo architecture, and the best practices we have implemented.

A7400533

From Starbucks in front of the Astronomical Clock in Prague

This challenge will not solve all my communication problems. But it sure will help improve it a little bit. So I am taking the next step.

Have a great rest of the weekend. See you soon.

Cracking competitive exams is easier now than before

I think those in the 2020s who would study as hard as those in the 2000s or earlier while preparing for competitive exams have the same, if not better, odds of getting into a good engineering, medical, or commerce school.

One may challenge this, arguing that 1) the number of students appearing for the competitive exams is higher and 2) the increase in the number of seats has not been enough; concluding that there’s higher competition than before.

I agree with the arguments but would differ with the conclusion.

There is more accessibility to learning material and coaching with or without in-class learning. Multiple techniques for solving an equation can be learned through an internet search. There is more training and test material available than before.

On the other side, nowadays, students are perpetually distracted by social media or phones. Many are lesser inclined to devote themselves to 3/4/5 years of rigorous college training. Then there is the rise of job opportunities like content writing, photography, or travel/fashion/motivational blogging/speaking.

This works in favor of those willing to stay focused to pursue higher education to have higher odds of getting into a good school.

Rise of shallow and desperate mentors

Back in the 90s when I was growing up, our parents used to look out for people in their 20s to give us advice on career and skill development.

As far as I remember, the then-20s people didn’t have any urge to teach us what to do or to become an inspiration or mentor to us.

I believe it’s because even though, I think, they were more stable, skillful, and successful, they probably felt that they still have a long way to go. Despite others’ perception of them doing well, they felt they still might not know enough. They were humble and conservative when referring to their skills.

Also, I cannot recall a discussion that didn’t conclude with studying to develop skills in STEM, skills that are attained over a long period.

Nowadays, I frequently come across folks barely holding a digital agency job but overtly desperate to teach others how to start up, earn a side income, or travel freely.

None of it alludes to studying hard. The majority of it seems to be selling the ‘idea’ of appearing successful.

Amritsar Startup Manifesto

Guidelines for Entrepreneurship & Innovation to Unlock, Inspire and Drive Growth in Amritsar

Amritsar had been a very prominent business hub up until a few decades ago. But due to the changing socio-economic environment coupled with the failure to keep up with the latest technology and skills, the city has failed to compete with the global market.

Perhaps the draconian government policies are to be blamed.

Still, we believe that the failure to understand the changing global business dynamics, slower technology adoption, and lack of growth mindset has led to the loss of confidence of its people and the business community outside.

India has seen a meteoric rise in the consumption of technology. Internet penetration has increased. Smartphones and data are one of the most economical commodities compared to the rest of the world.

The rising importance of technology-driven economic growth can transform the lives of thousands of people by providing them with high-paying jobs, competitive skills, and a global level-playing field. The increasing availability of high-speed internet means that we can nurture and grow technology businesses that can serve customers from all over the world, right from the comfort of being in our city.

In the coming time, the growth of technology businesses will outpace that of traditional economic sectors.

But, as with many industries, there are roadblocks in the growth of businesses. This is why I, along with some of my fellow entrepreneurs at Amritsar Founders, decided to join and call for radical changes.

We have recognized the following areas which need to be focused on to catapult and sustain the growth of businesses in Amritsar.

  1. Upgrade talent pool
  2. Make available world-class and affordable infrastructure
  3. Update policies to support disruptive innovation
  4. Simplify access to finance

This is an audacious goal that needs buy-ins from many players such as local educational institutes, industry leaders, entrepreneurs, police, lawmakers, and politicians.

  • Set up skill development programs in collaboration with the local educational institutes
  • Make it easier for startups to hire from overseas
  • Incentivize individuals and startups to train teachers and students
  • Support women to start and scale their businesses
  • Encourage and organize hackathons, meetups, and conferences
  • Invite global mentors and companies to provide training to local businesses and institutes

2) Make available world-class and affordable infrastructure

Section titled “2) Make available world-class and affordable infrastructure”
  • Invest in high-speed internet connectivity, even in rural areas
  • Provide cheap and affordable office and co-working spaces on flexible terms
  • Invest in technology at the local universities
  • Provide accessible rentable housing spaces for non-resident workers
  • Invest in entertainment, sports, and playgrounds for recreational purposes
  • Provide resources to local businesses to take part in regional as well as global conferences and exhibitions

3) Update policies to support disruptive innovation

Section titled “3) Update policies to support disruptive innovation”
  • Work with startups to eliminate regulations in technology
  • Formulate employer protection laws to instill confidence in entrepreneurs and investors
  • Review regulations surrounding the sharing economy – office spaces, housing, cars, internet, etc
  • Standardize and facilitate company creation
  • Provide and educate about tax relieves for entrepreneurs
  • Lower minimum investment and compensation requirements for hiring from abroad
  • Ease regulations on ESI, PF, and Insurance
  • Provide affordable loans and tax relieves to the skill development centers

We hope to represent and share a common vision of various entrepreneurs, professionals, small business owners, mentors, investors, and consultants irrespective of the industries. We aim to collaborate, communicate, and contribute to the growth of the local business ecosystem by promoting reasonable and actionable recommendations.

We encourage you to be part of our journey and work with us to bring Amritsar to the top of the World’s Business Map.

Embedded content