code2 - کد۲
340 subscribers
146 photos
65 videos
2 files
150 links
کد۲

💻 برنامه‌نویسی، فناوری و استارتاپ


ارتباط با ادمین:
@workwithtaleghani
Download Telegram
البته GitHub خودش یه مشارکتی با اکثر شرکت های بزرگ داره که روی هر push ریپو ها رو اسکن می‌کنه. حداقل توی پژوه های پابلیک که این طوره و اگر فرضا API key اون شرکت مشخص یا یه چیز امنیتی پیدا کنه اتومات از طریق لینکی که اون شرکت فرضا open ai به گیت هاب داده توکن رو غیرفعال می‌کنه تا نشه ازش سواستفاده کرد.
این قضیه فرضا برای ارز دیجیتال هم هست خیلی ها بابت اینکه اشتباهی کلید خصوصی کیف پول ارز دیجیتالشون رو توی گیت هاب آپلود کردن ازشون سرقت شد و دائما هکر ها دارن ریپو ها رو اسکن میکنن تا یه چی پیدا کنن!
👍1
code2 - کد۲
https://blog.jetbrains.com/blog/2024/10/24/webstorm-and-rider-are-now-free-for-non-commercial-use/
خبر خوب و بد

خوب برای برنامه نویس ها که الان میتونن راحت تر به این محصول خوب jetbrain دسترسی پیدا کنند.

خبر بد برای vscode که الان دیگه رقیب اصلیش با قدرت بیشتری اومده وسط میدون. 😁

شخصا با webstorm و محصولات jetbrain راحت ترم ولی خب الان دیگه همه راحت میتونن تست کنن و دسترسی داشته باشن

https://www.jetbrains.com/webstorm/

@code2_ir
🔥1👌1
👍1👎1
هوشیار، دستیار تغذیه و سلامتی شما آماده‌ی استفاده است!
GetHooshyar.ir
🌱 با افتخار، اولین نسخه از هوشیار، دستیار سلامتی هوشمندمون، آنلاین شده و آماده‌ی استفاده است! هدف هوشیار اینه که تو مسیر سلامتی و زندگی سالم‌تر بهتون کمک کنه، از پیشنهادات غذایی گرفته تا راهکارهای ساده برای بهبود عادات روزمره. خوشحال می‌شیم اگر تجربه‌تون رو با ما به اشتراک بگذارید.
از امروز می‌تونید هوشیار رو امتحان کنید و اولین قدم رو به سوی سلامتی هوشمند بردارید! 🚀🌱

برای استفاده از هوشیار کلیک کنید 👇
GetHooshyar.ir

فیبدک یا ارتباط با تیم هوشیار: @talegh
کانال تلگرام هوشیار @getHooshyar
هوشیار دستیار سلامتی
هوشیار، دستیار تغذیه و سلامتی شما آماده‌ی استفاده است! GetHooshyar.ir 🌱 با افتخار، اولین نسخه از هوشیار، دستیار سلامتی هوشمندمون، آنلاین شده و آماده‌ی استفاده است! هدف هوشیار اینه که تو مسیر سلامتی و زندگی سالم‌تر بهتون کمک کنه، از پیشنهادات غذایی گرفته تا…
این ربات برای کمک به توجه بیشتر به بحث تغذیه و سلامتی توسط من و دوستانم ساخته شده.
ممنون میشم اگر استفاده کنید و اگر نظری داشتید بگید.
اگر به دوستان یا آشنایان هم معرفی کنید که خیلی عالی میشه.
(835498 rows affected)


@code2_ir
خیلی از اوقات داریم با یه آبجکتی توی جاوااسکریپت کار می‌کنیم و فرضا تایپ اسکریپت هم استفاده نمی‌کنیم و هی console.log می‌زنیم ببینیم توی آبجکت چیا هست.
یه کار راحت تری که میشه انجام داد اینه که یه مرتبه کل آبجکت یا اون جاهایی که میخواید رو رو صفحه نمایش بدید تا با خیال راحت نگاش کنید 😃

مثل این کد:

<pre style={{direction: 'ltr'}} >{JSON.stringify(data, null, 2)}</pre>



@code2_ir
👍2
Media is too big
VIEW IN TELEGRAM
معرفی اپلیکیشن هوشیار

هوشیار نرم افزاری است که در مورد تغذیه سالم و بهبود فعالیت بدنی با شما گفتگو می‌کنه. در ورژن جدید سعی کردیم با استفاده از حافظه بلند مدت در هوش مصنوعی یا استفاده به صورت memory augmented بتوانیم گفتگوی صمیمی تر و نزدیک تری به گفتگوی انسان داشته باشیم.
تجربه شرکت در رویداد GenX بسیار ارزشمند بود و مشوقی بود برای علاقه بیشتر به هوش مصنوعی و تمرینی برای توسعه بهتر پروتوتایپ ایده‌های کسب و کار.

GetHooshyar.ir

@code2_ir
👌2
خدا رحمت کنه صابر راستی‌کردار رو.
چه خدمتی کرد به مردم.
خدا جد و آبادش رو بیامرزه.
13
یه قابلیت خوبی که توی کروم و brave هست و من تازه پیداش کردم اینه که می‌تونید کل یک تب رو به یکباره bookmark کنید. برای افرادی مثل من میتونه خوب باشه :) که هزار تا تب باز می‌کنم و بعد هم می‌ترسم که بعدا این ها رو گم کنم یا به هوای این که یه روزی میخونمشون همه رو باز نگه می‌دارم! یوهو بعد سه چهار روز می‌بینیم ۵ تا ویندوز باز کردم رو هر کدوم فلان قدر تب باز کردم 😅

@code2_ir
👍1👎1🤣1
لیستی از بهترین ابزارهای هوش مصنوعی ۲۰۲۴

https://hamrah.academy/blog/ai-tools/



@code2_ir
امان از این nextjs
بچه‌ی زرنگ اما بازیگوش!
In a Next.js app router project, data can be fetched in multiple places depending on the nature of the data, rendering strategy, and whether the data needs to be accessed at build time, on the server, or on the client. Here’s a breakdown of where to fetch data in Next.js’s app router and when each is appropriate:

### 1. Server Components (default in app directory)
- Where: Fetch data directly within server components, like your page.tsx or other components under the app directory.
- When: Ideal for server-only data, sensitive data, or data that doesn’t need client-side interactivity. Server components can fetch data using async functions and make use of server-only packages (e.g., databases).
- Example:
     import { PrismaClient } from "@prisma/client";

export default async function Page() {
const prisma = new PrismaClient();
const data = await prisma.someModel.findMany();

return (
<div>
{/* Render data */}
</div>
);
}

- Considerations: Server components do not increase the JavaScript sent to the client. However, since they are server-rendered, you may need additional client-side components if you want interactivity.

### 2. Client Components (use use client directive)
- Where: If you need client-side interactivity, mark the component with use client at the top and use data-fetching hooks like useEffect.
- When: Useful for data that requires client-side interactivity, like managing local state, dynamic data fetching (especially based on user interactions), or when using APIs that are only available on the client.
- Example:
     "use client";
import { useState, useEffect } from 'react';

export default function ClientComponent() {
const [data, setData] = useState(null);

useEffect(() => {
async function fetchData() {
const response = await fetch('/api/data');
const result = await response.json();
setData(result);
}
fetchData();
}, []);

return <div>{data ? JSON.stringify(data) : 'Loading...'}</div>;
}

- Considerations: Client components increase the JavaScript bundle size sent to the client, so they should be used when necessary.

### 3. API Routes
- Where: Use pages/api to create backend API endpoints, which can be called from both server and client components.
- When: Use API routes when you want to keep logic (like authentication, session checks, or data manipulation) separate from the component. This is especially useful for POST requests, sensitive data handling, or operations that don’t need to be part of the server-rendering flow.
- Example:
     // pages/api/data.ts
import { NextApiRequest, NextApiResponse } from 'next';
import { PrismaClient } from '@prisma/client';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const prisma = new PrismaClient();
const data = await prisma.someModel.findMany();
res.status(200).json(data);
}

- Considerations: API routes offer more flexibility and can be used by both server and client components, which is useful for actions like form submissions or fetching data on demand.
### 4. Middleware (for authentication and access control)
- Where: Use a middleware.ts file in the root directory.
- When: Middleware is useful for route-based logic, like authentication or role-based access control, without directly fetching data for rendering. Middleware runs on the edge and can redirect users based on conditions.
- Example:
     // middleware.ts
import { NextResponse } from 'next/server';

export async function middleware(request) {
const isAuthenticated = checkAuth(request); // Define your own check
if (!isAuthenticated) return NextResponse.redirect(new URL('/login', request.url));
return NextResponse.next();
}

export const config = {
matcher: '/protected/:path*', // Apply to specific routes
};

- Considerations: Middleware is limited in functionality compared to traditional API routes but is highly efficient for edge-based logic.

### 5. Static Fetching (using generateStaticParams for Static Site Generation)
- Where: If the data doesn’t change often and you don’t need real-time updates, use static generation with generateStaticParams or getStaticProps in the app directory.
- When: For data that doesn’t change frequently (e.g., blog posts, product pages) or when optimizing for SEO by generating pages at build time.
- Example:
     import { PrismaClient } from '@prisma/client';

export async function generateStaticParams() {
const prisma = new PrismaClient();
const items = await prisma.someModel.findMany();
return items.map(item => ({ id: item.id }));
}


### Summary
- Use Server Components by default for data fetching when rendering on the server.
- Use Client Components for client-side interactions or dynamic data that changes after initial render.
- Use API Routes for encapsulating backend logic or for requests initiated on the client-side.
- Use Middleware for lightweight route protection or conditionally redirecting users.
- Use Static Fetching for rarely changing content that benefits from static generation (like blog posts).

Each strategy is flexible, and you can mix these approaches depending on the needs of each part of your app.
😁3