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.
Sep 20, 2023
When your
Gemfile.lock says BUNDLED WITH 2.2.4 , but while doing bundle -v or starting your rails server or rails console you get an error saying"You must use Bundler 2 or greater with this lockfile." . We can resolve that by running gem update --system .Satya
Sep 15, 2023
There are a couple of performance metrics used to measure the loading and rendering speed of web pages.
1: First paint: It refers to the point in time when the browser starts rendering first pixels on screen. It does not needs to be recognisable. First Paint can include background colors or simple styling changes and doesn't guarantee that any content or text is visible yet.
2: First Contentful Paint (FCP): First Contentful Paint occurs when the browser renders the first piece of content from the DOM (Document Object Model). It can be text, an image, etc usually referring to something meaningful on the screen.
3. First Meaningful Paint (FMP): It refers to the point where a user can identify and understand the content that is loading. Usually includes layout changes the the font are loaded as well. FMP is depreciated.
4. Largest Contentful Paint (LCP): It measures the time it takes for the largest content element (such as an image, text block, or video) within the viewport to become fully visible and rendered on the user's screen. A webpage should have a LCP of 2.5 seconds or less.
5. Speed Index: It simply refers to how quickly the visible content of a web page is painted or rendered during the loading process. It depends on size of the viewport (mobile/desktop). Lower the score, the better it is.
1: First paint: It refers to the point in time when the browser starts rendering first pixels on screen. It does not needs to be recognisable. First Paint can include background colors or simple styling changes and doesn't guarantee that any content or text is visible yet.
2: First Contentful Paint (FCP): First Contentful Paint occurs when the browser renders the first piece of content from the DOM (Document Object Model). It can be text, an image, etc usually referring to something meaningful on the screen.
3. First Meaningful Paint (FMP): It refers to the point where a user can identify and understand the content that is loading. Usually includes layout changes the the font are loaded as well. FMP is depreciated.
4. Largest Contentful Paint (LCP): It measures the time it takes for the largest content element (such as an image, text block, or video) within the viewport to become fully visible and rendered on the user's screen. A webpage should have a LCP of 2.5 seconds or less.
5. Speed Index: It simply refers to how quickly the visible content of a web page is painted or rendered during the loading process. It depends on size of the viewport (mobile/desktop). Lower the score, the better it is.
Syed Sibtain
System Analyst
Sep 15, 2023
Critical Rendering Path:
The critical rendering path refers to the sequence of steps that a browser takes between getting the resources like HTML, CSS and JS and displaying a web page on a user's screen(turn them to pixels). It's crucial for web performance optimisation because it directly impacts how quickly a web page loads and becomes interactive.
The key steps involved are:
1. HTML parsing: The browser constructs the Document Object Model (DOM) tree by converting the HTML into a structured representation of the web page's content.
2. CSS parsing: The browser also parses the stylesheets and create CSS Object Model (CSSOM). The DOM and CSSOM is combined to create render tree.
3. Layout: Based on the render tree, the browser calculates the layout of each element, determining the size and position of each element, also called as reflow.
4. Paint: Finally, the browser paints pixels on the screen as per the calculated layout and it involves converting the elements into actual pixels on the screen.
The critical rendering path refers to the sequence of steps that a browser takes between getting the resources like HTML, CSS and JS and displaying a web page on a user's screen(turn them to pixels). It's crucial for web performance optimisation because it directly impacts how quickly a web page loads and becomes interactive.
The key steps involved are:
1. HTML parsing: The browser constructs the Document Object Model (DOM) tree by converting the HTML into a structured representation of the web page's content.
2. CSS parsing: The browser also parses the stylesheets and create CSS Object Model (CSSOM). The DOM and CSSOM is combined to create render tree.
3. Layout: Based on the render tree, the browser calculates the layout of each element, determining the size and position of each element, also called as reflow.
4. Paint: Finally, the browser paints pixels on the screen as per the calculated layout and it involves converting the elements into actual pixels on the screen.
Syed Sibtain
System Analyst
Sep 14, 2023
Headless UI Tab
Headless ui is providing us the Tab component were we have
1.
2.
3.
4.
Note: if we have 3 tabs in
example :
Headless ui is providing us the Tab component were we have
1.
Tab.Group is the parent its wraps all this present inside it.2.
Tab.list in tab list we have defined our tab and we have selected as active tab.3.
Tab.Panels so tabs panels is the parent of all the Tab.4.
Tab.Panel so tab panel is defined under the Tab.Panels Note: if we have 3 tabs in
Tab.list then we need to paced all 3 Tab.Panel in the same like we define tabs in Tab.Listexample :
// apply active class
key="must_pass_unique_key_1"
>
Tab Name 1
Rishav Raj
System Analyst
Sep 10, 2023
This website https://www.colorhexa.com/ is pretty good. Given a color, say #E4F6FC, it can explain the color, and also suggest a closest websafe color
Iffyuva
Aug 22, 2023
Let's say we have an api function
the
Note: we are using
const params = {
key1: "value1",
key2: "value2",
key3: ["value3", "value4"],
}
the stringified output will be - >
but backend is expecting to receive it without the index values i.e
So in order to send the parameters like that , we can just pass a stringify option called
export const getTheResults = async (params) => {
const response = await axios.get(
/api/v1/example.json?${stringify(params)}
);
return response.data;
};the
param is an object mentioned below , and we are stringifying it before sending the request to backend.Note: we are using
stringify from qs npm package.const params = {
key1: "value1",
key2: "value2",
key3: ["value3", "value4"],
}
the stringified output will be - >
key1=value1&key2=value2&key_3%5B0%5D=value3&key_3%5B1%5D=value4 i.e key1=value1&key2=value2&key_3[0]=value3&key_3[1]=value4but backend is expecting to receive it without the index values i.e
key1=value1&key2=value2&key_3[]=value3&key_3[]=value4So in order to send the parameters like that , we can just pass a stringify option called
arrayFormat: "brackets"
eg: export const getTheResults = async (params) => {
const response = await axios.get(
/api/v1/example.json?${stringify(params, {arrayFormat: "brackets"})}
);
return response.data;
};Satya
Aug 22, 2023
When using Rails strong parameters feature to permit certain parameters in controller and if any specific param has array values, we need to permit it as an array explicitly
Eg:
Request: /api/v1/calendar.json?date_from=&date_to=&hotel_id[]=1&hotel_id[]=2
def permit_params
params.permit(:date_from, :date_to, hotel_id: []) # hotel_id: [] is important
endSujay
Aug 21, 2023
When working with components that have predefined classnames but require occasional overrides based on specific use cases, it's common to encounter scenarios where developers resort to using the !important CSS rule to forcefully apply style changes. However, this approach is considered an anti-pattern as it can lead to specificity conflicts and maintenance issues down the line. A more effective solution to this problem is provided by the Tailwind Merge package, available at https://github.com/dcastil/tailwind-merge.
Sujay
Aug 21, 2023
Managing multiple variants of a component, such as different styles of buttons, can often be a challenging task, especially as the number of variants grows. Traditionally, developers have resorted to using packages like classnames to dynamically apply classes based on different conditions. However, a more streamlined and organized approach is provided by Class Variance Authority (CVA). CVA offers an elegant solution to handling multiple component variants, promoting maintainability and scalability.
One typical example is the "Button" component, which can possess various visual treatments like primary, secondary, with icons, and diverse icon placements. Instead of relying on cumbersome conditional statements and the classnames package, Class Variance Authority presents an efficient methodology through its documentation, available at https://cva.style/docs.
One typical example is the "Button" component, which can possess various visual treatments like primary, secondary, with icons, and diverse icon placements. Instead of relying on cumbersome conditional statements and the classnames package, Class Variance Authority presents an efficient methodology through its documentation, available at https://cva.style/docs.
Sujay
Aug 16, 2023
In order to disable pager in postgresql, just use this command
\pset pager off. This command is useful for seeing data from tables with huge jsonb dataIffyuva
Showing 42 to 44 of 82 results
Ready to Build Something Amazing?
Codemancers can bring your vision to life and help you achieve your goals
- Address
2nd Floor, Zee Plaza,
No. 1678, 27th Main Rd,
Sector 2, HSR Layout,
Bengaluru, Karnataka 560102 - Contact
hello@codemancers.com
+91-9731601276