Use Snippets tab of Chrome browser inspector to run your code instead of console


While developing projects, we may need to take help from other projects hosted on github.com. General procedure involves cloning the repository, because it is not easy to navigate through the files on github.com.

https://github.com/conwnet/github1s solves this simple issue of easing navigation through files in browser itself

Checkout below repo link

https://github1s.com/conwnet/github1s

Instead of github.com it is github1s.com

You can easily navigate through any github public repository, by adding 1s after Github in the repo link


Reviewing pull requests is very important in order to ensure that consistent practice is followed all throughout the code, thus all stakeholders should promote pull request review as an important task

Considering a team of 6–7 developers will create 3–10 pull requests in a week it is important that we devote special time to the process. Creating proper pull request with description and reviewing them properly does take a considerable amount of time and generally, only the team lead or some senior members will review pull request, other simply ignore it as not part of their duty.

Few reasons why…


In every frontend code we use a lot of colours in scss.

First bit of optimisation is to put all the colour variables in a separate file, so that we can get all the colours used in our project at one place

Now second bit is about giving proper names to these colour variable so that we get an idea just by looking at the name.

So I consider two types of colours

  1. gray colors (gray, black and white)
  2. non-gray colors (rest other colors)

Below is an approach that I am following and finding helpful for gray colours

  1. use rgb…

I work at Nium where we handle international money transfer, so we have pages where we show clients a list of transactions, and this is where I got a good case to make medium post!

See the case —

A user does a transaction in India at 2am 20-October, it is recorded in database with timestamp of 2020:10:19T20:30:00Z i.e 19th October 8:30pm this is what is the GMT time at 2am India Time on that day!

Suppose on any other day, that user in India tries to search for that transaction using date filter, as he knows that he has…


Gist: -> Either return a new value *or* modify the draft

A recipe function is used to update the value in immer library, here’s an example

const recipe = draft => {
draft.cool = true;
}
const newValue = produce(recipe, {cool: false})
console.log(newValue) // { cool: true }
  1. You mutate the draft to create a newValue, returning draft after modifying it is optional, the immer will anyway return the finalized draft
  2. if you return anything else except undefined or draft from the recipe, then the new return value will replace the state
  3. Point 2 is ok, only if you do not modify the draft in your recipe function. i.e. you can…


I am writing this code snippet that should be helpful to you as a utility function.
It will throw an exact error for you when you want to assert, that something should not be null or undefined

export const shouldNotBeNull = (container: any) => {const entries = Object.entries(container);let error = '';const getErrorMessage = (variable: string, token: string) =>`${variable} should not be ${token}`;const addError = (errorString: string) => (error += errorString);for (let i = 0; i < entries.length; i++) {let [key, value] = entries[i];if (value === null) {addError(getErrorMessage(key, 'null'));}if (value === undefined) {addError(getErrorMessage(key, 'undefined'));}}if (error.length > 0) {throw new Error(error);}};

link to gist
Thank you!


We write unit tests so as to make sure our code functions as expected and we can get notified when there is a change in behaviour by the test-runner

We should write comments so that a developer can reassure his understanding of code by reading comments

Thus it can also be considered as a unit test for developer.

More so if you are not immediately writing unit tests for code, in future either you or your peer can take comments as a guideline to write unit tests


Suppose we have an API /getTransaction with following response

{
transactionId: “TCC1232434”,
bankName: “ABC”,
accountNumber: 12131314,
transactionComments: "comments"
}

We might have another API to create the transaction and generally, transactionComments is an optional field

So while creating a transaction if someone does not enter transaction comments, nothing is stored in the database for field transactionCommentswhich is equivalent to null

and thus calling /getTransaction will return

{   
transactionId: “TCC1232434”,
bankName: “ABC”,
accountNumber: 12131314,
transactionComments: null
}

Now consumer of API is expecting transactionComments to be a string, and so might have string methods applied on transactionCommentslike this transactionComments.replace(' …


As a good practice, we keep a separate deployment instance=(qa=app.qa.com) apart from main deployment=(production=app.com), so that we can test our development on qa instance before moving that code to production instance

Adding a further level of safety, the code deployment to these different instances (qa and production) also goes from different git branches ( qa and master )

For new code addition, we create a branch=(feature-1) from qa and test it locally and if it works well on local, we merge feature-1 to qa branch, now this qa branch is used to deploy code to qa deployment instance hereafter referred…

Akshay Jain

I love learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store