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.

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
Feb 27, 2023
We can use the following where clause to filter users based on their age using a Postgres query
(CURRENT_DATE - INTERVAL '18 years')::date < TO_DATE(T3.DATE_OF_BIRTH, 'YYYY-MM-DD')
vaibhav.yadav
Vaibhav Yadav
Senior System Analyst
Feb 26, 2023
As a Next.js app can be executed on both the server and the client side. When the app is rendered on the server, there is no access to the browser-specific features like localStorage, as it is a feature of the client-side browser environment.

So let's say, if we try to use localStorage in a Next.js app, we may encounter issues when the app is being server-side rendered.

To avoid this problem, we can check if localStorage is available before using it in our Next.js app.



if(typeoflocalStorage!== 'undefined') { 
// Use localStorage here
} 


This way, our app will only use localStorage when it is available, and avoid errors when it is not.
ashwanikumarjha
Ashwani Kumar Jha
Senior System Analyst
Feb 18, 2023
Bring the suspended server to foreground using fg command. Say the server is running and we want to install a package


1. Ctrl+Z
2. yarn add jsonwebtoken
3. fg


And the server resumes
sujay
sujay
Feb 13, 2023
We handle navigation in Gatsby using the Link Component. So if we put both external and internal links in the Link element, we receive the following warning in the console:
External Link was detected in a link component. Use the link component only for internal links.

This is because the Link component is designed to interact with Gatsby's client-side navigation, which is better for single-page apps and uses the window.history API to update the URL without reloading the entire page.

So in case of external links, we should prefer a simple a tag and pass the href attribute.

Also gatsby prefetches the linked pages by starting a low priority request over a link, when we take the mouse on it onMouseOver, it makes the request high priority.
syedsibtain
Syed Sibtain
System Analyst
Feb 13, 2023
Difference between DOM element properties clientWidth clientHeight , offsetWidth offsetHeight , scrollWidth scrollHeight

clientWidth /clientHeight is the visual portion of box content, borders and scrollbars not included, but padding is included
offsetWidth/offsetHeight is the size of visual box including borders. Can be calculated by adding width/height and padding and borders.
scrollWidth/scrollHeight is the size of the box content, including the parts that are hidden outside the scrolling area
ayushsrivastava
Ayush Srivastava
System Analyst

Showing 42 to 44 of 77 results

Ready to Build Something Amazing?

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