en
Feedback
Hayitbek Yusupov - IT Blog

Hayitbek Yusupov - IT Blog

Open in Telegram
Buy Ad
56
Subscribers
No data24 hours
-27 days
-330 days
Posts Archive
https://github.com/tc39/proposal-structs Ushbu proposal javascriptda ham structlar va unsafe kalit so'zi uchun support qo'shish bilan bog'liq. Balki javascriptga yangi nom o'ylab toparmiza? Ruscript? Bu kunlarni ko'raman deb o'ylamagandim :)

Typescript shunchaki type definitionlar yozish emasligiga yana bir zo'r misol bu Tanstack Router. Side projectlarimda maza qilib ishlatyapman, ayniqsa type-safe file based routing qo'shilgandan keyin yana ham ishlatish oson bo'ldi https://www.youtube.com/watch?v=VlCxEjxprKg

Oxirgi 3-4 soatni Tauri appni qanday qilib cross compile qilishni qidirish bilan o'tkazdim. Eng yomon odatlarimdan biri shu, bir narsa o'xshamasa ustida 3-4 soat qolib ketaman. Lekin bu galgisi paid off. Cross platform uchun appimage build qilishga qaror qildim, boshqacha yo'li ham yo'q edi menimcha. Lekin appimageni hech build qilolmayotgandim:
pnpm tauri build
Build qilganimda quyidagi xatolik chiqaverdi:
Error failed to bundle project: error running build_appimage.sh
Shu issue orqali Tauri appni quyidagicha build qilib ko'rdim va muammosiz ishladi:
NO_STRIP=true pnpm tauri build
Lekin... generate qilingan appimage ning hajmi 239 MB. Endi ertaga unga ham biron yechim topish kerak. Afsuski Tauri hozirda Linux uchun deyarli faqat Debian based distrolarga supporti bor ekan. Lekin taslim bo'lmaymiz @khaitbekdev

import type { ComponentPropsWithoutRef, ElementType } from "react";

// helpers
import { cn } from "shared/lib/helpers/classNames";

type LimitedTextProps<As extends ElementType = "div"> = {
    as?: As
} & ComponentPropsWithoutRef<As>

export const LimitedText = <As extends ElementType = "div">({ className, ...props }: LimitedTextProps<As>) => {
    return (
        <div
            className={cn(
                "max-w-[20ch] overflow-hidden overflow-ellipsis whitespace-nowrap",
                className
            )}
            {...props}
        />

    )
}
A polymorphic React component that can be used when you need to limit text to one line. The component is fully customizable & can be rendered as any html element via props @khaitbekdev

https://github.com/zed-industries/zed/pull/18453 Vanihoyat Zed snippetlar uchun supportni qo'shdi πŸŽ‰

Trying to cook a desktop app using Tauri: https://github.com/khaitbek/tauri-todo-app The reason I am doing this is I had a conversation with a colleague of mine & he said that one of the projects needed a notification service (desktop app). He said it should be cross-platform. So, as I have been jonesing to try Rust in a real world project, I believe this is my chance. The stack I am using: Frontend - React, Typescript, Tanstack Router, Tanstack Query, Zustand Backend - Rust DB - Planning to use PostgreSQL using the SQL plugin of Tauri @khaitbekdev

Meta fined 91 million euros for storing passwords in plain text - https://thehackernews.com/2024/09/meta-fined-91-million-for-storing.htvvml Google's migration to Rust has finally paid off - https://thehackernews.com/2024/09/googles-shift-to-rust-programming-cuts.html @khaitbekdev

So'nggi kunlarda NestJSni oz-moz o'rganib yurgan edim. O'rganganda ham iloji boricha clean architecturega amal qilib loyiha strukturasini tuzishni o'rganayotgan edim. Qo'shimchasiga, nestjs/swagger package bilan ishlashni o'rganyabman Lekin bir muammoga duch keldim. Validation uchun zod packageni ishlatyabman. Manga validation bilan birga dto lar ham kerak bo'ladi, zodni o'zini dto sifatida ishlata olmayman. Muammo shundaki, birorta zod schema yaratsam, xuddi shunday propertylar bilan dto class ham yasashim kerak bo'lib qoldi. Masalan:
export const signUpSchema = z.object({
  username: z.string().min(3).max(20),
  firstName: z.string().min(3).max(20).optional(),
  lastName: z.string().min(3).max(20).optional(),
  password: z.string().min(3).max(20),
  email: z.string().email(),
});

export class SignUpDto {
  @ApiProperty({
    title: "Username",
    example: "john",
    required: true,
  })
  username: string;

  @ApiProperty({
    title: "Email",
    example: "john@gmail.com",
  })
  email: string;

  @ApiProperty({
    title: "First name",
    example: "John",
  })
  firstName: string;

  @ApiProperty({
    title: "Last name",
    example: "Doe",
  })
  lastName: string;

  @ApiProperty({
    title: "Password",
    minLength: 8,
    maxLength: 32,
  })
  password: string;
}
Ko'rib turganingizdek, bir xil kodni qayta-qayta yozishga to'g'ri keladi. Bugun ertalabdan bir packagega ko'zim tushdi va ishlatib ko'rdim:
import { createZodDto } from "@anatine/zod-nestjs";
import { extendApi } from "@anatine/zod-openapi";
import { z } from "zod";

export const signUpSchema = extendApi(
  z.object({
    username: z.string().min(3).max(20),
    firstName: z.string().min(3).max(20).optional(),
    lastName: z.string().min(3).max(20).optional(),
    password: z.string().min(3).max(20),
    email: z.string().email(),
    birthDate: z.string().optional(),
  }),
{
    title: "sign up",
    description: "sign up",
}
);

export class CreateUserDto extends createZodDto(signUpSchema) {}
Ko'rib turganingizdek, bu package zod schemani dto classga o'girib beradi @khaitbekdev

sticker.webp0.18 KB

Rust loyihalarni cross-qurilmalarga kompilyatsiya qilish - https://github.com/rust-cross/cargo-zigbuild Kompilatsiyadan so'ng, zip fayl yaratasiz:
tar -czvf package-name.tar.gz package-name
Diqqat: Bu instruksiyalar faqat Linux/MacOS da ishlashiga kafolat bor Keyin esa zip faylni Github Releases ga joylashingiz mumkin. Hayotni osonlashtirish uchun Github Actionsdan foydalansangiz bo'ladi Keyin esa, foydalanuvchilarni hayotini osonlashtirish uchun homebrew, snap, chocolatey kabi package managerlarga publish qilishingiz mumkin @khaitbekdev

Voice message00:14

Voice message00:11

Total platitude & a huge lie

Today I learned Pipes in NestJS - https://docs.nestjs.com/pipes @khaitbekdev