Home

  • #100daysofcode Day 5: Shared styles in NX #Angular libraries

    #100daysofcode Day 5: Shared styles in NX #Angular libraries

    With another missed day in my challenge, I will work on packaging styles with a library and use them in our newly created Angular app.

    Angular app styles

    It is easier to serve or build styles inside your app with the default configurations. Once you scaffold an application, the styles are available at {projectRoot}/src/styles.scss.

    To test it out, let us serve our application.

    $ nx serve linkinbio

    Now, open http://localhost:4200/ and you can see your app component.

    If we make a small change to our styles, we can see that in real-time in our app.

    /* styles.scss */
    
    /* You can add global styles to this file, and also import other style files */
    p {
      font-weight: bold;
    }

    Great. So our styling works.

    The problem

    This is good for a self-contained application.

    However, in the case of large applications, there will be a requirement for sharing styles across your libraries and including them as part of the main application build process.

    Creating a shared UI library containing variables, mixins, and shared component-specific styles is helpful.

    So we will learn how to include styles from an NX library into our application.

    Solution – sharing styles across NX libraries

    Create styles

    Let’s create some styles in our ui-shared library at libs/linkinbio/ui/shared/src/styles/linkinbio-ui-shared

    /* libs/linkinbio/ui/shared/src/styles/linkinbio-ui-shared/_variables.scss */
    
    $color-red: red;
    /* libs/linkinbio/ui/shared/src/styles/linkinbio-ui-shared/theme.scss */
    
    p {
      font-weight: bold;
    }

    Update app/project.json

    Now, let’s add the instructions to tell angular compiler to set `libs/linkinbio/ui/shared/src/styles` as one of the paths to look for for our new styles.

    To do that, we will add the following stylePreprocessorOptions property to projects/linkinbio/project.json file.

    {
            ...
            "styles": ["projects/linkinbio/src/styles.scss"],
            "stylePreprocessorOptions": {
              "includePaths": ["libs/linkinbio/ui/shared/src/styles"]
            },
            "scripts": []
            ...
    }

    Import library styles

    Now, you can easily import the styles into your app:

    /* styles.scss */
    
    /* You can add global styles to this file, and also import other style files */
    
    @use 'linkinbio-ui-shared/variables' as ui-shared-variables;
    
    @import 'linkinbio-ui-shared/theme';
    // @import '@rishabhmhjn/linkinbio/ui/shared/linkinbio-ui-shared';
    
    p {
      font-weight: bold;
      color: ui-shared-variables.$color-red;
    }

    You can see your styles applied in the browser.

    It is important to note that I have added a distinct folder, linkinbio-ui-shared, inside the library styles folder. This is because, in the future, it is likely I will need to import styles from other libraries too.

    To ensure the names of the shared styles do not collide with one another, I have chosen to namespace them by putting them in their own unique project name.

    That’s it! Happy coding 🙂

  • #100daysofcode Day 4: Break in the challenge & Ng Scaffolding

    #100daysofcode Day 4: Break in the challenge & Ng Scaffolding

    I had to take a break! I was working from early in the morning and was finishing Statusbrew tasks until late at night before I could get back home to figure out what to write about the blog and then code/screenshot/document and write about it.

    I was up until 2 am consistently for the whole week. I was drained a lot on Wednesday, thinking I would write the blog upon waking up, and, predictably, that didn’t happen.

    I would only delay this process for a while, but it won’t be canceled. I want to write daily. I want to build up this habit and do this consistently. A cliché but giving up isn’t an option.

    I have to mention that writing regularly is one of the things I want to do, me prioritizing Statusbrew tasks, which is for sure would be my priority, is another way to ensure I get done with the complicated Statusbrew tasks so that I can come back to writing as quickly as possible with a more bandwidth.

    Another goal of mine is to return to Sales and Marketing by the end of this month. Looking at the current pace of tasks, it seems unlikely I would be done by the end of the month, but the deviation would probably be for about a week. This doesn’t mean that the Statusbrew tasks will entirely disappear. It just means that I would focus on mentoring & quality control in development while spending significantly more time on Sales.

    Getting back to the challenge now. Day 4 it is.

    Today, I want to set up an Angular application inside our nx monorepo.

    My goal in the next few days is to learn the following concepts/frameworks and combine them to build the application:

    1. SSR – Server-Side Rendering (Angular)
    2. PWA – Progressive Web Application (Angular)
    3. NestJS
    4. Storybook (with Compodoc)
    5. Testing (Angular & NestJS)
    6. Railway

    While considering the type of application to cover the above, apart from the de-facto todos app, I want to build something that can align with what we can use at Statusbrew. There is one app idea I think may require integration across all the above – Link In Bio.

    It has been asked by a few of our clients already. Quite simply, some brands like to share a page on their bio containing some of the most common links to their brand web pages, social profiles, news articles, and dynamic content, such as links to the latest blog posts, giveaways, etc.

    There are some great apps already out there. e.g. https://lnk.bio/ is simple yet filled with compelling features like sync with the latest YouTube videos, and stats.

    I plan to eventually have similar features more aligned with our clients’ preferences. Thinking about it in detail feels like a year-long project, but we would start with the basics here and add more features as we move along.

    Today, we will bootstrap 2 angular entities, a library, and an app, and use the incremental build feature to build both.

    We will start by installing nx angular dependency on our project. I initially tried using the console with the following commands but it seems the workflow to initialize the app afterward is not well laid out.

    $ yarn add -D @nrwl/angular @angular-devkit/core @angular-devkit/schematics

    I had to use the NX Console extension to add the dependency properly. You can find more information here.

    Let’s just go ahead and add the nx angular depenency to our project.

    Let it go through the process and modify the repository. You will see changes to package.json, nx.json, .gitignore, and .vscode/extenstions.json. You will also find some jest.* files added.

    Here are the commands that it seems to have run in the process

    $ yarn add -D -W  @nrwl/angular
    $ yarn nx g @nrwl/angular:init  --interactive=false

    We will make some changes to the nx.json file related to generator configs that would look like this

    {
      "generators": {
        "@nrwl/angular:application": {
          "style": "scss",
          "linter": "eslint",
          "unitTestRunner": "jest",
          "e2eTestRunner": "cypress",
          "strict": true,
          "prefix": "rm",
          "standalone": true
        },
        "@nrwl/angular:library": {
          "linter": "eslint",
          "unitTestRunner": "jest",
          "strict": true,
          "prefix": "rm",
          "style": "scss",
          "changeDetection": "OnPush",
          "standalone": true
        },
        "@nrwl/angular:component": {
          "style": "scss",
          "prefix": "rm",
          "changeDetection": "OnPush",
          "standalone": true
        }
      }
    }

    Now, we will generate a ui library for linkinbio. I would be using the UI to create the lib, which would use the following command.

    $ yarn nx generate @nrwl/angular:library shared \
      --buildable \
      --directory=linkinbio/ui \
      --no-interactive

    Our new library is now available at /libs/linkinbio/ui/shared.

    You can now quickly build the library using the nx-console, project.json or with the following command

    $ nx build linkinbio-ui-shared

    Now, let’s quickly create a new application. Again, I will use nx-console to initialize the app, which eventually uses the following command.

    $ nx generate @nrwl/angular:application linkinbio

    I learned that we must manually add the missing @angular-eslint/eslint-plugin since it is not added after scaffolding. Let’s add that package too.

    $ yarn add -D @angular-eslint/eslint-plugin

    Now, we can launch the newly created app

    $ nx serve linkinbio

    Let’s make the following changes to the app

    1. Add imports: [LinkinbioUiSharedComponent] to app.component.ts
    2. Update the content of app.component.html to just [ <rm-linkinbio-ui-shared></rm-linkinbio-ui-shared> ]
    3. Remove nx-welcome.component.ts

    You can see our app successfully imported a component from a library project.

    Let us build the app to ensure proper library imports as well as incremental builds.

    $ nx build linkinbio
                                                                                         
    1/1 dependent project tasks succeeded [0 read from cache]
    
       Hint: you can run the command with --verbose to see the full dependent project outputs
    
     ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
    
    
    > nx run linkinbio:build:production
    
    Browser application bundle generation complete.
    Copying assets complete.
    Index html generation complete.
    
    Initial Chunk Files           | Names         |  Raw Size | Estimated Transfer Size
    main.068e18dfd9616db8.js      | main          |  82.28 kB |                25.05 kB
    polyfills.a0e551d9f0aaa365.js | polyfills     |  33.09 kB |                10.65 kB
    runtime.dfd26405657e5395.js   | runtime       | 896 bytes |               509 bytes
    styles.ef46db3751d8e999.css   | styles        |   0 bytes |                       -
    
                                  | Initial Total | 116.24 kB |                36.19 kB
    
    Build at: 2023-03-13T00:27:27.824Z - Hash: 0e4718ad16d04a5c - Time: 5027ms
    
     ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
    
     >  NX   Successfully ran target build for project linkinbio and 1 task it depends on (8s)

    You will see that the initial instructions are to build the library before building the app. In the end, the app builds successfully

    This will be it for tonight. We will work with Angular Material and Storybook tomorrow to create UI components.

    See you tomorrow.

  • #100daysofcode Day 3: Shared eslint-plugin

    #100daysofcode Day 3: Shared eslint-plugin

    Today’s challenge will be a quick one.

    I would create and use a custom eslint-plugin in our upcoming libraries & projects. Our goal with the eslint-plugin library will be to share reusable eslint configurations.

    Before we generate any new library, I want to change the configuration of nx to add new libraries to the /libs folder and new projects to the /projects folder. Update the nx.json file to reflect the following:

    {
      .
      "workspaceLayout": {
        "appsDir": "projects",
        "libsDir": "libs"
      }
      . 
    }

    Next, we will generate 2 ui libraries by running the following commands.

    $ nx generate @nrwl/js:library lib1 --unitTestRunner=none --bundler=esbuild --directory=ui --no-interactive
    $ nx generate @nrwl/js:library lib2 --unitTestRunner=none --bundler=esbuild --directory=ui --no-interactive

    Alternatively, we can generate the new libraries using the nx-console extension gui.

    Let’s learn about some of the newly generated library files.

    tsconfig.base.json

    This will be the root Typescript configuration for our project. All future libraries or projects will be extending this configuration.
    The important section to note is paths where we can see our newly added library mentioned.

    {
    ...
        "paths": {
          "@rishabhmhjn/ui/lib1": ["libs/ui/lib1/src/index.ts"],
          "@rishabhmhjn/ui/lib2": ["libs/ui/lib2/src/index.ts"]
        }
    ...
    }

    libs/ui/lib{1,2}

    project.json

    This critical file contains the configurations and commands we would like to run via our nx console.

    If you have installed the nx-console extension, you will see small links to run the commands (or targets) directly from the project.json file.

    We can go ahead and run the build command directly from the project.json file or type the following command in the console.

    $ nx run ui-lib2:build

    The library will be compiled to the /dist folder.

    Eslint

    There will be 3 files related to eslint that are added to our repository.

    /.eslintrc.json
    /.eslintignore
    /libs/ui-lib{1,2}/.eslintrc.json

    There are 2 essential things to note about the root .eslintrc.json.

    1. nx’ eslint-rule: @nrwl/nx/enforce-module-boundaries
      This handy rule triggers warnings if we have circular dependencies in our libraries or projects. You can read more about the rule here
    2. By default, the whole repository is marked as ignored with "ignorePatterns": ["**/*"]. Every individual library or project does the opposite and marks themselves as not ignored in their respective .eslintrc.json configurations

    Besides ignorePatterns in the .eslintrc.json file, we also see a .eslintignore file that contains more file patterns to be ignored globally.

    Now, we will quickly test the @nrwl/nx/enforce-module-boundaries rule by updating the following 2 files:

    /libs/ui/lib1/src/lib/ui-lib1.ts

    import { uiLib2 } from '@rishabhmhjn/ui/lib2';
    
    export function uiLib1(): string {
      return 'ui-lib1';
    }
    
    export function testBoundaries() {
      return uiLib2();
    }
    

    /libs/ui/lib2/src/lib/ui-lib2.ts

    import { uiLib1 } from '@rishabhmhjn/ui/lib1';
    
    export function uiLib2(): string {
      return 'ui-lib2';
    }
    
    export function testBoundaries() {
      return uiLib1();
    }

    We can see that the eslint extension will be showing an error:

    This means our eslint setup is working!

    We can also see that the warning goes off if we deactivate the rule in the root .eslintrc.json config

            {
            "@nrwl/nx/enforce-module-boundaries": [
              "off",
              {...}
            }

    Now we can create our shared eslint-plugin library where will move the @nrwl/nx/enforce-module-boundaries.

    Let’s create a new library: @rishabhmhjn/eslint-config.

    $ nx generate @nrwl/js:library eslint-plugin \
      --unitTestRunner=none \
      --bundler=esbuild \
      --directory=etc \
      --importPath=@rishabhmhjn/eslint-plugin \
      --js \
      --no-interactive

    It is essential to know that eslint-plugin can only use configs exposed from other npm packages and not via the typescript’s paths configuration.

    Since we will add our newly added library as a linked package directly into our root package.json, we can choose to remove the path entry from the tsconfig.base.json file.

    // tsconfig.base.json
    {
     "paths": {
          "@rishabhmhjn/eslint-plugin": ["libs/etc/eslint-plugin/src/index.ts"], // You may remove this line
          "@rishabhmhjn/ui/lib1": ["libs/ui/lib1/src/index.ts"],
          "@rishabhmhjn/ui/lib2": ["libs/ui/lib2/src/index.ts"]
        }
    }
    package.json

    Our package name is already set to what we need, so we do not require any change here.

    {
      "name": "@rishabhmhjn/eslint-plugin",
      "version": "0.0.1",
      "type": "commonjs"
    }
    

    We will add the new library as a yarn-linked package with the following command.

    $ yarn add link:./libs/etc/eslint-plugin -D

    This will create a new entry "@rishabhmhjn/eslint-plugin": "link:./libs/etc/eslint-plugin" in the devDependencies of the root package.json file.

    Now let’s make the following changes to our repository:

    • Update libs/etc/eslint-plugin/package.json
      This exposes our main index.js file that will export our shared eslint configs.
    {
      "name": "@rishabhmhjn/eslint-plugin",
      "version": "0.0.1",
      "type": "commonjs",
      "main": "src/index.js" // Add this line
    }
    • Remove libs/etc/eslint-plugin/src/lib/etc-eslint-plugin.js
      We don’t need this file
    • Add libs/etc/eslint-plugin/src/lib/configs/nx.js
      This is the config containing the set of rules bunched together. We can see that this is the javascript equivalent of the rule in the current root .eslintrc.json file.
    module.exports = {
      plugins: ['@nrwl/nx'],
      overrides: [
        {
          files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
          rules: {
            '@nrwl/nx/enforce-module-boundaries': [
              'error',
              {
                enforceBuildableLibDependency: true,
                allow: [],
                depConstraints: [
                  {
                    sourceTag: '*',
                    onlyDependOnLibsWithTags: ['*']
                  }
                ]
              }
            ]
          }
        }
      ]
    };
    • Update libs/etc/eslint-plugin/src/index.js
      This is how we name and export the configs. Currently, we are exporting the nx config as plugin:@rishabhmhjn/eslint-plugin/nx or short plugin:@rishabhmhjn/nx
    module.exports = {
      configs: {
        nx: require('./lib/configs/nx')
      }
    };

    Once these changes are made, we can remove the rule from the root config and extend the config we just exposed with our new eslint-plugin library.

    • Update .eslintrc.json
    {
      "root": true,
      "ignorePatterns": ["**/*"],
      "plugins": ["@nrwl/nx"],
      "extends": ["plugin:@rishabhmhjn/eslint-plugin/nx"],
      "overrides": [
        {
          "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
          "rules": {}
        },
        {
          "files": ["*.ts", "*.tsx"],
          "extends": ["plugin:@nrwl/nx/typescript"],
          "rules": {}
        },
        {
          "files": ["*.js", "*.jsx"],
          "extends": ["plugin:@nrwl/nx/javascript"],
          "rules": {}
        }
      ]
    }
    

    Now we can go back to the libs/ui/lib1/src/lib/ui-lib{1,2}.ts files and still see that the same lint error.

    Except for this time, the rule triggering this error comes from our new eslint-plugin library, not the rule inside the root .eslintrc.json.

    Hope you found this helpful. This was a very crude introduction to setting up an eslint plugin, but we will explore this further tomorrow along with

    1. Setting up an angular web app project
    2. Add a few eslint configs and implement them differently across libs
    3. Add lint-staged config with a husky pre-commit hook

    See you again tomorrow.

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

    #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.

    Toastmasters

    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.

    Monorepo setup

    Nx

    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.

    Install recommended VS Code extensions

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

    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.

    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"
      ]
    }

    Prettier

    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

    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:

    Husky

    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

    #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!

    Background

    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.

    Objective

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

    1. Knowledge sharing
    2. Communication
    3. Time management

    Knowledge sharing

    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.

    Communication

    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.

    Time management

    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

    Goal

    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

    Next Steps

    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.

    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.

    1) Upgrade talent pool

    • 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

    • 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

    • 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

    4) Simplify access to finance

    • 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.

  • Amritsar Co-working Spaces – Cases For and Against

    Many times, we at Amritsar Founders are invited by Colleges and Universities to work on proposals of Incubation Centers at their respective places. It’s an audacious project, and something that can change the corporate face of our city.

    I wanted to talk about one of the features of Incubation Centers that is seen as a necessity in the whole framework: co-working spaces.

    Ideally, co-working spaces can provide necessary infrastructure such as an office with a desk and chair, power connection, internet and meeting rooms to the budding entrepreneurs & small businesses. Co-workings can also provide private cabin spaces for bigger teams. Other perks include security, permanent office address & cafeteria. Luxury ones may consist of gyms & fitness centers too.

    Cases For

    Let me start with how co-working spaces can be valuable to our community.

    1) Never feel lonely

    If you have worked as a solo entrepreneur or a freelancer, you know that it is lonely to be doing things on your own without a peer group. Co-working spaces provide an excellent opportunity to be surrounded by those who are also working on their dreams that would keep you motivated and inspired to work on yours.

    We at Statusbrew have seemingly been working from our cave, Statusbrew HQ, with little interaction with the outside community, and it had been a lonely journey. Amritsar Startups was our initiative to create a community of go-getters and our answer to eliminate working alone. Later, I found solace with my newly formed group of entrepreneurs at Amritsar Founders. It’s truly remarkable how ideas and thoughts can be shared and transferred when you have a group of like-minded people you can call your own.

    2) Networking

    Having surrounded with like-minded people and the ability to interact with them, many opportunities can unfold. You can learn new skills, connect with potential clients, and even get a direct connect to the investors.

    3) Save costs

    No rental contracts (office, internet, electricity, etc.), no maintenance, no hassle of dealing with infra! Co-working saves you not only real money but also saves you time and opportunity costs. This is great for freelancers as well as small to mid-sized companies.

    And oh, the improvements to infra is also part of the job of your co-working provider. You don’t need to worry about upgrading infra anymore.

    Cases Against

    1) Distractions

    As promising the idea of networking is, it can also be a perpetual means to distract oneself. Some teammates would be found more often at common spaces or someone else’s desk than getting their own job done. Other teams at the space can be loud. There will be circumstances out of your control and can lead to reduced productivity.

    2) Restrictions

    Since you do not own the place, you would be potentially stuck with one allotted desk space for a considerable time. You would not be able to change orientation or decorate your workspace the way you like. Even bringing personal work amenities like whiteboards might require approvals.

    3) Bloated costs

    It might prove to be cost-effective for freelancers or small businesses by saving some upfront costs. However, it can prove to be quite expensive for mid to large companies as pricing is usually set on a per seat basis.

    Co-working scope in Amritsar

    Talking about this puts me in a very slippery slope as I am still part of the local communities, but I feel we need to talk about the core challenges that surround co-working, which ironically, have little to do with co-working.

    I think creative teams, HR and admin teams can work out of co-working spaces efficiently without significant concerns.

    But it can be an issue for core, tech (product or service) companies to be working out of co-working spaces due to requirements of safeguarding intellectual properties and private information. Core development and sales teams can be the ones under a more rigorous scrutiny for this.

    However additionally, since in Amritsar, a majority of the companies are into IT services – digital marketing, web & app development, etc., there can be understandable concerns about keeping their internal business processes secret.

    Issues with Co-working spaces in Amritsar

    1. Hoping clients –  since both your clients and other teams can now know about each other (visits, or overhearing discussions), they can quickly jump.
    2. Copying of ideas – expertise in creative content
    3. Information security leak – personal information of clients, contracts and intellectual property
    4. Talent poaching – other teams can pay more to recruit your trained staff

    Ways Co-working spaces can work in Amritsar

    Co-working can be a great fit for companies that do not have major overlapping business processes since there will be no concern about clients or team spillovers.

    Companies that require a high level of information security can work out of cabins so that their internal discussions or plans cannot be overheard by other tenants. Sales teams can make use of conference rooms to make sales calls, deliver product demos, or meet clients.

    Moreover, a simple agreement must be signed by all co-working tenants to ensure they adhere to a certain level of information protection. Defaulters should be penalized and may also be asked to leave the co-working space after a thorough hearing process.

    Conclusion

    I believe co-working is terrific and it would provide many opportunities for the community in growing their ventures. With this, we may also be able to attract a lot of investors, perhaps have a global incubator from our city. With a good plan and careful execution, we can see many global companies starting from the Holy City.

  • Levels of Politeness – Lessons from Japan

    This one is also one of the many learnings from my 4 years in Japan. In Japan, it is very important to choose the right politeness level as it can make or break your relationships with your friends, clients, or your team.

    Keigo is crucial and particular to Japan. However, some of it can also be easily implemented in your own day to day conversations.

    In the following examples, the politeness increases as we go down the list.

    1) Name? / Your Name? / Name please? / Tell me your name.

    This will be the most straightforward but blunt way to ask someone their name.

    2) What is your name?

    Asking a question in a complete form is a basic and safest way to ask someone their name.

    3) Can you tell me your name?

    There is a subtle difference between this and the next one. In this way, we are making the other person DO THE WORK to complete this task. However, this one is politer than the previous version because you are asking for permission first before you can have their name.

    4) May/Can I ask your name?

    This one also asks for permission before you can have their name. However, in this version, you are the one who is DOING THE WORK to complete this task. You may use this with your managers and your clients.

    5) Is it OK if I ask your name?

    This version is politer than all the above as it is checking whether it is OK to ask for permission to have your name, and then proceed to ask. Best to converse with your clients.

    Which level of politeness do you use with your friends, team, and clients?