Fueling Curiosity, One Insight at a Time

At Codemancers, we believe every day is an opportunity to grow. This section is where our team shares bite-sized discoveries, technical breakthroughs and fascinating nuggets of wisdom we've stumbled upon in our work.

May 4, 2023
When we have conflicts between main and production, we cannot open PR directly. We do the following:
1. git fetch and then go to production -> git checkout production
2. Create a new branch from production -> git checkout -b
3. Pull latest changes from main -> git pull origin main or git merge main
4. Resolve conflicts
5. Push the changes and create a pull request with base branch as production
6. And chill 🙂
syedsibtain
Syed Sibtain
System Analyst
May 3, 2023
Today I learned

1 Fetch data from Api.
2 How to use axios for Fetching Api.
3 How to use storybook.
4 Learned jest for writing test cases.
rishav.raj
Rishav Raj
System Analyst
May 3, 2023


git reset --hard origin/master
says: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as origin/master.

You probably wanted to ask this before you ran the command. The destructive nature is hinted at by using the same words as in "hard reset".


ayushsrivastava
Ayush Srivastava
System Analyst
Apr 27, 2023
So if we want to mock the useRouter hook in NextJs, we can use vi for it.
The "vi" library's function vi.mock allows us to simulate the behaviour of the useRouter hook. The mock function returns an object that mimics the Router object's properties and methods.



vi.mock("next/router", () => ({
    useRouter: () => ({
      replace: vi.fn(),
    }),
  }));


replace: a mock function that simulates the behavior of the replace method of the Router object.
If we do not use it, the test might fail and we get the following error.
Error: NextRouter was not mounted.
syedsibtain
Syed Sibtain
System Analyst
Apr 26, 2023
userEvent is considered to be a more reliable and secure way of triggering events in the browser because user events are events that are triggered by a user's interaction with the webpage and reflect the actual user behavior on the page.
However, fireEvent is a means of programmatically activating an event (dispatching DOM events) in the browser, which can be less dependable.

Reference: https://testing-library.com/docs/user-event/intro/#difference-to-fireevent
syedsibtain
Syed Sibtain
System Analyst
Apr 26, 2023
userEvent is more reliable and easy to use rather than fireEvent.
userEvent provides wide range of browser events options and it is like interacting with events same as we interact in browser
satya
Satya
Mar 15, 2023
We can easily browse s3 folder locally by using this https://github.com/awslabs/mountpoint-s3 tool
iffyuva
Iffyuva
Mar 13, 2023
Postgres query uses || as string concatenation instead of +
vaibhav.yadav
Vaibhav Yadav
Senior System Analyst
Mar 4, 2023
We can type JSON into https://app.quicktype.io/ and it generates TypeScript type.

Can be helpful in defining types for api response (usually while integrating third party apis where large amounts of data is returned).
ashwanikumarjha
Ashwani Kumar Jha
Senior System Analyst
Mar 2, 2023
you can whitelist IPs and ranges in nginx. When we have separate virtual hosts these are saved in /etc/nginx/sites-enabled. The rules look like allow xx.xx.xx.xx/range(32); and deny all;. Further we can make sure nginx passes some headers to the app using the rules proxy_set_header Host $http_host;.
keshav.chakravarthy
Keshav Chakravarthy

Showing 46 to 48 of 82 results

Ready to Build Something Amazing?

Codemancers can bring your vision to life and help you achieve your goals