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.
Aug 22, 2025
Next.js Typed Routes
Next.js now provides TypeScript support for route parameters and navigation, helping catch routing errors at compile time rather than runtime.
Next.js automatically generates route types based on our file structure in the
For example, if we have:
The generated types will understand routes like
#nextjs #typescript
Next.js now provides TypeScript support for route parameters and navigation, helping catch routing errors at compile time rather than runtime.
Next.js automatically generates route types based on our file structure in the
app directory.For example, if we have:
app/
users/
[id]/
page.tsx
posts/
[slug]/
page.tsxThe generated types will understand routes like
/users/123 and /posts/my-post-slug.
import { useRouter } from 'next/navigation'
import Link from 'next/link'
// TypeScript knows about our routes
const router = useRouter()
router.push('/users/123') // ✅ Valid
router.push('/invalid-route') // ❌ TypeScript error
// Link component is also typed
<Link href="/posts/my-slug">My Post</Link> // ✅ Valid
<Link href="/wrong-path">Invalid</Link> // ❌ TypeScript error#nextjs #typescript
Ashwani Kumar Jha
Senior System Analyst
Jul 30, 2025
How LLM's temperature affects AI output:
LLM models use a parameter called
Tip: Use lower temperatures when you need reliable, consistent responses, and higher temperatures for creative or exploratory tasks.
#llm
LLM models use a parameter called
temperature to control randomness in generated responses.temperature: 0 → deterministic output (same input = same output)temperature: 1 → default setting, balanced creativitytemperature > 1 → more random, creative, but less reliableTip: Use lower temperatures when you need reliable, consistent responses, and higher temperatures for creative or exploratory tasks.
#llm
Adithya Hebbar
System Analyst
Jul 23, 2025
Traits in FactoryBot allow you to define reusable pieces of attributes that can be mixed into factories to create variations of objects without duplicating code.
Here,
You can pass traits to
#CU6U0R822 #RSpec
FactoryBot.define do
factory :user do
name { "John Doe" }
trait :admin do
role { "admin" }
end
end
end
create(:user, :admin)Here,
:admin is a trait that overrides or adds attributes (role: "admin").You can pass traits to
create, build, or attributes_for to easily generate variations.#CU6U0R822 #RSpec
Mohammad hussain
System Analyst
Jul 15, 2025
Boost Query Performance with Prisma's Rust-free Engine(v6.7.0+)
Why?
• Quick Setup
• Faster queries
• 85–90% bundle size reduce
• Smoother & Better DX
Setup Steps :
1. Update Your
2. Re-Generate Prisma Client
3. Install Driver Adapter
• For Postgres:
• For other DBs: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine#3-install-the-driver-adapter|Prisma Adapter Docs
4. Instantiate Prisma Client
• For Postgres:
• For other DBs: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine#4-instantiate-prisma-client|Prisma Client Docs
5. All done!🎉 Now your can query as usual.
🔗 https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine|Official Rust-free Prisma Docs
Why?
• Quick Setup
• Faster queries
• 85–90% bundle size reduce
• Smoother & Better DX
Setup Steps :
1. Update Your
schema.prisma
generator client {
provider = "prisma-client-js" // or `prisma-client`
previewFeatures = ["queryCompiler", "driverAdapters"]
output = "../generated/prisma"
}2. Re-Generate Prisma Client
npx prisma generate3. Install Driver Adapter
• For Postgres:
npm install @prisma/adapter-pg• For other DBs: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine#3-install-the-driver-adapter|Prisma Adapter Docs
4. Instantiate Prisma Client
• For Postgres:
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from './generated/prisma'
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })• For other DBs: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine#4-instantiate-prisma-client|Prisma Client Docs
5. All done!🎉 Now your can query as usual.
🔗 https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine|Official Rust-free Prisma Docs
Swasthik K
Jul 8, 2025
Picture-in-Picture (PiP) API – Enabling Floating Video Playback
The Picture-in-Picture (PiP) API enables developers to present an HTML
How to use it (basic example):
Key Concepts
•
•
•
• Associated Events:
◦
◦
⚠️ Limitations
• Only applicable to native
• Most browsers require the video to be playing before entering PiP.
• Must be triggered through a user gesture (e.g., a click).
• Safari has limited support and relies on its own implementation.
🌐 Browser Support
• Chrome
• Edge
• Opera
• Firefox (with some restrictions)
#CCT1JMA0Z
The Picture-in-Picture (PiP) API enables developers to present an HTML
<video> element in a small, floating, always-on-top window. This allows users to continue watching a video while interacting with other applications or browser tabs.How to use it (basic example):
html
<video id="myVideo" src="video.mp4" controls></video>
<button id="pipButton">Enter PiP</button>
js
const video = document.getElementById('myVideo');
const button = document.getElementById('pipButton');
button.addEventListener('click', async () => {
try {
if (document.pictureInPictureElement) {
await document.exitPictureInPicture();
} else {
await video.requestPictureInPicture();
}
} catch (err) {
console.error(`Failed to toggle PiP: ${err}`);
}
});Key Concepts
•
video.requestPictureInPicture(): Initiates PiP mode for the video element.•
document.exitPictureInPicture() : Exits PiP mode.•
document.pictureInPictureElement : Returns the element currently in PiP, or null.• Associated Events:
◦
enterpictureinpicture◦
leavepictureinpicture
video.addEventListener('enterpictureinpicture', () => {
console.log('Video entered PiP mode');
});
video.addEventListener('leavepictureinpicture', () => {
console.log('Video left PiP mode');
});⚠️ Limitations
• Only applicable to native
<video> elements.• Most browsers require the video to be playing before entering PiP.
• Must be triggered through a user gesture (e.g., a click).
• Safari has limited support and relies on its own implementation.
🌐 Browser Support
• Chrome
• Edge
• Opera
• Firefox (with some restrictions)
#CCT1JMA0Z
Sudeep Hipparge
Jul 2, 2025
File Preview in React — Beyond Just Images
Building a file preview system in React can surface several helpful patterns — especially when working with images, PDFs, media, and plain text files.
• You can preview any local file before upload using:
It works seamlessly with:
• Images
• PDFs
• Audio files
• Videos
• Plain text
Tip: Always call
🔄 Handling Local and Server Files Together
To support previews for both uploaded and already-stored files, use a union type:
Then render conditionally based on
•
•
•
#CCT1JMA0Z #react
Building a file preview system in React can surface several helpful patterns — especially when working with images, PDFs, media, and plain text files.
• You can preview any local file before upload using:
URL.createObjectURL(file)It works seamlessly with:
• Images
• PDFs
• Audio files
• Videos
• Plain text
Tip: Always call
URL.revokeObjectURL() when the preview is no longer needed to prevent memory leaks.🔄 Handling Local and Server Files Together
To support previews for both uploaded and already-stored files, use a union type:
// Local preview
{ isLocal: true, file: File }
// Server-hosted file
{ url: '/api/files/:id', name: string, type: string }Then render conditionally based on
file.type. Rendering Previews Based on File Type•
<img> → for images•
<iframe> → for PDFs or text files•
<audio> / <video> → for media files#CCT1JMA0Z #react
Sudeep Hipparge
Jun 30, 2025
📌 Using Alpine.js in Rails to Toggle Content Efficiently
You can use Alpine.js in a Rails app to handle simple UI interactions like showing, hiding, or toggling content — with zero overhead and great maintainability.
🧠 How it works:
• Alpine adds lightweight reactivity directly in your HTML using attributes like
• Clicking a button updates the
• Alpine automatically re-evaluates all
• It then updates the UI by toggling styles like
• On clicking the "Urgent" button, Alpine applies
💡 Example in Rails ERB:
• Both partials are rendered server-side on initial load
• Alpine just toggles their visibility using CSS (e.g.,
• No data loss or performance bottleneck — ideal for UI tab switching or inline modals
✅ Why it's great:
• No page reloads or re-renders
• No JavaScript DOM manipulation — just CSS toggling
• Preserves state and DOM structure
• Ideal for tabs, modals, section toggles, and lightweight UI
#Rails #Alphine.js
You can use Alpine.js in a Rails app to handle simple UI interactions like showing, hiding, or toggling content — with zero overhead and great maintainability.
🧠 How it works:
• Alpine adds lightweight reactivity directly in your HTML using attributes like
x-data, @click, and x-show.• Clicking a button updates the
type (or any reactive) value.• Alpine automatically re-evaluates all
x-show (and related) bindings when that reactive value changes.• It then updates the UI by toggling styles like
display: none, not by re-rendering or manipulating the DOM.• On clicking the "Urgent" button, Alpine applies
display: none to the normal_partial and removes it from urgent_partial, effectively toggling visibility between the two.💡 Example in Rails ERB:
<div x-data="{ type: 'normal' }">
<button @click="type = 'normal'">Normal</button>
<button @click="type = 'urgent'">Urgent</button>
<div x-show="type === 'normal'">
<%= render "normal_partial" %>
</div>
<div x-show="type === 'urgent'">
<%= render "urgent_partial" %>
</div>
</div>• Both partials are rendered server-side on initial load
• Alpine just toggles their visibility using CSS (e.g.,
display: none), it wont manipulate DOM.• No data loss or performance bottleneck — ideal for UI tab switching or inline modals
✅ Why it's great:
• No page reloads or re-renders
• No JavaScript DOM manipulation — just CSS toggling
• Preserves state and DOM structure
• Ideal for tabs, modals, section toggles, and lightweight UI
#Rails #Alphine.js
Nitturu Baba
System Analyst
Jun 25, 2025
Creating Google Calendar Events with NestJS
Integrating Google Calendar event creation in a NestJS backend can be done seamlessly using the
Key Steps:
• Set up OAuth2 with access and refresh tokens.
• Use
• Always include the
Sample code:
Common Pitfalls:
• Incorrect scopes → leads to permission denied errors.
• Missing
• Expired tokens → results in 401 Unauthorized errors.
#NestJS
Integrating Google Calendar event creation in a NestJS backend can be done seamlessly using the
googleapis package.Key Steps:
• Set up OAuth2 with access and refresh tokens.
• Use
calendar.events.insert() to create events.• Always include the
timeZone field to ensure accurate scheduling.Sample code:
const event = {
summary: 'Team Sync',
start: { dateTime: '2025-06-26T10:00:00+05:30', timeZone: 'Asia/Kolkata' },
end: { dateTime: '2025-06-26T11:00:00+05:30', timeZone: 'Asia/Kolkata' },
};
await calendar.events.insert({
calendarId: 'primary',
requestBody: event,
});Common Pitfalls:
• Incorrect scopes → leads to permission denied errors.
• Missing
timeZone → causes unexpected event timings.• Expired tokens → results in 401 Unauthorized errors.
#NestJS
Sudeep Hipparge
Jun 20, 2025
Understanding
Today I learned how
While building a custom
Why It Matters:
•
• You can switch between different transport layers (HTTP, RPC, WebSockets) using methods like
• It's essential for building dynamic and context-aware logic in guards, interceptors, and decorators.
Pro Tip:
Use
#CCT1JMA0Z #NestJS
ExecutionContext in NestJS GuardsToday I learned how
ExecutionContext works in NestJS — it's a powerful tool for accessing low-level request details within Guards, Interceptors, and Custom Decorators.While building a custom
AuthGuard, I used ExecutionContext to extract the request object and retrieve the authenticated user like so:
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
@Injectable()
export class AuthGuard implements CanActivate {
canActivate(context: ExecutionContext): boolean {
const request = context.switchToHttp().getRequest();
const user = request.user;
return !!user; // or apply custom authorization logic
}
}Why It Matters:
•
ExecutionContext wraps the current request lifecycle and gives you flexible access to request-specific information.• You can switch between different transport layers (HTTP, RPC, WebSockets) using methods like
switchToHttp(), switchToRpc(), etc.• It's essential for building dynamic and context-aware logic in guards, interceptors, and decorators.
Pro Tip:
Use
context.getClass() and context.getHandler() to access metadata about the controller and handler being executed — especially useful for implementing role-based access control or custom permission systems.#CCT1JMA0Z #NestJS
Sudeep Hipparge
Jun 19, 2025
the term
In simple terms we can understand it as refubrished items where later the warehouse can send that to a buyer and then the buyer decide which store to sell these items in a discounted price.
#warehouse #outbound
Cannibalization in warehouse terms meaning taking components or parts from one unit (often damaged, unused, or scrapped) to use in repairing or completing another unit.In simple terms we can understand it as refubrished items where later the warehouse can send that to a buyer and then the buyer decide which store to sell these items in a discounted price.
#warehouse #outbound
Satya
Showing 3 to 5 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