id
int64
5
1.93M
title
stringlengths
0
128
description
stringlengths
0
25.5k
collection_id
int64
0
28.1k
published_timestamp
timestamp[s]
canonical_url
stringlengths
14
581
tag_list
stringlengths
0
120
body_markdown
stringlengths
0
716k
user_username
stringlengths
2
30
1,925,897
Debugging JavaScript: Tools and Techniques
Welcome back to our series, "JavaScript: From Novice to Expert!" Our last article introduced the...
27,941
2024-07-16T19:47:19
https://dev.to/buildwebcrumbs/debugging-javascript-tools-and-techniques-2i4b
javascript, beginners, programming, webdev
Welcome back to our series, "JavaScript: From Novice to Expert!" Our last article introduced the fundamentals of JavaScript Syntax and Structure and today, we are going to learn about an essential skill every developer must learn to be a successful dev —debugging. Debugging can be a bit scary at first, but with the right tools and techniques, it becomes a powerful part of your development process, helping you find bugs in your way. **Let's dive into how we can identify and fix errors to make sure our JavaScript code runs the way we want it too.** --- ## **1. Understanding Common JavaScript Errors** As we code, we are bound to run into errors, and sometimes they can even be your friends!. Here are the most common types: - **Syntax Errors:** These occur when there's a mistake in the use of the language itself, like a typo or missing bracket. Ex. You comst instead of const. - **Runtime Errors:** These happen during execution, such as trying to call a function that doesn’t exist. - **Logical Errors:** Perhaps the trickiest, these are errors where the code does not act as expected or intended, but the syntax is okay, and the code is running. --- ## **2. Browser Developer Tools** In JavaScript a big part of debugging involves using your browser’s developer tools . Here’s how: - **Console:** The console is super helpful for testing quick expressions or checking the values of variables at various stages of execution. - **Debugger:** Use the debugger to set breakpoints, which allow you to pause execution and inspect the state of your application at various points. - **Network Tab:** This tool helps you monitor and debug issues related to network operations, essential for understanding AJAX requests and API interactions. --- ## **3. Debugging Techniques** Now let us explore some techniques that can simplify the debugging process: - **Console.log():** Simple yet effective, logging allows you to output variable values to the console, providing insight into the state of your application. When I started coding I had a console.log() every other line 🤣 - **Using breakpoints:** Set breakpoints in the source code view of your developer tools; this lets you pause execution and examine the values of variables step-by-step, until you find where the bug is. - **Step-by-step Execution:** Learn to step through your code one line at a time using the step over, step into, and step out functionalities of the debugger. --- ## **4. Handling Exceptions** Properly handling exceptions can prevent your JavaScript applications from crashing: - **Try...Catch:** Use try...catch blocks to manage errors gracefully, allowing you to handle exceptions and continue execution. ``` JavaScript function checkUsername(username) { try { if (username.length < 10) { throw new Error("Username must be at least 4 characters long."); } console.log("Username is valid."); } catch (error) { console.error("Error:", error.message); } } checkUsername("happycat"); // This will throw and catch an error: "Username must be at least 4 characters long." checkUsername("happykittycat"); // This will print: "Username is valid." ``` 🐈‍⬛ - **Throwing Errors:** Sometimes you may need to throw custom errors when something goes wrong, helping maintain control flow and providing clear error messages to users. ```JavaScript function calculateAge(birthYear) { try { let age = new Date().getFullYear() - birthYear; if (age < 0) { throw new Error("Birth year cannot be in the future."); } console.log("Your age is:", age); } catch (error) { console.error("Error:", error.message); } } calculateAge(2025); // This will throw and catch an error: "Birth year cannot be in the future." calculateAge(1991); // This will print: "Your age is: 33" (as of 2024) ``` --- ## Another step done ✅ We have covered the essentials of debugging JavaScript, which will help you write more reliable and error-free code. Remember, debugging is not just about fixing bugs—it’s about understanding your code better and ensuring it performs well under various conditions. ! ## Let's build together? We at [Webcrumbs](https://www.webcrumbs.org/) are hard at work building an innovative Open Source plugin ecosystem designed to integrate seamlessly with any JavaScript framework. If you're excited about building a better web and the tools we are developing, show your support by giving us a star on our [GitHub repository](https://github.com/webcrumbs-community/webcrumbs). Thanks for reading! Pachi 🥑
pachicodes
1,925,898
Postman Api 101 #postmanstudent
The program featured: Comprehensive Modules: From API basics to advanced Postman techniques. Live...
0
2024-07-16T19:47:54
https://dev.to/mohanraj1234/postman-api-101-postmanstudent-37n1
The program featured: Comprehensive Modules: From API basics to advanced Postman techniques. Live Expert Sessions: Direct insights and advice from MK Veerendra Vamshi. Collaborative Projects: Real-world applications and teamwork experiences. Skills Gained API Mastery: Designing, testing, and documenting APIs with ease. Problem-Solving: Sharpened troubleshooting abilities. Effective Communication: Clear explanation of technical concepts to varied audiences. Community Impact Forming connections with peers and receiving guidance from mentors like MK Veerendra Vamshi enriched the experience.
mohanraj1234
1,925,899
3 Chrome Extensions to Boost Your Productivity (Plus a Bonus!)
Hello Devs!, We all know how important it is to stay productive at work. The most efficient people...
0
2024-07-16T19:48:19
https://dev.to/ronakkhunt/3-chrome-extensions-to-boost-your-productivity-plus-a-bonus-3f1f
productivity, extensions, browser, shorturl
Hello Devs!, We all know how important it is to stay productive at work. > The most efficient people aren't necessary brilliant, they've just found the right tools Chrome extensions can be real game-changers when it comes to productivity. Here are three must-have Chrome extensions that can help you streamline your tasks and save valuable time. 1. [StayFocusd](https://chromewebstore.google.com/detail/stayfocusd-block-distract/laankejkbhbdhmipfmgcngdelahlfoji) StayFocusd helps you stay focused on your work by restricting the amount of time you can spend on time-wasting websites. You can block specific sites or entire categories, ensuring you stay productive throughout the day. 2. [OneTab](https://chromewebstore.google.com/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall) If you have countless tabs open at once. OneTab converts all your tabs into a single list, reducing memory usage and clutter. You can restore tabs individually or all at once, making it easier to manage your browsing session. 3. [Dark Reader](https://chromewebstore.google.com/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh) Working long hours in front of a screen can strain your eyes. Dark Reader helps reduce eye strain by turning on dark mode for every website. Customize brightness, contrast, and other settings to create a comfortable browsing experience, especially during late-night coding sessions. Bonus: [SimpleURL](https://chromewebstore.google.com/detail/simpleurl-search-bookmark/fgfagloedegjakmfijkhpiknbdcbodhj) ![SimpleURL: URL Shortner & Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qnx9pupidtjn10gf8rv9.png) As a bonus, I wanted to introduce you to SimpleURL, a tool I designed to streamline your URL management. SimpleURL allows you to create easy-to-remember personal Short URLs, organize them efficiently, and access them easily. It's especially handy for developers who deal with numerous links and resources daily. Try these extensions and see how they can make your development process smoother and more efficient. **Do you have any other productivity-boosting Chrome extensions you love? Share them in the comments!** Happy coding!
ronakkhunt
1,926,805
News | Bollywood Movies | Hindi Serials | APNE TV
These days, finding a comfortable and enjoyable space to unwind in after a long day of hectic...
0
2024-07-17T13:52:25
https://dev.to/apnetv/news-bollywood-movies-hindi-serials-apne-tv-42h9
These days, finding a comfortable and enjoyable space to unwind in after a long day of hectic activity has become crucial thanks to entertainment. It has always been a component of human culture and society, both in the past and now. Everyone enjoys watching their favorite television programs, films, and series, regardless of age. We have taken into consideration your concerns and launched a single [APNE TV](https://apnetvv.com/) platform for users. Let us clarify what we mean. Our platform offers entertainment for all tastes, not just a selection of well-known serials. This portal caters to those who enjoy watching movies, web series, reality shows, Bollywood dramas and serials, and trending news. Additionally, this channel features some well-known Hollywood and Lollywood entertainment content. **Highlighted Articles** Discover a wide range of your preferred channels on APNE TV, such as Colors TV, Star Plus, Sony TV, Star Bharat, Zee TV, Life OK, and more. These are more than sufficient; have a look at our category area for an excellent assortment. These networks are undoubtedly popular right now, and viewers enjoy watching their favorite serials, but occasionally it can be challenging to locate episodes online. Fear not, we have you everything covered, and we consistently provide our audience with the greatest entertainment. We offer show scripts and videos so that fans may learn everything there is to know about their favorite programs. Watching popular TV shows, films, and serials all in one location isn't it great? Of course it is, and for that reason APNE TV has millions of viewers. Rather than all of this, this website gives users viewer ratings on dramas, making it simple for them to determine whether or not to watch. Speaking of the serial video clips, we consistently offer viewers visually appealing content that draws them to our channel. Additionally, there are HD-quality episodes available in order so you won't miss any of them. **Coverage of APNE TV** This channel's other advantages include giving viewers access to the show exactly as it is and covering every facet of the serial. Videos with the same excellent material are available. Put simply, this is the one-stop entertainment destination you've been searching for. In addition, APNE TV offers Bollywood news and Trending TV so you can always be updated on the goings-on in the life of your favorite celebrities. Take a look at one of the most fascinating articles and amuse your family and friends. **New Bollywood Films** Are you trying to find an excellent place to watch the newest Bollywood films? Without a doubt, Movies APNE is the best location for your issue. Whatever your genre preference, ZEE5 offers a vast selection of New Free Hindi Movies, Desi Movies, and Latest New Hindi Movies. It becomes challenging to determine which of the many movie websites is providing appropriate and excellent content for no cost. Free websites that don't require users to make in-app purchases are generally preferred by users, and APNE TV is your reliable movie companion. In addition to assisting you in finding the desired movie quickly, it will also display similar films. Additionally, you can look through films according to popular, recent, and genre categories. **Hindi serials and Indian dramas** APNE TV is available to provide you with the latest information on your dramas and Hindi serials. We have a wide variety of serials to choose from, covering comedy, romance, horror, thrillers, emotional stories, and more. Occasionally, viewers of live streaming dramas miss their shows, and it seems pointless to watch the subsequent episode after missing the previous one. Don't worry at all; we've listed every episode in a clear and concise manner so that viewers won't miss a second of their beloved series. **Free Web Series in Hindi** This APNE TV has also taken into consideration the concerns of all series fans who enjoy watching and learning about their favorite stars and actresses from Hindi television. No one can dispute the rise in popularity of Hindi web series in recent years, nor the fact that their tales are superior and rife with humor. Web series fans can choose from a variety of programs in our dedicated section, including Rocket Boys, Aashiqana, Flames, Delhi Crime, Family Man, Class, Aranyak, and many more. This channel contains content for everyone, regardless of whether you enjoy crime or comedic television shows. Another feature that will appeal to you about this platform is how quickly new episodes and seasons are released; this channel offers them before any other platform. **Game Shows and Reality Shows** Some individuals enjoy watching game shows or reality series like Bigg Boss, Roadies, Kaun Banega Crorepati, and so on, and they never miss one episode. Thus, this channel will assist you in covering all of the show-related updates. It will include every single detail of your favorite show, such as who is winning, who is now leading, who was eliminated, and who is dominating the play. Put simply, it won't allow you to miss even the smallest detail about the stars and series you love. **Interviews and Talk Shows** Popular Hindi chat shows like The Kapil Sharma Show, Koffee with Karan, Comedy Nights with Kapil, Desi Vibes with Shehnaaz Gill, etc. are favorites not only among Indians but also among people in other nations. Star actors and actresses discuss a variety of topics in these shows, including their lifestyles, ongoing and forthcoming projects, and much more. Hosts respond to public requests by asking these kinds of questions since people are naturally fascinated about the entertainment, married life, family life, and other aspects of the lives of their favorite celebrities. The shows of Karan Johar, Shehnaz Gill, and Kapil Sharma are popular right now, with millions of people watching their content.
apnetv
1,925,900
Create perfect anime characters with GPT-4o and SDXL
GPT-4o writes character details and text-to-image prompts. SDXL generates images. AI Agent...
0
2024-07-16T19:49:47
https://dev.to/appbaza/create-perfect-anime-characters-with-gpt-4o-and-sdxl-5a36
sdxl, chatgpt, aiagent, ai
GPT-4o writes character details and text-to-image prompts. SDXL generates images. ## AI Agent Flow The initial prompt is as simple as this: “Generate a random anime character. You can pick any topic. Write a background story specific to the character, including mood, physical appearance, and superpowers.” Then we chain it using [http://aiflowly.com](http://aiflowly.com): ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3bpom45hnvlf0dib2o0b.png) ## Character Details and Specifications The first four GPT-4o will generate different AI characters. Their system image is as follows: > “Write a detailed specification for an anime character.” **An example output (long text):** “Character Specification: Aiko Takahashi — The Elemental Guardian Background Story: In a small, ancient village nestled within the untamed forests of Japan, there exists a legend of a powerful guardian who wields the elemental forces of nature to protect the world from dark entities. That guardian is Aiko Takahashi, a seemingly ordinary 16-year-old high school student, living a dual life between modern convenience and ancient duty. Born into a lineage of elemental guardians, Aiko was trained from a young age by her grandmother, the previous guardian. Her village, isolated from the hustle and bustle of the cities, preserved a strong connection to nature and its mystical energies. Aiko’s life was a blend of rigorous training sessions and typical teenage experiences, although she felt the weight of her responsibility constantly tugging at her. Aiko’s peaceful village life was disrupted when she turned 15, and the balance of nature began to falter due to a resurgence of dark forces. The once-understood mantle was passed down to her, and she became the chief protector against these malevolent supernatural beings threatening not just her village, but the entire world. Mood: The mood surrounding Aiko Takahashi is a mix of serene nature harmonies and looming tension. Her story oscillates between the tranquil beauty of her village’s lush forests and the intense battles against dark forces. The ambiance often shifts from the comforting, warm lights of traditional paper lanterns to the eerie, suspenseful darkness of encroaching night. Aiko is a hopeful yet burdened character, struggling with the balance between her personal desires and her duty. This duality flavors her story with both light-hearted moments of teenage life and the somber, weighty responsibilities she carries as a guardian. Physical Appearance: Aiko Takahashi embodies the ethereal beauty and intensity of a hero tied to nature. Here are the details of her appearance: Hair: Long, jet-black hair that flows down to her waist, often tied up in intricate styles with traditional hairpins and floral adornments during ceremonies. In battle, she wears it in a high ponytail for practicality. Eyes: Her eyes are a striking emerald green, reflecting the elemental power she channels. They glow faintly when she uses her abilities, adding a mystical air to her presence. Height: Average height for her age, around 5’4” (162 cm), giving her a balanced, agile frame. Build: She has a lithe, athletic build from years of training, yet retains an air of grace and poise. Attire: Normally, Aiko wears her school uniform — a typical sailor-style outfit with a green bow tie. However, during her guardian duties, she dons a traditional miko (shrine maiden) attire, which is white and crimson with flowing sleeves and intricate designs that symbolize the elements she controls. Superpowers: Aiko possesses the rare ability to manipulate the four classical elements — Earth, Water, Fire, and Air. Her training allows her to wield these powers with precision and creativity: Earth: Aiko can summon and control earth in various forms, from creating barriers out of rock to growing plants for attack or defense. She can also sense vibrations through the ground, giving her a tactical advantage during battles. Water: Aiko can manipulate water, shaping it into various forms such as weapons or healing mists. She can also purify tainted water and summon rain. Fire: With fire, Aiko can generate intense flames, enhance her physical attacks with fire aura, and even create fire-based constructs like phoenixes. Her control allows her to extinguish fires too, preventing collateral damage. Air: Aiko’s air manipulation enables her to create powerful gusts of wind, form protective air barriers, and enhance her agility. She can also use air currents to glide or leap across large distances. Aiko’s elemental powers are tied to her emotions and her training has taught her to maintain a balance within herself to ensure precise and effective use of her abilities. As the newest guardian, Aiko’s journey is about mastering her powers, understanding the ancient knowledge passed down to her, and uniting with her allies to protect the world from encroaching darkness. Brimming with potential and the wisdom of her ancestral lineage, Aiko Takahashi is on a path that will challenge her resolve, reveal her true strength, and ultimately allow her to embrace her destiny as the Elemental Guardian.” ## Automate text-to-image prompt Then, we ask another GPT-4o instance to write a text-to-image prompt for each of these images. The system instruction is: > “You are an AI assistant writing in-depth prompts for another AI model. Your output must always be a detailed prompt without additional text. You must write a detailed prompt with the parameters and features of an image for a given user input. Write prompts as detailed as possible. It must be related to the topic of the user’s input. Pay attention to describing style and everything in the image.” ## Example Anime Characters ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v14zftm9d7xmun5krxcl.png) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m28hztud45pjeytfjuvm.png) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k0rqxas0iio9u3uwxzqv.png) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfp53hhvdknmstb3p3n5.png) ## Create Anime Characters with GPT-4o and SDXL You can use this agent via: https://www.aiflowly.com/.../AID-01J2YFMMFFD26H2QTFQARQV61N
appbaza
1,925,901
Como configurar o VSCode para seus projetos de React
Nota: apenas traduzi o texto abaixo e postei aqui. As referências estão no fim deste artigo. A...
0
2024-07-16T19:50:15
https://dev.to/dougsource/como-configurar-o-vscode-para-seus-projetos-de-react-k2b
programming, vscode, react, braziliandevs
_**Nota:** apenas traduzi o texto abaixo e postei aqui. As referências estão no fim deste artigo._ A ferramenta definitiva que você tem ao desenvolver seus projetos é o editor de código. É por isso que é tão importante configurá-lo corretamente. Neste guia passo a passo, passaremos de uma instalação completamente nova do VSCode a um editor de código perfeitamente preparado para seu próximo projeto React. Vamos começar! ## Como instalar o VSCode A primeira etapa para configurar o Visual Studio Code (abreviado como VSCode) é instalá-lo em seu computador. Acesse [code.visualstudio.com](https://code.visualstudio.com/) e baixe a versão correta para o seu computador (é 100% gratuita). ![installing the editor](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.08.06-AM.png "installing the editor") _Instale a versão correta para o seu sistema operacional_ Assim que a instalação for concluída e você abrir o VSCode app, você será saudado com uma tela inicial parecida com esta: ![vscode initial page](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.19.32-AM.png "vscode initial page") _Tela inicial do VSCode (após a instalação)_ ## Escolha uma color theme que você goste Embora o theme default fornecido com o VSCode seja muito bonito e legível, prefiro usar um theme de terceiros que considero mais agradável aos meus olhos. Pode parecer algo trivial perder tempo escolhendo um theme. Mas como você passará horas lendo textos em seu editor, você deve escolher cores que goste e que não cansem seus olhos. Eu pessoalmente uso e recomendo fortemente o Material Theme para todas as minhas instalações do VSCode. Para instalar o Material Theme, acesse (na parte superior da tela): **View &gt; Extensions** (ou use o atalho `⇧ + ⌘ (Ctrl) + X`) Em seguida, pesquise "Material Theme" na barra lateral e instale o primeiro resultado que aparecer. Deveria ficar assim: ![vscode extensions section](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.36.24-AM.png "vscode extensions section") Depois de instalado, você terá um dropdown para escolher entre várias variantes diferentes. A opção default é ótima, mas pessoalmente considero a variante "`Material Theme Ocean High Contrast`" a mais bonita. ![Material Theme Ocean High Contrast](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.37.38-AM.png "Material Theme Ocean High Contrast") Agora é um bom momento para adicionar algumas configurações básicas que tornem o código que você escreve confortável de ler. As configurações que melhorarão a legibilidade do seu código são o font size, o tab size e o font family. Você pode alterar suas preferências de VSCode acessando (na parte superior da tela): **Code &gt; Preferences &gt; Settings** (ou use o atalho: `⌘ (Ctrl) + ,`) As configurações que achei mais confortáveis ​​ao longo dos anos para o desenvolvimento de desktops e laptops são o font size como 18 e o tab size como 2. ![vscode settings commonly used](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.27.06-AM.png "vscode settings commonly used") Além disso, para deixar seu texto perfeito, acho que o texto fica melhor quando você aumenta o zoom level default do editor. Para aumentar o zoom level, vá em _preferences_ (`⌘ (Ctrl) + ,`) e digite "zoom level". Eu recomendo alterar o zoom level de 0 para 1. E, finalmente, por uma questão de preferência, gosto de remover os breadcrumb links default que estão na parte superior do editor. Você pode remover breadcrumbs acessando: **View &gt; Show Breadcrumbs** (e certificando-se de que esteja desmarcado). Esta é a aparência do nosso editor de código com um arquivo de component de exemplo que adicionei ao meu Desktop: ![vscode component screen](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.49.42-AM.png "vscode component screen") ## Formate seu código com a Prettier extension Você deve ter notado no exemplo acima que o código não está muito bem formatado. Felizmente, você pode formatar automaticamente cada arquivo `.js` escrito usando a Prettier extension para VSCode. Para poder formatar instantaneamente nosso código sempre que salvarmos um arquivo `.js`, podemos ir novamente para a extensions tab (`⇧ + ⌘ (Ctrl) + X`), digitar "**prettier**" e instalá-lo: ![vscode prettier plugin screen](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.51.35-AM.png "vscode prettier plugin screen") A seguir, podemos voltar às _preferences_ (`⌘ (Ctrl) + ,`) e procurar por "format on save" e verificar se está marcado: ![Format on Save setting](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.53.36-AM.png "Format on Save setting") E novamente em _preferences_, procure a configuração "**default formatter**" e defina isso como `Prettier`. ![Default formatter setting](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.55.30-AM.png "Default formatter setting") Agora, se voltarmos para um arquivo não formatado e clicarmos em salvar, ele será formatado instantaneamente para nós! Esta é a aparência do nosso component fictício depois que clicamos em salvar: ![Formatted React component com Prettier](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-10.57.23-AM.png "Formatted React component com Prettier") Confira a documentação da Prettier extension para ver como você pode configurá-la ainda mais de acordo com suas preferências de formatação. Ainda assim, eu pessoalmente recomendo usar as opções default. ## Como digitar JSX rapidamente com Emmet VSCode vem com suporte integrado para uma ferramenta incrível chamada **Emmet**, que permite escrever tags HTML muito rapidamente. No entanto, Emmet não está configurado por default para ser usado com JSX, que o React usa em vez de HTML. Para escrever seu JSX mais rapidamente, você pode usar Emmet com React acessando: **Code &gt; Preferences &gt; Settings** (`⌘ (Ctrl) + ,`) E então digite na barra de pesquisa, "**emmet include languages**". Depois disso, clique no button "Add Item" e adicione a seguinte configuração: `item: javascript, value: javascriptreact` (e então clique em ok) Sua configuração adicionada deve ficar assim: ![Emmet Include Languages setting](https://www.freecodecamp.org/news/content/images/size/w1000/2022/02/Screen-Shot-2022-02-17-at-11.10.32-AM.png "Emmet Include Languages setting") Agora que incluímos o React como linguagem para o Emmet, podemos começar a escrever nosso JSX muito mais rapidamente. ## Fonte [Artigo](https://www.freecodecamp.org/news/vscode-react-setup/?fbclid=IwZXh0bgNhZW0CMTEAAR0Q5COZUpdwRtjMYeZNitUsMq1dn2uGqfTbt3pin8QRxTgETHKCubpjnvE_aem_o59ADGrIqoaQSDsoJwxeog) escrito por **Reed Barger**.
dougsource
1,925,902
Build a Compiler in C language
Hey dev community! 👋 It's Amir back again with a new article and today, I'm excited to share a new...
0
2024-07-16T19:58:39
https://dev.to/bekbrace/build-a-compiler-in-c-language-3lgb
c, cpp, csharp, programming
Hey dev community! 👋 It's Amir back again with a new article and today, I'm excited to share a new tutorial where I walk you through creating a simple arithmetic expression parser and code generator in C. I hope this guide will help you understand the basics of tokenizing, validating, and evaluating arithmetic expressions, and then generating assembly-like instructions. 📚 What You'll Learn: Tokenize arithmetic expressions ✂️ Validate and evaluate expressions ✅ Generate assembly-like instructions 🛠️ Check out the video tutorial here: {% youtube 0k-c0vvs6HA %} Creating this one was really really fun, especially that I am not experienced in C, I wanted to share this little project with all of you. Here's the code: 📂 GitHub: https://github.com/BekBrace/C-Compiler Let me know what you think, your feedback is very valuable. Thanks and I will see you in the next one :)
bekbrace
1,925,903
SECURE YOUR LOST CRYPT0 INVESTMENT WITH MUYERN TRUST HACKER
In the vast and often treacherous realm of online investments, I was entangled in a web of deceit...
0
2024-07-16T19:58:58
https://dev.to/rickey_thompson/secure-your-lost-crypt0-investment-with-muyern-trust-hacker-4dio
In the vast and often treacherous realm of online investments, I was entangled in a web of deceit that cost me nearly  $45,000. It all started innocuously enough with an enticing Instagram profile promising lucrative returns through cryptocurrency investment. Initially, everything seemed promising—communications were smooth, and assurances were plentiful. However, as time passed, my optimism turned to suspicion. Withdrawal requests were met with delays and excuses. The once-responsive "investor" vanished into thin air, leaving me stranded with dwindling hopes and a sinking feeling in my gut. It became painfully clear that I had been duped by a sophisticated scheme designed to exploit trust and naivety. Desperate to recover my funds, I turned to online forums where I discovered numerous testimonials advocating for Muyern Trust Hacker. With nothing to lose, I contacted them, recounting my ordeal with a mixture of skepticism and hope. Their swift response and professional demeanor immediately reassured me that I had found a lifeline amidst the chaos. Muyern Trust Hacker wasted no time in taking action. They meticulously gathered evidence, navigated legal complexities, and deployed their expertise to expedite recovery. In what felt like a whirlwind of activity, although the passage of time was a blur amidst my anxiety, they achieved the seemingly impossible—my stolen funds were returned. The relief I felt was overwhelming. Muyern Trust Hacker not only restored my financial losses but also restored my faith in justice. Their commitment to integrity and their relentless pursuit of resolution were nothing short of remarkable. They proved themselves as recovery specialists and guardians against digital fraud, offering hope to victims like me who had been ensnared by deception. My gratitude knows no bounds for Muyern Trust Hacker. Reach them at muyerntrusted @ m a i l - m e . c o m AND Tele gram @ muyerntrusthackertech ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk46gd6hkeer2g1ai42o.jpg)
rickey_thompson
1,925,904
Top 10 Cloud Security Startups to Watch in 2024
As cloud environments continue to evolve, several startups are making significant strides in...
0
2024-07-16T20:00:05
https://dev.to/nashetking/top-10-cloud-security-startups-to-watch-in-2024-5964
cloudcomputing, security, programming, startup
As cloud environments continue to evolve, several startups are making significant strides in providing innovative cloud security solutions. These startups are not only leveraging cutting-edge technologies but also addressing the specific challenges that organizations face. In this blog, we'll explore the top 10 cloud security startups of 2024, diving into their unique offerings, behind-the-scenes technology, case studies, and client responses. --- #### 1. Aqua Security **Overview**: Aqua Security specializes in securing cloud-native environments. Their recent updates include the Kubernetes Bill of Materials (KBOM) and AI-Guided Remediation capabilities. **Tech Behind the Scenes**: Aqua Security utilizes machine learning to analyze data from various sources, providing automated remediation steps. The KBOM tool dissects Kubernetes clusters to identify all components, enhancing security monitoring. **Case Study**: * **Client**: A leading e-commerce platform * **Challenge**: Securing a complex Kubernetes environment with multiple clusters. * **Solution**: Implemented Aqua Security’s KBOM and AI-Guided Remediation. * **Results**: Reduced vulnerability remediation time by 40%, improved visibility, and compliance. **Client Response**: "Aqua Security has significantly streamlined our Kubernetes security processes. The automated remediation is a game-changer." **Code Snippet**: ```yaml apiVersion: v1 kind: Pod metadata: name: secure-pod spec: containers: - name: secure-container image: secure-image:latest securityContext: readOnlyRootFilesystem: true runAsNonRoot: true ``` **More Info**: [Aqua Security](https://www.aquasec.com/) --- #### 2. Dazz **Overview**: Dazz offers a platform focused on the prioritization and remediation of cloud vulnerabilities with its Unified Remediation Platform. **Tech Behind the Scenes**: Dazz uses data correlation techniques to connect related security issues and trace them back to their root causes, enabling efficient remediation. **Case Study**: * **Client**: A global financial services company * **Challenge**: High volume of security alerts with limited context. * **Solution**: Adopted Dazz’s Unified Remediation Platform. * **Results**: 50% reduction in false positives, quicker identification of critical vulnerabilities. **Client Response**: "Dazz has transformed our vulnerability management process, making it more efficient and focused." **Code Snippet**: ```python import dazz_sdk client = dazz_sdk.Client(api_key='your_api_key') vulnerabilities = client.get_vulnerabilities() critical_vulns = [v for v in vulnerabilities if v.severity == 'Critical'] for vuln in critical_vulns: client.remediate_vulnerability(vuln.id) ``` **More Info**: [Dazz](https://www.dazz.io/) --- #### 3. Orca Security **Overview**: Orca Security provides AI-driven cloud asset search for fast visibility into cloud environments. **Tech Behind the Scenes**: Orca leverages large language models (LLMs) to create a question-and-answer functionality, enabling users to query their cloud assets and receive detailed responses. **Case Study**: * **Client**: A healthcare provider * **Challenge**: Lack of visibility into cloud assets and security posture. * **Solution**: Deployed Orca Security’s AI-driven search functionality. * **Results**: Achieved 100% visibility into cloud assets, improved incident response times. **Client Response**: "Orca Security has given us unprecedented visibility and control over our cloud environment." **Code Snippet**: ```json { "query": "List all EC2 instances with open security groups", "results": [ { "instance_id": "i-1234567890abcdef", "security_group": "sg-12345", "open_ports": [22, 80] } ] } ``` **More Info**: [Orca Security](https://orca.security/) --- #### 4. Cyble **Overview**: Cyble uses AI to monitor the Darkweb, Deepweb, and Surface Web for cyber threats, providing real-time insights and threat intelligence. **Tech Behind the Scenes**: Cyble's platform continuously scans and analyzes data from various sources, leveraging machine learning to identify potential threats and vulnerabilities. **Case Study**: * **Client**: A major retail chain * **Challenge**: Frequent data breaches and lack of threat intelligence. * **Solution**: Implemented Cyble’s threat intelligence platform. * **Results**: Early detection of potential breaches, improved security posture. **Client Response**: "Cyble’s threat intelligence capabilities have been instrumental in protecting our data." **Code Snippet**: ```python import cyble_sdk client = cyble_sdk.Client(api_key='your_api_key') threats = client.get_threats() for threat in threats: if threat.risk_level == 'High': client.alert_security_team(threat.id) ``` **More Info**: [Cyble](https://cyble.com/) --- #### 5. Illumio **Overview**: Illumio provides microsegmentation technology for zero-trust security, preventing the lateral movement of breaches within data centers and cloud environments. **Tech Behind the Scenes**: Illumio's platform uses dynamic policies and real-time traffic analysis to enforce security boundaries within and across cloud environments. **Case Study**: * **Client**: A large manufacturing firm * **Challenge**: Preventing lateral movement of attacks within the network. * **Solution**: Deployed Illumio’s microsegmentation solution. * **Results**: 60% reduction in breach impact, enhanced network security. **Client Response**: "Illumio’s microsegmentation has fortified our internal security against breaches." **Code Snippet**: ```yaml apiVersion: illumio.com/v1 kind: SecurityPolicy metadata: name: zero-trust-policy spec: rules: - action: Allow source: app-tier destination: db-tier ports: [5432] - action: Deny source: app-tier destination: any ``` **More Info**: [Illumio](https://www.illumio.com/) --- #### 6. Safebreach **Overview**: Safebreach offers continuous security assessment through breach and attack simulations, identifying vulnerabilities before hackers do. **Tech Behind the Scenes**: Safebreach’s platform simulates various attack vectors, providing detailed reports on security weaknesses and remediation steps. **Case Study**: * **Client**: A telecommunications company * **Challenge**: Identifying and mitigating security gaps. * **Solution**: Utilized Safebreach’s simulation tools. * **Results**: Identified critical vulnerabilities, improved overall security posture. **Client Response**: "Safebreach’s simulations have been crucial in proactively addressing our security weaknesses." **Code Snippet**: ```python import safebreach_sdk client = safebreach_sdk.Client(api_key='your_api_key') simulations = client.run_simulations() for sim in simulations: if sim.status == 'Failed': client.remediate_issue(sim.id) ``` **More Info**: [Safebreach](https://safebreach.com/) --- #### 7. Beyond Identity **Overview**: Beyond Identity focuses on passwordless authentication, binding identities to devices to enhance security. **Tech Behind the Scenes**: The platform uses cryptographic keys stored on users’ devices, eliminating the need for passwords and reducing the risk of credential-based attacks. **Case Study**: * **Client**: A financial technology startup * **Challenge**: Preventing credential-based attacks. * **Solution**: Implemented Beyond Identity’s passwordless authentication. * **Results**: Enhanced security, reduced phishing attacks by 70%. **Client Response**: "Beyond Identity has made our authentication process more secure and user-friendly." **Code Snippet**: ```javascript const beyondIdentity = require('beyond-identity-sdk'); beyondIdentity.authenticateUser(user_id, device_id) .then(response => { console.log('Authentication successful:', response); }) .catch(error => { console.error('Authentication failed:', error); }); ``` **More Info**: [Beyond Identity](https://www.beyondidentity.com/) --- #### 8. Confluera **Overview**: Confluera helps organizations identify, track, and manage sophisticated security threats through its advanced cybersecurity platform. **Tech Behind the Scenes**: Confluera uses real-time tracking and correlation of security events, providing actionable insights for threat management. **Case Study**: * **Client**: A government agency * **Challenge**: Managing advanced persistent threats (APTs). * **Solution**: Adopted Confluera’s cybersecurity platform. * **Results**: Improved threat detection and response times, reduced APT impact. **Client Response**: "Confluera’s platform has enhanced our ability to detect and respond to sophisticated threats." **Code Snippet**: ```python import confluera_sdk client = confluera_sdk.Client(api_key='your_api_key') threats = client.get_advanced_threats() for threat in threats: client.take_action(threat.id) ``` **More Info**: [Confluera](https://www.confluera.com/) --- #### 9. Liongard **Overview**: Liongard offers cybersecurity services for Managed Service Providers (MSPs), providing comprehensive visibility and protection for sensitive data. **Tech Behind the Scenes**: Liongard’s platform integrates with various IT systems to automate security monitoring and compliance reporting. **Case Study**: * **Client**: An MSP serving multiple small businesses * **Challenge**: Ensuring consistent security across diverse environments. * **Solution**: Implemented Liongard’s integrated security platform. * **Results**: Improved compliance, reduced manual security management efforts by 50%. **Client Response**: "Liongard has simplified our security management, making it more efficient and reliable." **Code Snippet**: ```yaml apiVersion: liongard.io/v1 kind: SecurityIntegration metadata: name: msp-security spec: rules: - action: Monitor source: all target: sensitive_data frequency: daily - action: Alert source: any condition: anomaly_detected ``` **More Info**: [Liongard](https://liongard.com/) --- #### 10. Valtix **Overview**: Valtix offers a cloud-native network security platform designed to provide visibility, control, and protection across multi-cloud environments. **Tech Behind the Scenes**: Valtix's platform uses a single-pass architecture to inspect and enforce security policies, integrating seamlessly with AWS, Azure, GCP, and Oracle Cloud. **Case Study**: * **Client**: A global technology company * **Challenge**: Securing multi-cloud environments with unified policies. * **Solution**: Deployed Valtix’s network security platform. * **Results**: Enhanced security visibility, streamlined policy management across clouds. **Client Response**: "Valtix has revolutionized our multi-cloud security strategy, making it more efficient and comprehensive." **Code Snippet**: ```json { "policy": { "name": "multi-cloud-policy", "description": "Unified security policy for multi-cloud environments", "rules": [ { "action": "Allow", "source": "internal_network", "destination": "cloud_resources", "ports": [443, 80] }, { "action": "Deny", "source": "external_network", "destination": "cloud_resources" } ] } } ``` **More Info**: [Valtix](https://www.valtix.com/) --- ### Conclusion The landscape of cloud security is rapidly evolving, with startups like Aqua Security, Dazz, Orca Security, Cyble, Illumio, Safebreach, Beyond Identity, Confluera, Liongard, and Valtix leading the way. These companies are leveraging cutting-edge technologies such as AI, machine learning, and advanced analytics to provide innovative solutions that address the complex challenges of securing cloud environments. From automated remediation and threat intelligence to zero-trust security and breach simulations, these startups are setting new standards in cloud security. Their case studies demonstrate the tangible benefits of their solutions, highlighting significant improvements in security posture, compliance, and operational efficiency. As cloud adoption continues to grow, keeping an eye on these innovative startups can provide valuable insights into the future of cloud security. Whether you're an enterprise looking to enhance your security measures or an MSP seeking to streamline your security management, these startups offer solutions that can meet your needs. --- **Author Note**: For more in-depth articles on cloud security and the latest tech innovations, follow my profile: **Connect with me**: - [LinkedIn](https://www.linkedin.com/in/nashet-ali/) - [Twitter](https://twitter.com/nashetali) Stay secure and keep innovating!
nashetking
1,925,905
Revolutionizing Web 3 Development with AI: Unlocking New Possibilities
As the digital landscape evolves, the intersection of artificial intelligence (AI) and Web 3...
0
2024-07-16T20:00:25
https://dev.to/irmakork/revolutionizing-web-3-development-with-ai-unlocking-new-possibilities-55m5
ai, devops, developers, web3
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83fv57qu93ifweczulbc.jpg) As the digital landscape evolves, the intersection of artificial intelligence (AI) and Web 3 development is creating unprecedented opportunities. Web 3, characterized by decentralization, blockchain technology, and peer-to-peer interactions, is now being supercharged by AI to unlock new possibilities for developers and users alike. **Enhancing Smart Contracts with AI** One of the most exciting applications of AI in Web 3 development is the enhancement of smart contracts. These self-executing contracts with the terms directly written into code are fundamental to decentralized applications (dApps). AI can optimize smart contract performance, improve security by detecting vulnerabilities, and even predict potential bugs before deployment. This fusion ensures more reliable and efficient transactions on the blockchain. Advanced Data Analytics for Decentralized Networks AI's ability to process and analyze vast amounts of data is particularly beneficial in decentralized networks. Web 3 platforms generate significant data that, when analyzed, can provide valuable insights into user behavior, network performance, and emerging trends. AI-driven analytics tools can help developers understand complex datasets, enabling them to make informed decisions and enhance user experiences. AI-Powered Personalization in dApps User experience is at the heart of any successful application, and Web 3 is no exception. AI can bring advanced personalization to decentralized applications, offering users tailored experiences based on their preferences and behaviors. This can range from personalized content recommendations in decentralized social networks to customized financial advice in DeFi platforms, enhancing user engagement and satisfaction. Improved Security and Fraud Detection Security is a paramount concern in the Web 3 space. AI can bolster security measures by providing real-time monitoring and fraud detection. Machine learning algorithms can identify suspicious activities and patterns that may indicate fraud, ensuring the integrity of decentralized networks. This proactive approach to security helps protect user assets and maintains trust in the ecosystem. Automating Complex Workflows AI can automate complex workflows in Web 3 development, reducing the burden on developers and increasing efficiency. From automating the creation and management of decentralized autonomous organizations (DAOs) to streamlining token issuance processes, AI can handle repetitive and intricate tasks, allowing developers to focus on innovation and strategic development. AI and Interoperability in Web 3 Interoperability is a key challenge in the Web 3 space, with various blockchains operating independently. AI can facilitate interoperability by enabling seamless communication and data transfer between different blockchain networks. This can unlock new possibilities for cross-chain applications and foster greater collaboration within the decentralized ecosystem. The Future of Web 3 Development The integration of AI into Web 3 development is still in its early stages, but the potential is immense. As AI technologies continue to evolve, they will become even more integral to the development and operation of decentralized platforms. Developers who harness the power of AI in their Web 3 projects will be at the forefront of innovation, driving the next wave of digital transformation. In conclusion, AI is revolutionizing Web 3 development by enhancing smart contracts, providing advanced data analytics, improving security, and automating complex workflows. As these technologies converge, the decentralized web will become more efficient, secure, and user-friendly, unlocking new possibilities for developers and users alike. Embracing AI in Web 3 development is not just an option but a necessity for those looking to shape the future of the digital world.
irmakork
1,925,906
Postman Api 101
The Postman Student Program was an incredible journey, equipping me with crucial skills and...
0
2024-07-16T20:00:31
https://dev.to/mohanraj1234/postman-api-101-4c5j
The Postman Student Program was an incredible journey, equipping me with crucial skills and connections. If you're passionate about APIs, this program is a game-changer. Highly recommended!
mohanraj1234
1,925,907
Api In postman
Today I attended the postman Api workshop
0
2024-07-16T20:04:27
https://dev.to/mohanraj1234/api-in-postman-2df4
Today I attended the postman Api workshop
mohanraj1234
1,925,908
I couldn't afford $5/mo for Ghost Pro so I built one for $2/mo on a $4,000/mo VPS
Children, this is the story of "How I Met Your M̶o̶t̶h̶e̶r̶ .... no Ghost" So, this story starts...
0
2024-07-16T20:05:09
https://dev.to/vednig/i-couldnt-afford-5mo-for-ghost-pro-so-i-built-one-for-2mo-on-a-4000mo-vps-no5
webdev, javascript, programming, supabase
Children, this is the story of "How I Met Your M̶o̶t̶h̶e̶r̶ .... no Ghost" ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wuu5uvbbem3bnowxvh1z.gif) So, this story starts with the usual problem present everywhere , I know, Poverty. So, right now I have graduated from my college and was working on my startup doshare.me living in the spare room of my parent's house. For over a year I looked for tech based jobs on various platforms including Linkedin, Glassdoor and Indeed during the global financial slowdown and seasons of layoffs that's when I started on "file based service for reorganization" i.e changing the way buisnesses interact with files. But that would be a story for next decade. This one's for this weekend. Since, all the SEO services, marketing and discoverability start with a blog, we at Doshare, got our go-to blog on Ghost Pro. After 1 Month of Free Trial and sending a "reinstating" email to ghost support team(cause card declined ofc.). We knew we couldn't pay $11/mo for Plausible Analytics and $5 for Ghost Pro then paying Monthly Infrastructure Costs for AWS, Cloudflare Workers, R2 and Render. We needed to cut costs so we did what any other (totally!) reasonable engineer would do. Setup the blog on a VPS using docker. So, like aaanyyy other reasonable engineer we started out, where ever we could get free credits. And then this occurred. IBM gave free $1000 IN VPC credits. After exhausting every free credit limit on AWS and Render. It was time to move to IBM cloud. Simply installing docker and setting up a single instance of Ghost for our blog at blog.doshare.me . Then I realized many people are required to host their own instance on a $5 DigitalOcean droplet(or similarly priced VPS on AWS, Azure etc.). While setting up Ghost using Docker on server. I thought it would be great to have a WebUI over the Docker that could deploy as many websites I want for each of my side projects with a simple URL setup via cname. So, taking inspiration from Vercel's UI (or Next.js idk much of a Vue person really). But, I wanted to learn Nextjs and work on a project using Supabase - what's supabase? you ask? it's this Awesome Open Source Firebase alternative for building Apps. And recently, it went into GA - General Availability, which also means they have made it less buggy for this type of project or any. So, I left everything I was doing(I wasn't doing anything), and got started with this Nextbase Starter from GitHub. Encountered some errors, did rigourous Testing, Wake up late. Sleep (a little) for 2 week. First week I hoped, I would be able to ship by end of week. But that was my overambitious self. it's okay(sobs on localhost:3000) .Let's say it, "I am Batman" (in ben afleck's voice). OKAY, you got me I might have designed (or not) a theme named Batmobile for Ghost back when I was tinkering with building Custom Ghost Themes. After 2 weeks on 14 June starting from 1 June it was finally completed with Payment Integration using Razorpay's Gateway. It was live for 2 days, I launched it on YC News and then Razorpay.(because they don't support business web hosting) Remember it's BYOSD (that's short for Bring Your Own Sub-Domain) Now, it's down again. So, that's great for an effort? Now that my ramp is over here it is time for stating that I have made website free for now until I figure out a Payment Platform so you can try it out. Enjoy, GT out! (mic drop🎤) Enjoy The Free Brunch Here :> [Login](https://shedtheshade.com/login) - [SignUp](https://shedtheshade.com/sign-up) PS: Now I have to pay $7000 and $72 on AWS plus whatever Cloudflare for SaaS bills. [Original Post](https://blog.shedtheshade.com/i-couldnt-afford-5-mo-for-ghost-pro-so-i-built-one-for-2-mo-on-a-4-000-mo-vps/)
vednig
1,925,940
🚀 20 Days to Azure DevOps Superstardom! 🌟
Welcome to your epic Azure DevOps learning journey! 🎉 This 20-day adventure will transform you from...
0
2024-07-16T20:29:34
https://dev.to/narashim_reddy/20-days-to-azure-devops-superstardom-4lg6
devops, azure, tutorial, cloudninja
Welcome to your epic Azure DevOps learning journey! 🎉 This 20-day adventure will transform you from an Azure novice to a DevOps pro, complete with 4 mind-blowing projects! 🏆 ## 🗓️_Your Epic Learning Odyssey_ <table> <thead> <tr> <th>Day</th> <th>Topic</th> <th>Theory</th> <th>Hands-On</th> <th>YouTube</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Azure Basics - DevOps</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>2</td> <td>Azure Boards</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>3</td> <td>Azure Repos</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>4</td> <td>Azure Pipelines</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>5</td> <td>Azure Release Pipelines</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>6</td> <td>Azure Test Plans</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>7</td> <td>Azure Artifacts</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>8</td> <td>Azure Terraform Pipeline</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>9</td> <td>Azure VMSS Agents</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>10</td> <td>Azure Docker Containers</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>11</td> <td>Three-Tier Architecture CI/CD on Kubernetes</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>12</td> <td>Azure Advanced Security</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>13</td> <td>Azure Functions CI/CD</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>14</td> <td>Azure Wiki</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>15</td> <td>Azure Security Best Practices</td> <td>✅</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>16</td> <td>Troubleshooting & Common Issues</td> <td>✅</td> <td>🛠️</td> <td>▶️</td> </tr> <tr> <td>17</td> <td>Project 1: </td> <td>🚀</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>18</td> <td>Project 2: </td> <td>🚀</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>19</td> <td>Project 3: </td> <td>🚀</td> <td>✍️</td> <td>▶️</td> </tr> <tr> <td>20</td> <td>Project 4: </td> <td>🚀</td> <td>✍️</td> <td>▶️</td> </tr> </tbody> </table> ## _🧠 What You'll Master_ Prepare to supercharge your skills with: - 🏗️ Azure fundamentals and DevOps principles - 📊 Project management wizardry with Azure Boards - 🔄 Version control mastery using Azure Repos - 🚦 CI/CD implementation like a pro - 🧪 Testing strategies that catch bugs in their sleep - 📦 Package management secrets with Azure Artifacts - 🏭 Infrastructure as Code using Terraform - 🐳 Containerization and Kubernetes deployment sorcery - ⚡ Serverless computing with Azure Functions - 📚 Documentation best practices that will make your team weep with joy - 🔐 Security considerations to make your apps fortress-strong ## _🚀 Getting Started_ 1. 🔑 Secure your Azure account 2. 💻 Set up your dev environment (make it comfy!) 3. 🧭 Navigate the Azure portal like a pro 4. 🤝 Join the Azure DevOps community (we're friendly, we promise!) ## _🗺️ Your Learning Odyssey_ 1. 🌱 Plant the seeds of knowledge (Days 1-7) 2. 🌳 Grow your skills with advanced topics (Days 8-16) 3. 🌟 Shine bright with real-world projects (Days 17-20) ## _Remember: Consistency is your superpower! Aim for 1-2 hours of daily Azure awesomeness!_ ## _📚 Treasure Trove of Resources_ - [Official Azure Docs](https://docs.microsoft.com/en-us/azure/) - Your map to the Azure universe - [Azure DevOps Labs](https://azuredevopslabs.com/) - Where theory meets practice - [Microsoft Learn](https://docs.microsoft.com/en-us/learn/) - Level up your skills, RPG style! May your code be bug-free and your deployments lightning-fast! 🚀✨ #azure #devops #cloud #tutorial #CloudNinja
narashim_reddy
1,926,865
Flutter
A post by Aadarsh Kunwar
0
2024-07-17T14:58:31
https://dev.to/aadarshk7/flutter-38lm
aadarshk7
1,925,941
Prime Day Sniping: Top Tech Deals for Developers
Prime Day is here, and it’s the perfect opportunity to snag some fantastic deals on laptops,...
0
2024-07-16T20:45:17
https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/
devtoys, deals, productivity
--- canonical_url: https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/ --- Prime Day is here, and it’s the perfect opportunity to snag some fantastic deals on laptops, computers, and tablets. Here are some of the top picks that will elevate your tech game without breaking the bank. --- ## ⚡For more details please visit -> [DevToys.io- Deal Sniping ](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🛸 --- ## Laptops [Acer Aspire 5 15 Slim Laptop](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $449.99 (15% off, was $529.99) [ASUS ROG Strix G16 (2024) Gaming Laptop](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $1,099.99 (21% off, was $1,399.99) [Lenovo Newest V15 Series Laptop](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $439.99 (20% off, was $549.99) --- ## Desktops [Alienware Aurora R15 Gaming Desktop](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $1,999.99 (20% off, was $2,499.97) [CyberpowerPC Gamer Master Gaming PC](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $849.99 (15% off, was $999.99) [Alienware Aurora R16 Gaming Desktop](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $1,869.99 (15% off, was $2,199.99) --- ## Tablets [Samsung Galaxy Tab A9+ Tablet](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $142.49 (35% off, was $219.99) [Samsung Galaxy Tab S9 FE](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $313.49 (30% off, was $449.99) [Apple iPad (10th Generation)](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥Deal Price: $449.99 (10% off, was $499.00) --- ## 🫠 Take advantage of these Prime Day deals to upgrade your tech arsenal with top-rated laptops, computers, and tablets. Don’t miss out on these limited-time offers! Check out the details here! [DevToys.io - Deal Sniping](https://devtoys.io/2024/07/16/prime-day-sniping-top-tech-deals-for-developers/) 🔥
3a5abi
1,925,942
Host A Static Website On Microsoft Azure Blob Storage
Azure Static Web Apps is a service that automatically builds and deploys full stack web apps to Azure...
0
2024-07-16T22:37:06
https://dev.to/sangifeanyi/host-a-static-website-on-microsoft-azure-blob-storage-2l62
Azure Static Web Apps is a service that automatically builds and deploys full stack web apps to Azure from a code repository. In this quick start, you are to deploy an application to Azure Static Web apps using the Visual Studio Code extension. The first step is to configure your storage account to host a static website in the Azure portal. __Under Azure Services, click Storage accounts ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rx3mn5gbzvtn8foq76ln.png) On the Storage accounts page, click Create to create a new storage account. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj4ghwlsuksjg6l9w5qe.png) __On the Basics tab, enter the storage account name and other details. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwa3eenbrrrq4vubjb99.png) __Click Review + Create Create. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9k4xxntyndty6ydcdsb.png) click on GO To resources ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0z6r7ybqx2smkvv98t8.png) _Locate your storage account and display the account overview. __On the left pain, select Container to create a container for the website. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpu5ymwculc78f909czh.png) __Enter the details and click on create __Select Static website On the left pain to display the configuration page for static websites. _Select Enabled to enable static website hosting for the storage account._ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08zyy6ri3yyakx1wjn5h.png) _In the Index document name field, specify a default index page of index.html. The default index page is displayed when a user navigates to the root of your static website._ _In the Error document path field, specify a default error page of 404.html. The default error page is displayed when a user attempts to navigate to a page that does not exist in your static website. Click Save. _The Azure portal now displays your static website endpoint. _Azure Storage automatically creates a container named $web. The $web container will contain the files for your static website. _ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj3fj7ev931cg8102pnu.png) _Launch Visual Studio Code, and open the folder that you contain your website files, from the Explorer panel. _ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gmlh9yok3qn5nx7ctc1a.png) _Install the Azure Extension in the Visual Studio Code and connect to it. You will be prompted to log in to Azure to retrieve a list of your subscriptions. Select the subscription containing the storage account for which you enabled static website hosting. Next, select the storage account when prompted. _ _Right-click the Azure linked website folder in the Explorer panel and select Deploy to Static Website... to deploy your website._ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8ut12ywti1klrkptk16.png) Visual Studio Code prompt you to select your project folder. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b84vejp49zxdig3b8dup.png) __select the folder and upload your files to your web endpoint. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2rxo50vmb1uclz3wyp5.png) __Visual Studio Code show the success status bar. _Click Launch the website when deployment is completed or go to Azure to get the primary endpoint._ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwsu7mmfutspl57i2lmg.png) _Launch the website in a browser._ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/edjtrw674euz98xq6pxr.png) to view it in Azure. You've successfully deployed a static website to Azure.
sangifeanyi
1,925,943
Hello world,
Today my HTML learning are Nesting and Anchor element and it was fun... making my base strong for...
0
2024-07-16T20:52:30
https://dev.to/ritesh_dev/hello-world-4ko
webdev, javascript, beginners, programming
Today my HTML learning are Nesting and Anchor element and it was fun... making my base strong for further future learning.... hashtag#webdev hashtag#coder hashtag#html ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6qwhlh78eggjlocq0h9.png)
ritesh_dev
1,925,944
Top 7 Featured DEV Posts of the Week
Welcome to this week's Top 7, where the DEV editorial team handpicks their favorite posts from the...
0
2024-07-16T20:55:20
https://dev.to/devteam/top-7-featured-dev-posts-of-the-week-k38
top7
_Welcome to this week's Top 7, where the DEV editorial team handpicks their favorite posts from the previous week._ Congrats to all the authors that made it onto the list 👏 {% embed https://dev.to/jenc/the-dual-nature-of-seniority-in-software-development-1b3j %} Jen explores the complexities of seniority in software development, discussing its dual nature and how it impacts team dynamics and career growth. --- {% embed https://dev.to/davorg/combining-calendars-59g8 %} Dave expresses the joy that's felt when someone uses your side project, and also shares what that side project is: a tool to combine multiple calendars to streamline your schedule. --- {% embed https://dev.to/fastly/an-easy-intro-to-edge-computing-3ced %} Sue shares a beginner-friendly introduction to edge computing, explaining its concepts, benefits, and practical applications. --- {% embed https://dev.to/moopet/my-work-setup-for-php-development-4dj8 %} Ben gives us a tour of their work setup, highlighting the tools and practices that boost their efficiency. --- {% embed https://dev.to/francescoxx/a-new-project-for-rust-developers-5cbj %} Francesco announces a new project that aims to consolidate free, open-source resources dedicated to the Rust programming language. --- {% embed https://dev.to/mb337/how-to-center-a-div-3c2a %} Matteo publishes a few answers to the age old question: how do you center a div? --- {% embed https://dev.to/ispmanager/8-fun-linux-utilities-48i0 %} Enjoy these eight fun Linux utilities for some day-to-day entertainment. --- _And that's a wrap for this week's Top 7 roundup! 🎬 We hope you enjoyed this eclectic mix of insights, stories, and tips from our talented authors. Keep coding, keep learning, and stay tuned to DEV for more captivating content and [make sure you’re opted in to our Weekly Newsletter] (https://dev.to/settings/notifications) 📩 for all the best articles, discussions, and updates._
thepracticaldev
1,925,946
Integration of Artificial Intelligence and Machine Learning in Cloud Security
Lately, companies, startups, governments, and other organizations have opted to use cloud computing...
0
2024-07-16T20:57:07
https://dev.to/joshwizard/integration-of-artificial-intelligence-and-machine-learning-in-cloud-security-62b
cybersecurity, devops, machinelearning, ai
Lately, companies, startups, governments, and other organizations have opted to use [cloud computing](https://en.wikipedia.org/wiki/Cloud_computing) only for its reliability to store their data without the risk of losing the data either by computer viruses, theft, human errors, software corruption, natural disasters, or hardware impairment among others. Artificial Intelligence and Machine Learning have become very crucial in enhancing cloud security by having automated threat detection whereby potential threats can be identified in real-time and machine learning models activated to surpass the danger. It also has improved automated response to block malicious activities and trigger automated workflows to detach affected systems and activate recovery processes, hence more efficiency and reduced human errors. Last but not least, AI and ML are self-learning, this aspect improves with time as they learn and adapt to new emerging threats hence detection and response capabilities are strengthened. In this article, I will explore how Artificial Intelligence and Machine learning are transforming and impacting cloud security despite the challenges that will be catered for in the future. ##The role of AI and ML in cloud security ###Enhancing Threat Detection and Response ####AI-Driven Threat Detection AI algorithms can analyze large amounts of data to identify unusual patterns of hackers or an attempt to access data unauthorized. A good example of AI algorithms is Google’s Chronicles and Amazon’s Macie. They are all cloud-based security software that helps organizations to detect potential security incidents on their entire network infrastructure. ####Automated Incident Response Machine Learning models are well modified to enable automated responses to respond to already identified threats to mitigate damage that would be caused by a breach of security to access unauthorized data. These models are very fast thus reducing response time and potential damage that could arise as a result of security breach. AI-driven Security Information and Event Management (SIEM) Systems like Splunk and IBM QRadar leverage Machine Learning for real-time threat detection and automated responses. They get operational insights into vulnerabilities and return feedback about security breaches. ###Predictive Analytics for Proactive Security Artificial Intelligence models are designed to predict potential threats based on historical data and emerging trends. These models are so important since they are used in ethical hacking to detect vulnerabilities in systems before they are exploited by hackers. Machine Learning models analyze users' behavior to establish a baseline and identify deviations that may indicate compromised accounts or insider threats. ###Enhanced Access Management Artificial Intelligence systems can adjust account authentication processes based on real-time potential risk assessments. Most companies have incorporated this technique to counterattack any malicious attempt on their systems. An example is Microsoft’s Azure Active Directory Identity Protection which uses Artificial Intelligence to detect and respond to suspicious sign-ins. Google also has embraced this technique where when signing in to your Gmail Account on a different device, a message confirming the sign-in activity is sent to your email or your phone to confirm its authenticity. Artificial Intelligence and Machine Learning models are used for continuous monitoring to detect access patterns to systems and give an alert on any possible irregularities. AI and ML models are trained on the normality of sign-ins and in case an abnormality is detected, a response action is activated to the access attempt before damage is inflicted on the system. A service such as Amazon GuardDuty provides intelligent threat detection for Amazon Web Services (AWS) resources by continuously monitoring your account activity within the AWS environment. ###Challenges and Considerations ####Data Privacy and Ethics The main challenge when working with Artificial Intelligence and Machine Learning models is ensuring that it complies with data privacy and ethical standards. These systems require a lot of large datasets for training which include access to personal information. To achieve maximum data privacy regulations, compliance with GDPR, HIPAA, and CCPA is a necessity whereby terms and conditions are adhered to. If AI and ML models are not fully customized to achieve the end goal, these AI and ML models could lead to negatives by breaching data privacy, and how conclusions are reached thus all potential biases in Machine Learning models must be fully addressed. ####Scalability and Integration AI and ML models require high functional computation resources to handle large datasets for training purposes which makes it a challenge to handle increased data volume and ensure complex computations are attained efficiently. Due to the high need for computational demands to balance performance, AI and ML systems lead to high operational costs which are critical to run and maintain. ####Continuous Learning and Adaptation Attacks on systems and technology are ever-evolving, necessitating frequent updates and retraining AI and ML models to handle these new types of attacks. Ensuring regular updates and personnel to constantly retrain AI models is a big challenge resulting in high costs of management and keeping operations undisrupted. ##Future Trends in AI and ML for Cloud Security ###Advanced Threat Detection Response Future AI and ML systems will advance their intellectual capabilities by integrating more resources to detect potential threats with high accuracy. These models will correlate on multiple environments for detailed threat detection and automatically execute the best response protocols to counter identified threats hence reducing human intervention and errors. ###Integration with Quantum Computing With quantum computing technology, all the traditional encryption methods will become vulnerable to threats therefore, AI and ML models will be trained to use cryptographic algorithms (blockchain technology) to protect and secure data systems against future quantum attacks. Quantum computing will also solve the need to solve complex models and process large datasets by boosting Artificial Intelligence abilities. ###Federated Learning Federated learning will enhance data privacy whereby it allows AI and ML models to be trained on multiple decentralized devices without actually sharing personal information publicly. In this perspective, organizations will benefit from collaborative learning while maintaining data locally and only sharing AI and ML model updates thus keeping data privacy regulations intact. ###Improved Transparency and Trust Future AI and ML models will be explainable making AI security solutions more transparent, and understandable to humans thereby increasing trust in these systems. These AI models will provide clear explanations for automated response actions taken by security systems, therefore, facilitating top-notch regulatory compliance requirements. ###Enhanced User Behavior Analytics (UBA) The evolving nature of AI and ML in monitoring user behavior will advance its capabilities in detecting anomalies by constantly learning new users' behavior and adapting to the patterns thus improving the detection of newly invented threats. UBA will also integrate with IAM (Identity Access Management) to provide real-time and up-to-date authentication based on user activity hence decreasing data breaches. ###AI for IoT Security As IoT devices escalate, AI and ML models will play a vital role in making sure the endpoints of these devices are secured. It will help detect and respond to threats at the endpoints ensuring remote and distributed environments are always protected against any form of cyber threats. ##Conclusion Artificial Intelligence and Machine Learning have positively impacted security in the cloud computing sector by reducing human intervention in systems attacks, using advanced monitoring tools to track unusual user behavior, they can trigger automated workflows to respond quickly to affected systems, and can also activate recovery processes in case of an attack. These awesome benefits will enable organizations to have improved security and save on operation and management costs for human intervention. The future of AI and ML in cloud computing is revolutionary, ushering in a new era of innovations to enhance security to systems that are intelligent and adaptive to emerging trends.
joshwizard
1,925,948
Boost Your Android Development with Fast & Easy Form Builder
Boost Your Android Development with Fast &amp; Easy Form Builder Building forms can often...
0
2024-07-17T14:05:36
https://dev.to/jos_igutirrezb_8d0b/boost-your-android-development-with-fast-easy-form-builder-42p7
mobile, kotlin, opensource, androiddev
## Boost Your Android Development with Fast & Easy Form Builder Building forms can often be a time-consuming task in Android development. Whether it’s for user registration, feedback collection, or data entry, creating a well-structured and functional form can be challenging. Enter **Fast & Easy Form**, a powerful library designed to streamline this process, making form creation faster and easier than ever before. In this post, we’ll explore the features and benefits of this remarkable library and how it can enhance your Android projects. ### Features of Fast & Easy Form #### Comprehensive Functionality - **start:** Easily initiate form generation within the user interface. - **validateAll:** Validate all form fields with a single function call. - **validateByTag:** Target and validate specific fields identified by tags. - **getResultByTag:** Retrieve the result of specific fields using their tags. - **getResult:** Fetch the overall form results effortlessly. - **updateRow:** Dynamically update rows or sections within the form. - **eventChecked:** Manage item verification or selection events. - **startProgressView & finishProgressView:** Manage progress views for actions, enhancing user experience. #### Customizable Form Structure - Define forms with sections and rows, allowing for a clear and organized layout. - Configure themes to match your app’s design, with options for light, dark, and auto modes. #### Versatile Row Types - **INFO:** Display information. - **TITLE:** Add titles to sections. - **ACTIVITY:** Directly call other activities within the project. - **MULTIPLE_CHECK_LIST:** Enable multi-option selections. - **CHECK:** Quick validations for specific questions. - **EDIT:** Input fields for text, numbers, emails, etc. - **SINGLE_CHECK_LIST:** Single-option selections. - **ON_CLICK:** Buttons for actions. - **DATE_PICKER & TIME_PICKER:** Native date and time pickers. - **SWITCH:** Switch controls for settings. #### Detailed Parameterization - Extensive options for setting text, colors, sizes, alignment, and visibility for various form elements. - Parameters such as `tag`, `activity`, `checked`, `validationOn`, and more for fine-grained control. #### Event Handling - Use `onClick` and `eventChecked` for interactive and dynamic forms. ### Benefits of Using Fast & Easy Form #### Increased Development Speed - Reduce the time spent on creating and managing forms, allowing you to focus on other critical aspects of your project. #### Enhanced User Experience - With customizable themes and dynamic updates, your forms will look great and respond fluidly to user interactions. #### Robust Validation - Ensure data integrity with comprehensive validation functions, reducing the likelihood of user errors. #### Flexibility and Scalability - The extensive parameterization and versatile row types make it easy to create forms for a wide range of use cases, from simple surveys to complex data entry systems. #### Ease of Integration - The clear structure and detailed documentation make integrating Fast & Easy Form into your project straightforward, even for developers new to the library. ### Simple Structure Code for Implementation Implementing Fast & Easy Form in your Android project is straightforward. Here’s a simple example to get you started: ```kotlin var easyFastForm = BuildForm(mContext = this) { mode = uiMode.dark // Config theme: LIGHT, DARK, & AUTO container = MyRecyclerView // Set your RecyclerView body { section { title = "Personal Information" description = "Fill out the following details." content { row(RType.EDIT) { setText.title = "Name" inputTypeEditText = InputType.TYPE_CLASS_TEXT } row(RType.DATE_PICKER) { setText.title = "Date of Birth" setDatePicker.format = "dd/MM/yyyy" } row(RType.SINGLE_CHECK_LIST) { setText.title = "Gender" checkList { option { text = "Male" } option { text = "Female" } option { text = "Other" } } } row(RType.ON_CLICK) { setText.title = "Submit" onClick { // Submit action } } } } } } ``` Integrating Fast & Easy Form into your Android project is simple. Start by adding the library to your project dependencies, then follow the detailed documentation to create and customize your forms. With the provided code snippets and examples, you’ll be up and running in no time, building forms that are both functional and visually appealing. Interested in making your Android form-building process faster and easier? Explore the Fast & Easy Form project and discover all its features by [clicking here](https://github.com/LordSaac/FastEasyForm/tree/master). ### Conclusion Fast & Easy Form is a game-changer for Android developers. Its powerful features, flexibility, and ease of use make it an indispensable tool for creating forms quickly and efficiently. By incorporating this library into your projects, you’ll save time, enhance user experience, and ensure robust data handling. Start using Fast & Easy Form today and take your Android development to the next level!
jos_igutirrezb_8d0b
1,925,950
Day 992 : When The Sun Shines Again
liner notes: Professional : Today flew by! Responded to some community questions and worked on some...
0
2024-07-16T21:06:49
https://dev.to/dwane/day-992-when-the-sun-shines-again-1p5
hiphop, code, coding, lifelongdev
_liner notes_: - Professional : Today flew by! Responded to some community questions and worked on some documentation before a meeting. After the meeting, I spoke with someone that worked on a feature that I'll be creating a sample application and blog post to clarify some things so that what I say is as accurate as possible. Did some more research and I think I found how I want to be able to really showcase the value of the feature. - Personal : After like a day and a half with the sample ring, I selected the size to complete my order to get the health tracking ring. I'll primarily wear it on my index finger, but it can also fit on my ring and middle fingers. I went through some tracks for the radio show. Made some pretty good progress on the proof of concept for a feature of my side project. What I thought would take multiple canvas elements to achieve turned out that I only needed one. I just need to do some math to work out some sizing of some videos. The next step will be to record the contents of the canvas element and preview it in a video player to where they can download it. In my project, I want to allow them to be able to upload it to a storage location that I can view it later. I also want to add a timer so that I can limit how long the recording can be. Could be a cool project to add to https://myLight.work After coding, I watched an episode of the "Suicide Squad" anime and went to sleep. ![A panoramic view of a lake in the Rocky Mountains, with a steep mountainside on the right and a smaller mountainside on the left. The lake is a vivid, almost iridescent blue. Green pines and fir trees are silhouetted against the water and snow-capped peaks. The location is Banff National Park, Canada.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fgigx91htu5boo95slle.jpg) Going to do a replay of last night, but it's raining so I'll begin when the sun shines again. I also need to pack some close because I'll be heading out early tomorrow to check out some land. Really hoping that I'll finally find something. So no blog posts for the next couple of days. Hopefully I can go from looking at land to looking at homes to put on that land. haha. Have a great night and see you in a couple of days! peace piece Dwane / conshus https://dwane.io / https://HIPHOPandCODE.com {% youtube bFYHRupfarU %}
dwane
1,925,951
shadcn-ui/ui codebase analysis: How does shadcn-ui CLI work? — Part 2.14
I wanted to find out how shadcn-ui CLI works. In this article, I discuss the code used to build the...
0
2024-07-16T21:07:29
https://dev.to/ramunarasinga/shadcn-uiui-codebase-analysis-how-does-shadcn-ui-cli-work-part-214-4p20
javascript, shadcnui, nextjs, opensource
I wanted to find out how shadcn-ui CLI works. In this article, I discuss the code used to build the shadcn-ui/ui CLI. In part 2.11, we looked at runInit function and how shadcn-ui/ui ensures directories provided in resolvedPaths in config exist. The following operations are performed in runInit function: ![](https://media.licdn.com/dms/image/D4E12AQHEmOyCs-cx4Q/article-inline_image-shrink_1000_1488/0/1721163275555?e=1726704000&v=beta&t=6j10fRzVcFjODfc_inb84FvvhMQFq_TDSF1gYGiUcks) 1. Ensure all resolved paths directories exist. 2. Write tailwind config. 3. Write css file. 4. Write cn file. 5. Install dependencies. 1, 2, 3 from the above are covered in part 2.12 and 2.13, let’s find out how “Write cn file” operation is done. > _Want to learn how to build shadcn-ui/ui from scratch? Check out_ [_build-from-scratch_](https://tthroo.com/) Write cn file ------------- The below code snippet is picked from [cli/src/commands/init.ts](https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/commands/init.ts#L373) ```js // Write cn file. await fs.writeFile( \`${config.resolvedPaths.utils}.${extension}\`, extension === "ts" ? templates.UTILS : templates.UTILS\_JS, "utf8" ) ``` [templates.UTILS](https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/utils/templates.ts#L1) contains the below code ```js export const UTILS = \`import { type ClassValue, clsx } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue\[\]) { return twMerge(clsx(inputs)) } \` export const UTILS\_JS = \`import { clsx } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs) { return twMerge(clsx(inputs)) } \` ``` cn utility is literally code returned as a string and written to lib/utils when you run shadcn init. Conclusion: ----------- templates.UTILS variable in [packages/cli/src/commands/init.ts](https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/commands/init.ts#L331C3-L356C4) contains the cn utility function related code. ```js export const UTILS = \`import { type ClassValue, clsx } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue\[\]) { return twMerge(clsx(inputs)) } \` export const UTILS\_JS = \`import { clsx } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs) { return twMerge(clsx(inputs)) } \` ``` Catch here is, this code is presented as a string into fs.writeFile that writes to a provided path as shown below ```js await fs.writeFile( \`${config.resolvedPaths.utils}.${extension}\`, extension === "ts" ? templates.UTILS : templates.UTILS\_JS, "utf8" ) ``` > _Want to learn how to build shadcn-ui/ui from scratch? Check out_ [_build-from-scratch_](https://tthroo.com/) About me: --------- Website: [https://ramunarasinga.com/](https://ramunarasinga.com/) Linkedin: [https://www.linkedin.com/in/ramu-narasinga-189361128/](https://www.linkedin.com/in/ramu-narasinga-189361128/) Github: [https://github.com/Ramu-Narasinga](https://github.com/Ramu-Narasinga) Email: [ramu.narasinga@gmail.com](mailto:ramu.narasinga@gmail.com) [Build shadcn-ui/ui from scratch](https://tthroo.com/) References: ----------- 1. [https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/commands/init.ts#L331C3-L356C4](https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/commands/init.ts#L331C3-L356C4) 2. [https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/utils/templates.ts#L1](https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/utils/templates.ts#L1)
ramunarasinga
1,925,952
Como instalar e atualizar o seu AWS CLI corretamente usando o Ubuntu 22.04 no WSL2 (Windows 11)
Nessa documentação você terá acesso ao processo de instalação e atualização do AWS CLI sendo feito...
0
2024-07-16T21:42:05
https://dev.to/aws-builders/como-instalar-e-atualizar-o-seu-aws-cli-corretamente-usando-o-ubuntu-2204-no-wsl2-windows-11-3jom
Nessa documentação você terá acesso ao processo de instalação e atualização do AWS CLI sendo feito via terminal em uma distribuição Ubuntu 22.04 executada via WSL 2.0 no Windows 11 **Sumário:** * Instalação do AWS CLI; * Atualização do AWS CLI; * Deleção do AWS CLI; ## Instalação do AWS CLI O processo de instalação do AWS CLI é extremamente simples e a [documentação oficial](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) da AWS no entrega os comandos necessários, são eles: ``` curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install ``` > O comando **curl** baixa o binário compactado em um zip file; > O comando **unzip** extrai esse binário do zip no diretório /aws (Se você não tiver o unzip instalado, basta executar o comando: **sudo apt install unzip -y;** > O comando **sudo ./aws/install** instala o aws-cli no seu terminal; Para verificar se a instalação aconteceu corretamente, basta executar o comando: ``` aws --version ``` Você verá a versão do CLI instalado como retorno no seu terminal: ![Saída do comando mostrando a versão instalado do aws-cli no seu terminal](https://cdn-images-1.medium.com/max/2174/1*eW3bH0NFdi6IT7sdE0i9yw.png) ## Atualização do AWS CLI Caso o seu aws-cli esteja desatualizado, o processo de atualização também é consideravelmente simples. Abaixo estão os passos: Execute o comando abaixo para baixar o binário mais recente do AWS CLI e extraia o arquivo: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip Após baixar e extrair o arquivo, você verá o seguinte no seu terminal: ![Execute o comando ls -l para listar o conteudo do seu diretório](https://cdn-images-1.medium.com/max/2000/1*bZ_i6Lw9n82AbWpj4QbiGw.png) Você poderá deletar o arquivo .zip depois de extraído, se desejar. Para deletar, basta executar o comando: rm awscliv2.zip Para atualizar finalmente o aws-cli, execute o comando ***which aws*** para verificar o local de instalação do aws-cli e usar essa saída no próximo comando que executaremos. Normalmente o resultado é: ***/usr/local/bin*** ![](https://cdn-images-1.medium.com/max/2000/1*OUuRcIdq406jDZ9rduTx8g.png) Se o seu local for diferente você precisa informá-lo no comando de instalação abaixo no parâmetro ***bin-dir. ***O parâmetro **instal-dir** indica o local de instalação do aws-cli e deve ser deixado dessa forma. O comando final ficaria da seguinte forma: sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update Após a execução do comando, o aws-cli mais recente será instalado no seu terminal. Para conferir, basta executar o comando: aws --version Executando o comando novamente, você verá que a versão mais recente do AWS CLI foi instalada em seu terminal ![](https://cdn-images-1.medium.com/max/2000/1*5jLwfxsTBBIzq_m0n_5_IQ.png) **Antes: Versão 2.15.40** ![Saída do comando mostrando a versão instalado do aws-cli no seu terminal antes do update](https://cdn-images-1.medium.com/max/2174/1*eW3bH0NFdi6IT7sdE0i9yw.png) **Depois: Versão 2.17.13** ![Saída do comando mostrando a versão instalado do aws-cli no seu terminal depois do update](https://cdn-images-1.medium.com/max/2000/1*5jLwfxsTBBIzq_m0n_5_IQ.png) ### **Troubleshooting:** Caso após executar e conferir toda a sequência de comandos, o seu aws-cli não for atualizado, você pode remover explicitamente o aws-cli e depois instalá-lo novamente. Para o processo de deleção do AWS CLI no Ubuntu, siga os passos abaixo: ## Deleção do AWS CLI do seu terminal **Localize os symlinks abaixo:** which aws which aws_completer Você terá uma saída como a mostrada abaixo: ![](https://cdn-images-1.medium.com/max/2000/1*S1ZZDToGVr98dL1aNPQ4Pw.png) **Remova os dois symlinks:** sudo rm /usr/local/bin/aws sudo rm /usr/local/bin/aws_completer Encontre o diretório de instalação do aws-cli. Observe que ao executar os comandos abaixo, o diretório de instalação do aws-cli está no mesmo caminho tanto para o ***aws*** quanto para o ***aws_completer***: ***/usr/local/aws-cli/…*** ``` ls -l /usr/local/bin/aws ls -l /usr/local/bin/aws_completer ``` O resultado é: ![](https://cdn-images-1.medium.com/max/2392/1*EHS--sXkLX3BwaXgeQSSug.png) Removendo o diretório /usr/local/aws-cli/ você já removerá todos os arquivo e diretórios subsequentes: ``` sudo rm -rf /usr/local/aws-cli ``` **Opcional:** Delete os arquivos de configuração do aws-cli. Os arquivos nesse diretório armazenam as configurações de credenciais usadas no seu terminal ``` sudo rm -rf ~/.aws/ ``` Execute o comando abaixo para verificar se o aws-cli foi removido com sucesso: ``` aws --version ``` Se a saída for que o **comando não é reconhecido**, o aws-cli foi desinstalado corretamente. Agora é só seguir os passos de instalação para instalá-lo novamente! Para manusear corretamente a(s) sua(s) conta(s) na AWS, você precisará agora configurar corretamente as suas credenciais programáticas e a melhor forma de fazer isso é através dos perfis de CLI. Para entender mais sobre esse assunto, veja esse meu artigo: **Links uteis:** * Verificar versões do AWS CLI V2: [https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst](https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst) * Documentação oficial de install/update do AWS CLI V2: [https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) * Documentação oficial de deleção do AWS CLI V2: [https://docs.aws.amazon.com/cli/latest/userguide/uninstall.html](https://docs.aws.amazon.com/cli/latest/userguide/uninstall.html)
o_filipealmeida
1,925,953
How often do you run your agile retrospectives?
Wondering how often to run Agile retrospectives? Regular retrospectives at the end of each sprint are...
0
2024-07-16T21:16:20
https://dev.to/mattlewandowski93/how-often-do-you-run-your-agile-retrospectives-19lg
agile, scrum, retrospective, management
Wondering how often to run Agile retrospectives? Regular retrospectives at the end of each sprint are key for continuous improvement, but the optimal frequency depends on factors like sprint length, team maturity, and project complexity. In our latest article, we explore the benefits of timely feedback and manageable changes, discuss feature-based retrospectives for complex projects, and offer tips on avoiding meeting fatigue. Finding the right rhythm can enhance your team’s efficiency and productivity. Dive deeper into [how often you should run your agile retrospectives](https://kollabe.com/posts/how-often-should-you-run-an-agile-retrospective).
mattlewandowski93
1,925,954
System Architecture Design Methodologies Part1
System Architecture Design Methodologies are like recipes for building complex systems. These methods...
0
2024-07-16T21:16:34
https://dev.to/usmanatx/system-architecture-design-methodologies-part1-3g6p
systemdesign, microservices, architecture, designsystem
System Architecture Design Methodologies are like recipes for building complex systems. These methods provide a framework for architects to follow. They design the system for flexibility, simplicity, and consistent performance. Here are some common System Architecture Design Methodologies: **Monolithic Architecture:** This approach builds the entire system as a single, self-contained unit. It is often used for smaller applications or proof-of-concepts. **Pros:** 1. Since there is a single codebase, it makes it easier to develop, test, and debug. 2. Deployment is often faster and more straightforward. 3. It is relatively easier to optimize performance because all components are co-located. **Cons:** 1. A single codebase simplifies deployment, but hinders scaling. As the application grows, adding resources forces you to scale the entire application. 2. Components are tightly coupled. This makes it hard to change them without affecting the whole system. 3. It has a single point of failure. ![Monolithic Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/et99cgsmwtahi0ng7ze2.png) **Microservice Architecture:** In this approach, a single application consists of many small services. They are independent and loosely coupled. Each service is designed to perform a specific task. **Pros:** 1. You can easily scale up or down each microservice. You do this depending on if demand increases or decreases. 2. If a particular microservice is down, the rest of the system will not be affected. 3. Maintaining a smaller, independent component is easy. It is easier than making changes in a monolith repository. **Cons:** 1. Managing multiple services can be more complex than deploying a single application. 2. Tracing problems gets harder. You might need to search through many services to find the problem. 3. Services communicating over a network can increase latency. But, this may not be true in a monolith architecture. ![Microservice Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7wuop1ui9f4394xzqal.png) **Service-Oriented Architecture (SOA):** SOA is a middle state. It is between monolith and microservices architectures. SOA takes a hybrid approach. It keeps some coupling between systems, but not as much as in a monolith. SOA typically involves large, complex services. They have a lot of business logic. Microservices are smaller and focused. They perform a specific task or function. **Pros:** 1. Easier to implement than a microservice, as it requires less complex infrastructure. 2. SOA is well-suited for small-scale applications that don't require much scalability. 3. SOA has a centralized management approach, which makes governance easier. **Cons:** 1. SOA services are often scaled vertically. This makes it hard to scale them horizontally. 2. SOA services are tightly coupled, making it harder to make changes. 3. The maintenance cost for SOA services could be higher if not set up properly. ![Service-Oriented Architecture (SOA)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/230rw73lqoiido1vf961.png)
usmanatx
1,925,975
The Kafka Metric You’re Not Using: Stop Counting Messages, Start Measuring Time
by Aratz Manterola Lasa Companion video Consumer groups are the backbone of data consumption in...
0
2024-07-17T14:04:25
https://dev.to/warpstream/the-kafka-metric-youre-not-using-stop-counting-messages-start-measuring-time-2e57
apachekafka, dataengineering, realtimestreamingdat
--- title: The Kafka Metric You’re Not Using: Stop Counting Messages, Start Measuring Time published: true date: 2024-07-16 18:03:30 UTC tags: apachekafka,dataengineering,realtimestreamingdat canonical_url: --- by Aratz Manterola Lasa [Companion video](https://youtu.be/yBia8pnDKYg) Consumer groups are the backbone of data consumption in Kafka. Consumer groups are logical groupings of consumers who work together to read data from topics, dividing the workload by assigning partitions to individual group members. Each group member then reads messages from its assigned partitions independently. Consumer groups also keep track of consumption progress by storing offset positions for every topic partition that the group is consuming. This ensures that when a member leaves the group (because it was terminated or crashed), a new member can pick up where the last one left off without interruption. ![](https://cdn-images-1.medium.com/max/1024/0*DZ-_bdB9iSU7S3S1.png) Depiction of a Kafka consumer group. Consumers read from their respective partitions, and commit their progress (as Kafka offsets) back to the cluster. Consumer groups are great, but monitoring them can be a challenge. Specifically, it can be tricky to determine if your consumers are keeping up with the incoming data stream (i.e., are they “lagging”) and, if not, why. In this post, we’ll explain why the usual way of measuring consumer group lag (using Kafka offsets) isn’t always the best and show you an alternative approach that makes it much easier to monitor and troubleshoot them. The most common way to monitor consumer groups is to alert on the delta between the maximum offset of a topic partition (i.e., the offset of the most recently produced message) and the maximum offset committed by the consumer group for that same topic partition. We’ll call this metric “offset lag.” ![](https://cdn-images-1.medium.com/max/1024/0*jpQW7OcX0R54Ti3S.png) Offset lag is the delta between the committed offset and the offset of the last produced record for each topic-partition. Consumer groups track their own progress using Kafka offsets, so intuitively, it makes sense to reuse the same mechanism to monitor whether they’re keeping up. High offset lag indicates that your consumers can’t keep up with the incoming data, necessitating action like increasing the number of consumers, partitions, or both. In addition, the _rate of change_ of consumer group lag is an important early indicator of potential problems and a good indicator that attempts to mitigate observed increases in lag are working. ### The Problem with Consumer Offset Lag Tracking consumer group offset lag can be a really useful way to monitor an individual Kafka consumer. However, converting offset lag into a value that is meaningful _to humans_ or that can be compared with other workloads is difficult. Let’s use a concrete example to make this more clear. Imagine you’re an infrastructure engineer responsible for managing your company’s data streaming platform. In a recent incident, one team’s consumer application fell so far behind that customer data was delayed for hours. No monitors were fired, and you only discovered the issue when some of your (rightfully angry!) customers complained. As a remediation item, you’ve been tasked with ensuring that all Kafka consumers are monitored, so alarms will go off if any consumers fall “too far” behind. Great! We just learned about the concept of offset lag, so you can create a monitor on the offset lag metric and group by consumer group name, right? All you have to do is pick the offset lag “threshold” beyond which the monitor should fire. You run the query in a dashboard to see the current values, and you are shocked to find that the current offset lag for your various consumer groups varies wildly, from 10 (no extra zeros!) to 12 _million_. You freeze in panic. “Are we having an incident _right now!?_” ![](https://cdn-images-1.medium.com/max/1024/0*i8zj1D-VmUF5kUWx.png) Two different consumer groups with wildly varying offset lag. After some investigation and talking to other teams, you realize this is normal. Some of these consumer groups naturally have much higher throughput than others, so their baseline offset lag is higher because there’s more data “in-flight” at any given moment. Other consumer groups process data in large batches, accumulating large amounts of offset lag, consuming it all at once, and then repeating that process. Every team’s use case makes sense in isolation, but now you’re stuck. How in the world will you pick one threshold that makes sense for all of these different workloads? You could pick different thresholds for each workload, but even then, you’ll probably get woken up in the middle of the night with false alarms when some of these workloads grow in throughput and their baseline offset lag increases, even if the actual consumers are keeping up just fine. ### Time Lag: A More Intuitive Metric To overcome the limitations of offset-based lag, the Kafka community has introduced a more intuitive metric called “time lag”. While intuitive, this concept wasn’t immediately available in Open Source Kafka’s native tooling. Companies like Agoda and AppsFlyer recognized its value and developed their own solutions, with Agoda notably [sharing their insights in a blog post](https://medium.com/agoda-engineering/adding-time-lag-to-monitor-kafka-consumer-2c626fa61cfc) that inspired many in the community (including us!). Since then, tools like Burrow have emerged, offering time lag calculation as part of their Kafka monitoring tools. Imagine once again that you’re an infrastructure engineer, and you’re in the middle of an incident where one of your consumer groups has fallen behind. Your customers are asking you how delayed their data will be. They’re likely to look at you with a blank stare if you tell them: “your data is delayed 30 million offsets”, but they’ll understand immediately if you tell them the maximum data delay is 17 minutes. Time lag is calculated using the following function: Time Lag = CurrentTime — LastTimeConsumedOffsetWasLatest Where LastTimeConsumedOffsetWasLatest is defined as the moment when the last consumed message was also the most recently produced message. Let’s illustrate that with an example. Imagine a Kafka topic where: - The latest produced message has offset 15 and was generated at 3:15 PM. - A consumer group processes messages up to offset 10 by 3:20 PM. - The message with offset 11 was produced at 3:10 PM. In this scenario, LastTimeConsumedOffsetWasLatest is 3:10 PM. This is because at 3:09:59 PM, offset 10 was still the latest message on the topic. However, at 3:10 PM, offset 11 was produced, meaning the consumer started to fall behind at that exact moment. So we round this up to 3:10 PM. Therefore, at 3:20 PM, the time lag is calculated as: Time Lag = 3:20 PM — 3:10 PM = 10 minutes This means the consumer group is 10 minutes behind the most recent message. ![](https://cdn-images-1.medium.com/max/1024/0*ELgu-Y_8qigv0gT-.png) Another way to put it: “ **time lag” is the time elapsed since the next-message-to-be-consumed was produced.** This definition is simple but also deceptively elegant: by making it relative to the _current time_, the metric keeps increasing if there are _any_ unprocessed records, even if producers and consumers have stopped entirely. It acts as an alarm, alerting you to unprocessed messages even when the system appears idle. ### An Integrated Approach to Time Lag Calculation While monitoring time lag can be a game-changer, accessing this metric isn’t always straightforward. If you search online resources, you’ll find the primary method involves third-party tooling that calculates this metric for you, like Burrow. These tools are great; they really make monitoring trivial. However, Burrow is yet another piece of software that has to be deployed, maintained, and troubleshooted. At WarpStream, we like to make things easy. Asking our users to install third-party tooling just to know if their consumer applications were caught up didn’t sit right with us. So, we decided to build time lag measurement directly into WarpStream so that all our users would benefit from it out of the box. This is probably a good time to briefly review WarpStream’s architecture. If you’re not familiar with it, WarpStream is a drop-in replacement for Apache Kafka built directly on top of object storage. WarpStream has many different architectural differences from Apache Kafka, but the one most relevant to the current topic is that in addition to separating computing from storage, WarpStream also separates _data from metadata_. ![](https://cdn-images-1.medium.com/max/1024/0*hlHjiPr5ngiq-3lw.png) WarpStream architecture diagram. Agents (stateless thick proxies) run in the customers cloud account, and the metadata store runs in WarpStream’s cloud account. Customers’ raw data is stored exclusively in their own S3 buckets, accessible only to them. Meanwhile, WarpStream Cloud stores metadata in a highly available, quadruply-replicated metadata store. The fact that WarpStream stores all of the cluster’s metadata in a centralized metadata store makes calculating time lag (relatively) straightforward. Unlike Apache Kafka, we don’t have to read or load any raw records or their headers; we can just query the timestamp index in the metadata store directly. This has the added benefit that it doesn’t rely on potentially unreliable record header timestamps (the client can set custom timestamps in the records). Instead, WarpStream maintains its own accurate timestamps in the metadata store and uses optimized data structures for time-based searches. There was one challenge we had to solve, though: metrics are published by the Agents (data plane), which run in the customer’s environment and expose metrics via a Prometheus endpoint. However, the time lag calculation was running in WarpStream’s cloud control plane, so we needed a mechanism to make the time lag metrics the control plane generated available as Prometheus metrics in the Agents. To solve this, we came up with a very simple solution: leverage WarpStream’s existing job queueing system. WarpStream’s architecture includes a centralized scheduler on the control plane that orchestrates various operational tasks. Agents, deployed within the customer’s environment, regularly poll this scheduler to receive and execute tasks, including functions like data compaction and object storage cleanup. Leveraging this existing infrastructure, we introduced a new job dedicated to calculating time lag metrics. This job runs on the control plane, periodically computing the metrics and making them accessible for the agents to retrieve during their polling cycles, who then emit them. We liked this solution because it’s simple and allows us to provide more metrics easily in the future. We leverage this metadata to provide the **warpstream\_consumer\_group\_estimated\_lag\_very\_coarse\_do\_not\_use\_to\_measure\_e2e\_seconds** metric. Why such a weird name? As you’ll see later in our more detailed explanation, this value is coarse-grained and imprecise. For example, while the actual end-to-end latency for a workload may be 500ms, this metric could report that the consumer group time lag is as high as 5 seconds. We wanted to clarify that while this metric is valuable for monitoring and alerting, it should not be used for _benchmarking_. This metric is an approximation, so it’s not perfect, but it’s great for getting a general idea of how things are going and catching bigger problems. If an incident happens and someone tries to use this metric to explain a one-millisecond delay, they’re using the wrong tool for the job. We want people to feel comfortable setting alerts for more substantial delays (e.g., several minutes) because this metric excels at that. Think of it as a coarse-grained tool for catching big problems, not a fine-tuned instrument for performance tuning. ![](https://cdn-images-1.medium.com/max/1024/0*7cFqsVqP61MSzHP9.png) ![](https://cdn-images-1.medium.com/max/1024/0*o2cbZgD8X3E482QC.png) Offset lag for the blue consumer is more than 20x higher, but time lag is less than 2x higher. The graph above showcases the difference between offset lag and time lag for two consumer groups. One group has a much larger offset lag of 20,000, while the other has a smaller lag of a few hundred. However, when we switch to the time lag, we see a different picture: both groups have very similar lags of 2 and 4.5 seconds. This shows how offset lag alone can be misleading and how time lag provides a more understandable overview of consumer group health. Imagine trying to set alerts based on these metrics. With time lag, a single alert threshold (e.g., 2 minutes) could easily cover both consumer groups. With offset lag, you’d need to set different thresholds for each, carefully considering the nature of each workload and potentially missing alerts for the group with the “smaller” lag. ### Behind the Scenes: The Mechanics of Time Lag Metrics Having established the benefits of time lag over offset lag, let’s delve into the technical implementation. Understanding this implementation will also show how WarpStream calculates the time lag we introduced earlier: Time Lag = CurrentTime—LastTimeConsumedOffsetWasLatest. WarpStream continuously tracks when messages are produced, associating each message offset with its corresponding timestamp. This data is stored internally in a way that allows us to efficiently query for offsets based on timestamps. To optimize storage, we aggregate this data into minute-level intervals. For each minute, we record the earliest offset produced (baseOffset) and the total number of offsets produced (offsetCount), effectively creating a compact time-series representation of message production. When we need to know LastTimeConsumedOffsetWasLatest for a specific offset consumed by a consumer group, we use this index: 1. We first locate the relevant minute-level interval that contains that offset. 2. Within that interval, we divide the time by the offsetCount to estimate how frequently messages were produced within that time range. 3. Using the production rate and the offset’s position within the interval, we calculate an estimated timestamp for when that specific message was produced. This gives us the LastTimeConsumedOffsetWasLatest, which we then subtract from the current time to obtain the time lag. As mentioned earlier, a dedicated background job within WarpStream’s control plane periodically calculates each cluster’s time lag and other relevant metrics for every consumer group. This involves querying the committed offsets for every consumer group and partition and then utilizing the timestamp index to compute the corresponding time lag values. These calculated values are subsequently transmitted to the WarpStream Agents operating within the customer’s environment. And finally the Agents expose these time lag metrics via their Prometheus endpoint, under the name **warpstream\_consumer\_group\_estimated\_lag\_very\_coarse\_do\_not\_use\_to\_measure\_e2e\_seconds**. However, keeping a record of every minute would consume excessive storage space for clusters with many topic-partitions and high (or infinite) retention. To address this, we merge the index entries periodically. This involves merging multiple entries into one, updating the baseOffset and offsetCount, and introducing an additional field called minuteCount to keep track of the number of minutes the compacted entry represents. This merging does sacrifice some timestamp precision, but we prioritize the most recent entries, ensuring we maintain their original accuracy untouched. Older entries are the only ones subject to merging. We prioritize recent entries because the more recent an offset is, the more crucial it is for consumers to have precise lag information. If a consumer is 10 minutes behind, a 30-second difference isn’t a major concern. But for a consumer who’s only 1 minute behind, that level of precision becomes much more important. In this way, we balance optimizing storage efficiency and maintaining the level of precision that matters most for effective monitoring. Now, it’s clear why this metric is an approximation designed for monitoring and alerting, not precise benchmarking. The “very coarse” part of the metric’s name highlights a few key limitations: - **Interpolation:** The metric is calculated by interpolating **at least** 1-minute level entries in the timestamp index, which can introduce inaccuracies compared to the true message production time. - **Committed Offsets:** The metric relies on committed offsets, which may only sometimes reflect the most up-to-date consumption progress. Consumers can commit offsets at varying intervals, either immediately after processing a message or after processing an entire batch. This leads to potential discrepancies between the committed offset and the actual latest consumed message. These factors make the metric less suitable for precise performance measurements but perfectly adequate for identifying significant delays in consumer group processing. Moreover, the utility of the timestamp index extends beyond just calculating the time lag. It also enables internal Kafka APIs to query for offsets based on specific timestamps, which is useful for features like time-based data retrieval and analysis. ![](https://cdn-images-1.medium.com/max/1024/0*UQ0rbAf8QPTzWyeA.png) Depiction of timestamp index compaction and subsequent interpolation. In conclusion, monitoring Kafka consumer groups doesn’t need to be a guessing game. By shifting the focus from the message counts (offset lag) to time (time lag), understanding how consumers perform becomes trivial. With Warpstream’s built-in time lag metrics, this insight is readily available, ensuring you can monitor and react timely in case your data pipeline consumers start to fall behind. **Create a free WarpStream account and start streaming with $400 in free credits.** [**Get Started**](https://console.warpstream.com/signup)!
warpstream
1,925,984
any suggestions on this website
https://enaly.com
0
2024-07-16T21:28:39
https://dev.to/henry_wang_c02699c8c99e04/any-suggestions-on-this-website-1jcg
[https://enaly.com](https://enaly.com)
henry_wang_c02699c8c99e04
1,925,988
Have you tried all API calls in JavaScript? Here are 4 ways to do it
API calls are a key part of modern web development. JavaScript offers several ways to accomplish...
0
2024-07-16T21:31:52
https://dev.to/tomasdevs/have-you-tried-all-api-calls-in-javascript-here-are-4-ways-to-do-it-4l4d
webdev, javascript, api, programming
> API calls are a key part of modern web development. JavaScript offers several ways to accomplish this task, each with its own advantages and disadvantages. This article will introduce you to four main methods of making API calls in JavaScript that you can use in your projects. ## XMLHttpRequest (XHR) **XMLHttpRequest (XHR)** is a traditional way to call APIs, supported in all browser versions. This method is reliable and widely used, although its syntax can sometimes be harder to read and maintain. ``` const xhr = new XMLHttpRequest(); xhr.open("GET", "https://api.example.com/data", true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { console.log(JSON.parse(xhr.responseText)); // Parse and log the response data } else { console.error('Error:', xhr.statusText); // Log any errors } } }; xhr.send(); ``` --- ## Fetch API **Fetch API** is a more modern and simpler way to make API calls, based on promises. It supports asynchronous operations and is easy to extend using async and await. ``` fetch("https://api.example.com/data") .then(response => response.json()) .then(data => console.log(data)) // Log the response data .catch(error => console.error('Error:', error)); // Log any errors ``` **Using async and await.** ``` async function fetchData() { try { const response = await fetch("https://api.example.com/data"); const data = await response.json(); console.log(data); // Log the response data } catch (error) { console.error('Error:', error); // Log any errors } } fetchData(); ``` --- ## Axios **Axios** is a popular library for HTTP requests that provides a simple and consistent interface for making API calls. It needs to be installed first using npm or yarn. `npm install axios` or `yarn add axios` Then you can use Axios for making API calls: ``` const axios = require('axios'); axios.get("https://api.example.com/data") .then(response => { console.log(response.data); // Log the response data }) .catch(error => { console.error('Error:', error); // Log any errors }); ``` Using async and await: ``` async function fetchData() { try { const response = await axios.get("https://api.example.com/data"); console.log(response.data); // Log the response data } catch (error) { console.error('Error:', error); // Log any errors } } fetchData(); ``` --- ## jQuery AJAX **jQuery AJAX** is a method for making API calls using the jQuery library. Although jQuery is less commonly used today, it still appears in older projects. ``` <!-- Include jQuery library --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { $.ajax({ url: "https://api.example.com/data", method: "GET", success: function(data) { console.log(data); // Log the response data }, error: function(error) { console.error('Error:', error); // Log any errors } }); }); </script> ``` --- _Source photo:_ RAKOZY, Greg. Website design books. Online. In: Unsplash. 2016. Available from: https://unsplash.com/photos/html-css-book-vw3Ahg4x1tY. [cit. 2024-07-16].
tomasdevs
1,925,999
Softrobo - Empowering Digital Evolution
With over a decade of expertise in SEO and digital marketing, I present Softrobo – your ultimate...
0
2024-07-16T22:02:03
https://dev.to/softrobo/softrobo-empowering-digital-evolution-2laa
digitalservices, digitalsolution, seoservices, webdevelopmentservices
With over a decade of expertise in SEO and digital marketing, I present Softrobo – your [ultimate](https://softrobo.co.uk) partner in empowering digital evolution. Softrobo Executive Team, boasting over 7 years of experience, excels in creating and enhancing exceptional digital products. Our services encompass: Mobile App Development: Tailored solutions to bring your app ideas to life, ensuring a seamless user experience and robust functionality. Brand Development: Crafting compelling brand identities that resonate with your target audience. Website Development and SEO: Building high-performing websites optimized for search engines to enhance your online presence. IT Consultancy: Expert advice to align your IT strategy with your business goals. Social Media Marketing: Engaging campaigns to boost your brand's visibility and engagement on social platforms. Content Marketing: Creating valuable content that drives traffic and converts leads. IT Outsourcing: Efficient and reliable IT services to support your business operations. Headquartered in the UK, our seasoned professionals are dedicated to providing customized solutions that propel your business towards its goals. Connect with Softrobo today to discover how our experts can drive your organization's growth through cutting-edge digital strategies and technologies. **FAQs** 1. What is Softrobo? Softrobo is a digital solutions company specializing in mobile app development, brand development, website development and SEO, IT consultancy, social media marketing, content marketing, and IT outsourcing. 2. Where is Softrobo located? Softrobo is headquartered in the UK. 3. What kind of experience does Softrobo's Executive Team have? Softrobo's Executive Team has over 7 years of experience in creating and enhancing exceptional digital products. 4. How can Softrobo help my business grow? Softrobo provides customized digital solutions including mobile app development, SEO-optimized website development, effective social media marketing, and comprehensive IT consultancy to drive your business's growth. 5. What industries does Softrobo serve? Softrobo serves various industries, offering tailored digital solutions to meet unique business needs. 6. How can I get in touch with Softrobo? You can connect with Softrobo through our website or by contacting our customer service team directly. For more information and to get started with our services, visit Softrobo Website today!
softrobo
1,926,004
Day 13 of my 90-Devops project: Setting Up a CI/CD Pipeline with Docker and Kubernetes on GitLab
Prerequisites Basic Knowledge of Docker and Kubernetes GitLab Account Git Installed on...
0
2024-07-16T22:41:02
https://dev.to/arbythecoder/day-13-of-my-90-devops-project-setting-up-a-cicd-pipeline-with-docker-and-kubernetes-on-gitlab-52m
gitlab, cicd, docker, kubernetes
#### Prerequisites 1. **Basic Knowledge of Docker and Kubernetes** 2. **GitLab Account** 3. **Git Installed on Local Machine** 4. **Docker Installed on Local Machine** 5. **Minikube Installed on Local Machine** 6. **kubectl Installed on Local Machine** ### Step 1: Setting Up the Project 1. **Create a Project Directory** ```bash mkdir day13secureci cd day13secureci ``` 2. **Initialize a Git Repository** ```bash git init ``` 3. **Create a Dockerfile** ```bash touch Dockerfile ``` **Content of Dockerfile**: ```dockerfile # Use an official Node.js runtime as a parent image FROM node:14 # Set the working directory WORKDIR /usr/src/app # Copy package.json and package-lock.json COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application code COPY . . # Expose port 8080 EXPOSE 8080 # Run the application CMD ["node", "app.js"] ``` 4. **Create Kubernetes Deployment and Service Files** ```bash mkdir -p kubernetes touch kubernetes/deployment.yaml touch kubernetes/service.yaml ``` **Content of deployment.yaml**: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: my-app-deployment spec: replicas: 1 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app image: registry.gitlab.com/your-username/your-project-name:my-app:latest ports: - containerPort: 8080 ``` **Content of service.yaml**: ```yaml apiVersion: v1 kind: Service metadata: name: my-app-service spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 8080 type: LoadBalancer ``` 5. **Create GitLab CI/CD Configuration File** ```bash touch .gitlab-ci.yml ``` **Content of .gitlab-ci.yml**: ```yaml stages: - build - test - deploy variables: DOCKER_DRIVER: overlay2 before_script: - docker info build: stage: build script: - docker build -t my-app . - docker tag my-app:latest registry.gitlab.com/your-username/your-project-name:my-app:latest - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com - docker push registry.gitlab.com/your-username/your-project-name:my-app:latest test: stage: test script: - docker run --rm my-app npm test deploy: stage: deploy script: - kubectl apply -f kubernetes/deployment.yaml - kubectl apply -f kubernetes/service.yaml environment: name: production url: http://your-app-url.com ``` 6. **Create Your Application Code** - Create a simple Node.js application: ```bash touch app.js ``` **Content of app.js**: ```javascript const express = require('express'); const app = express(); const port = 8080; app.get('/', (req, res) => { res.send('Hello, World!'); }); app.listen(port, () => { console.log(`App running on http://localhost:${port}`); }); ``` **Create package.json**: ```bash touch package.json ``` **Content of package.json**: ```json { "name": "my-app", "version": "1.0.0", "description": "A simple Node.js app", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { "express": "^4.17.1" } } ``` ### Step 2: Setting Up GitLab 1. **Create a New Project on GitLab** - Log in to your GitLab account and create a new project. 2. **Connect Your Local Repository to GitLab** ```bash git remote add origin https://gitlab.com/your-username/your-project-name.git git add . git commit -m "Initial commit" git push -u origin master ``` ### Step 3: Running the Pipeline Locally Since GitLab CI/CD runs in a CI environment and cannot directly interact with your local Minikube cluster, you’ll need to simulate the pipeline locally or adjust your setup for local testing. 1. **Create a Script to Run the CI/CD Steps Locally** ```bash touch run_pipeline.sh ``` **Content of run_pipeline.sh**: ```bash #!/bin/bash # Set variables IMAGE_NAME="my-app" REGISTRY="registry.gitlab.com" USERNAME="your-username" PROJECT_NAME="your-project-name" IMAGE_TAG="${REGISTRY}/${USERNAME}/${PROJECT_NAME}:${IMAGE_NAME}" # Build Docker image echo "Building Docker image..." docker build -t ${IMAGE_NAME} . # Tag the Docker image echo "Tagging Docker image..." docker tag ${IMAGE_NAME}:latest ${IMAGE_TAG}:latest # Log in to GitLab container registry echo "Logging in to GitLab container registry..." docker login -u your-gitlab-username -p your-gitlab-password ${REGISTRY} # Push the Docker image to the registry echo "Pushing Docker image to registry..." docker push ${IMAGE_TAG}:latest # Run tests (assuming you have a test script) echo "Running tests..." docker run --rm ${IMAGE_TAG}:latest npm test # Deploy to Minikube echo "Deploying to Minikube..." kubectl apply -f kubernetes/deployment.yaml kubectl apply -f kubernetes/service.yaml echo "Pipeline execution completed." ``` 2. **Make the Script Executable** ```bash chmod +x run_pipeline.sh ``` 3. **Run the Script** ```bash ./run_pipeline.sh ``` ### Step 4: Verify Deployment on Minikube 1. **Start Minikube** ```bash minikube start ``` 2. **Check the Deployment and Service** ```bash kubectl get deployments kubectl get services ``` ### Common Issues and Troubleshooting 1. **Dockerfile Not Found** - Ensure the `Dockerfile` is in the project root directory and named correctly. 2. **Invalid Repository/Tag Format** - Ensure you have replaced placeholder values with actual GitLab username and project name. 3. **Missing Kubernetes Files** - Verify that `kubernetes/deployment.yaml` and `kubernetes/service.yaml` exist and have the correct content. ### Final Notes - Ensure all paths and filenames are correct. - Replace all placeholder values with your actual values. - Follow the steps sequentially to avoid errors.
arbythecoder
1,926,009
Confused by var, let, and const? Let's Clear the Mess
Ah, JavaScript variables! If you’ve ever found yourself scratching your head over the differences...
0
2024-07-16T22:38:17
https://dev.to/i-sultan0/confused-by-var-let-and-const-lets-clear-the-mess-4kn7
webdev, javascript, beginners, programming
Ah, JavaScript variables! If you’ve ever found yourself scratching your head over the differences between var, let, and const, you’re not alone. Understanding these three can feel like trying to navigate a maze. But fear not, dear coder! I am here to clarify the confusion. # Basic Concept : Assigning and Redeclaration of Variable ## Let's start with 'Var' - The Old Guard of JS The variable associated with 'var' keyword can be reassign and redeclared. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jc63a1o6iifkilfz0dim.png) ## 'Let' - The Modern contender The variable associated with 'let' can be reassign but cannot be redeclared. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v80fqv218yqeldi5gchp.png) ## 'Const' - The Immutable Force The variable associated with 'const' can neither be reassign not redeclared. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kijfxggfqdo9ifxs4bml.png) If you are a beginner and want to know about the bare minimum about variables, then this STOP is for you. Below we will discuss some advance concepts related to variables which will come in handy like Scoping and Hoisting . ## Scoping - Accessibility of variables within specific parts of code. Where 'var' has Function Scope but 'let' and 'const' are Block Scope. It means 'var' can be accessed throughout the function even in blocks (if,else etc..) And 'let' and 'const' can be accessed inside its own Block. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n781pjbpfsv38nkzlhtq.png) ## Hoisting - In simple words, it means using variables without declaring them is called Hoisting. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz7qlvydrknx4hb2xg6x.png) 'var' declaration is hoisted and initialized as 'undefined', you can use the variable before its declartion but its value will be undefined. 'let' and 'const' declaration is hoisted but not initialized, you cannot use the variable before its declaration, attempting to do so will result in 'reference error'. Thankyou for reading, I am starting my journey of posting, related to Web Development. Do like and share to support me. If you have any question regarding the topic or the info shared in the blog, please leave a comment.
i-sultan0
1,926,011
EnvLock: The Ultimate Env Manager
As developers, we often juggle multiple projects with different environment configurations. Whether...
0
2024-07-16T22:39:36
https://dev.to/siyabuilt/envlock-the-ultimate-env-manager-11ha
webdev, programming, productivity, security
As developers, we often juggle multiple projects with different environment configurations. Whether you're working with Python, Node.js, or Ruby, managing environment variables can be a hassle. Enter [EnvLock](https://envlock.com), a powerful and user-friendly SaaS solution that streamlines your environment variable management across various programming languages and projects. ### Why You Need an Env Manager Environment variables are crucial for keeping sensitive information secure and configuring your applications. However, managing these variables across different projects and team members can be challenging. An effective env manager solves these problems by: - Centralizing environment variable storage - Ensuring consistency across development environments - Enhancing security by separating sensitive data from code - Simplifying the onboarding process for new team members ### Introducing EnvLock: Your All-in-One Env Manager Solution EnvLock is a web-based SaaS platform designed to simplify environment variable management for developers and teams. With its intuitive dashboard, EnvLock offers a centralized location to create, manage, and share environment configurations across various projects and programming languages. #### Key Features of EnvLock 1. **User-Friendly Dashboard**: EnvLock provides an easy-to-use web interface where you can manage all your environment variables in one place. 2. **Project-Based Organization**: Create and organize multiple projects within EnvLock, each with its own set of environment files and variables. 3. **Flexible Environment Files**: Within each project, you can create multiple env files to suit different environments (e.g., development, staging, production). 4. **Easy Variable Management**: Add, edit, and delete variables with just a few clicks. EnvLock makes it simple to keep your configurations up-to-date. 5. **Sharing Capabilities**: Collaborate with team members by sharing projects or specific env files, ensuring everyone has access to the latest configurations. 6. **Export Functionality**: Easily export your environment variables in various formats compatible with different programming languages and frameworks. 7. **Secure Storage**: EnvLock uses encryption to store your sensitive data, ensuring that your environment variables remain protected. ### Getting Started with EnvLock To begin using EnvLock as your env manager, follow these simple steps: 1. **Sign Up**: Visit [https://envlock.com](https://envlock.com) and create an account. 2. **Create a Project**: Once logged in, create a new project for your application. 3. **Add Env Files**: Within your project, create one or more env files to organize your variables. 4. **Add Variables**: Start adding your environment variables to the appropriate env files. 5. **Share and Collaborate**: Invite team members to collaborate on your projects or share specific env files. 6. **Export and Use**: Export your environment variables in the format that suits your development environment and integrate them into your projects. ### EnvLock for Different Programming Languages EnvLock is designed to be language-agnostic, making it an ideal choice for developers working with various programming languages. Here's how EnvLock can benefit developers using different languages: #### Python Env Manager As a Python developer, you can use EnvLock to: - Store and manage environment variables for your Django, Flask, or any other Python projects. - Export variables in a format compatible with Python's `os.environ` or popular libraries like python-dotenv. - Easily switch between different configurations for development, testing, and production environments. #### Node Env Manager Node.js developers can leverage EnvLock to: - Centralize environment variable management for Express.js, Next.js, or any Node.js application. - Export variables in a format that works seamlessly with `process.env` or dotenv. - Maintain separate configurations for different deployment environments. #### Ruby Env Manager Ruby developers will find EnvLock useful for: - Managing environment variables for Rails applications or other Ruby projects. - Exporting variables in a format compatible with Ruby's `ENV` or gems like dotenv. - Organizing different sets of variables for various environments and deployment scenarios. ### Best Practices for Using EnvLock To get the most out of EnvLock, consider the following best practices: 1. **Organize Projects Clearly**: Create separate projects for different applications or services to keep your variables organized. 2. **Use Descriptive Names**: Choose clear and descriptive names for your env files and variables to make them easily understandable by all team members. 3. **Leverage Multiple Env Files**: Create separate env files for different environments (e.g., development, staging, production) within each project. 4. **Regular Reviews**: Periodically review your environment variables to ensure they are up-to-date and remove any that are no longer needed. 5. **Utilize Sharing Features**: Take advantage of EnvLock's sharing capabilities to ensure all team members have access to the latest configurations. 6. **Maintain Security**: Use EnvLock's secure storage, but also be cautious about who you share your env files with. 7. **Version Control Integration**: While EnvLock stores your variables securely, you can use its export feature to include non-sensitive configuration files in your version control system. ### Conclusion In today's complex development landscape, an efficient env manager is no longer a luxury—it's a necessity. EnvLock offers a robust, secure, and user-friendly solution for managing environment variables across various projects and programming languages. By centralizing your env management with EnvLock, you'll boost productivity, enhance security, and simplify collaboration within your development team. Don't let environment variable management slow you down. Try EnvLock today and experience the difference a well-designed, web-based env manager can make in your development workflow! Visit [https://envlock.com](https://envlock.com) to get started and take control of your environment variables with ease. Simplify your development process, enhance team collaboration, and keep your sensitive data secure with EnvLock – your ultimate environment variable management solution.
siyabuilt
1,926,012
Fullstack Blog with Tanstack Query, Zustand, Flask, JWT, Cookies | Register, Login, CRUD Post Tutorial
Learn how to build a fullstack blog application using modern technologies like Tanstack Query,...
0
2024-07-16T22:42:34
https://dev.to/henry_lee_1787e739b0c8191/fullstack-blog-with-tanstack-query-zustand-flask-jwt-cookies-register-login-crud-post-tutorial-2kjh
Learn how to build a fullstack blog application using modern technologies like Tanstack Query, Zustand for state management, Flask for backend, JWT for secure authentication, and cookies for session handling. This comprehensive tutorial covers user registration, login, and CRUD operations for blog posts. Perfect for developers looking to enhance their fullstack skills! Hashtags: #Fullstack #WebDevelopment #TanstackQuery #Zustand #Flask #JWT #Cookies #CRUD #Register #Login #CodingTutorial #Python #React Detailed Explanation: In this tutorial, we'll guide you step-by-step through the process of creating a robust fullstack blog application. You'll learn how to: Set up a Flask backend to handle authentication and CRUD operations. Secure your application using JWT (JSON Web Tokens) and manage sessions with cookies. Implement state management in your React frontend using Zustand. Fetch and mutate data efficiently with Tanstack Query. Build a seamless user experience with features like user registration, login, and full CRUD (Create, Read, Update, Delete) functionality for blog posts. Whether you're a beginner or an experienced developer, this tutorial will help you understand the integration of these powerful tools and improve your fullstack development skills.[](https://youtu.be/ZUOacqfUYj0?si=v-qweDJUCjSnp-tb)
henry_lee_1787e739b0c8191
1,926,013
[Day 2] - Configuring React Router
The second day is always a grind in my experience. Some of the excitement has passed, the work has...
28,085
2024-07-17T12:00:00
https://dev.to/nmiller15/day-2-configuring-react-router-42k
buildinpublic, webdev, react, devjournal
The second day is always a grind in my experience. Some of the excitement has passed, the work has truly set in. It’s never on day one that I realized the size of the project that I’ve just started. It’s been probably about a month since I’ve worked on a React, so the biginnings are moving a little slower than I want. Once I get more of the structure built, though, I will feel more comfortable and confident. ## Under the Hood ![Responsively Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vvyfm8atqusktet7xbv2.png) Most of the work today looked like this. Not near as exciting as seeing the fleshed out UI come together. However, I got the footer done, AND it’s operational too. The primary routing of this app is now handled by React Router. I’ve configured React Router a couple of times, and it comes out a little different each time. This configuration might be my favorite so far. ### Using a Layout Component I was having a hard time keeping my footer at the bottom of the screen in every route. I didn’t want to have to render in the Footer on every component, and using an outlet and child routes of the root make for a funky and deeply nested router. So, this time I tried a layout component that wraps each of the components displayed in my routes! Here’s what it looks like: ```javascript // Layout.js import React from 'react' import Footer from './Footer' const Layout = (props) => { return ( <> {props.children} <Footer /> </> ) } export default Layout; ``` Simple. The `props.children` call here lets me add more components inside Layout and everything will be rendered above the footer, even when I change routes. ## Setting Up My Router I have four primary routes: `/`, `/library`, `/account`, and `/about`, and to keep my `index.js` file from getting too cluttered, I did the router configuration in a separate file: ```javascript // router.js import { createBrowserRouter } from "react-router-dom"; import Layout from './Layout/Layout' import Home from './Home/Home' import Library from './Library/Library' import Account from './Account/Account' import About from './About/About' const router = createBrowserRouter([ { path: "/", element: ( <Layout> <Home /> </Layout> ), }, { path: "/library", element: ( <Layout> <Library /> </Layout> ) }, { path: "/account", element: ( <Layout> <Account /> </Layout> ) }, { path: "/about", element: ( <Layout> <About /> </Layout> ) } ]) export default router; ``` Since I’m tucking the router away, I also thought this might be a good place to render in my Layout componenet, rather than having to do it in each functional component. All that was left was to add the router provider in `index.js` : ```javascript // index.js import React from 'react'; import ReactDOM from 'react-dom/client' import { IconoirProvider } from 'iconoir-react'; import router from './router'; import { RouterProvider } from 'react-router-dom'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <React.StrictMode> <RouterProvider router={router} fallbackElement={( <div><p>Loading...</p></div> )} > <IconoirProvider iconProps={{ color: '#FFF8F4' }}> <App /> </IconoirProvider> </RouterProvider> </React.StrictMode> ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals(); ``` See why I didn’t want to have the router in here too? Seems like it would be a lot yeah? So, with these changes, and the addition of React boilerplate to my `Home`, `Library`, `Account`, and `About` pages, I now have a footer that changes my URL and navigates me through the application. ## Tidbits Something small I learned today that is going to have a big impact is the `rfce` code snippet! I’ve had these snippets installed for months, but I haven't really taken the time to learn them. I'm kicking myself for that now! `rfce` means React Functional Component Export. It automatically generates the following boilerplate: ```javascript import React from 'react' function Home () { return ( <div></div> ) } export default Home ``` It’s great, and it saved me a ton of time today. ## What's Next? I think I’ll build the About page the next time I sit down, since it will be relatively easy to knock out, and it is pretty static. From there, I have some global components that I need to create! If you like what you’re reading, give me a follow and share with a friend. Let me know what you’re working on down in the comments, or tell me how I can improve my process!
nmiller15
1,926,014
Precision Reloading Shop Review
Precision Reloading Shop is an online retailer that specializes in providing high-quality reloading...
0
2024-07-16T23:04:33
https://dev.to/precisionreloading/precision-reloading-shop-review-2dg8
ammo
[Precision Reloading Shop](https://precisionreloadingshop.com) is an online retailer that specializes in providing high-quality reloading supplies to hunters, sport shooters, and gun enthusiasts. According to their website, they offer a wide selection of reloading components from top brands, including [smokeless powder, primers, bullets, brass](https://precisionreloadingshop.com/product/federal-small-pistol-primers-box-of-1000), and [other essential tools and accessories](https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://precisionreloadingshop.com/product/federal-small-pistol-primers-box-of-1000/&ved=2ahUKEwjE3Zj4o5WHAxVJjo4IHQSxDsc4PBAWegQIDRAB&usg=AOvVaw1nBY0AnTNh0Ij47GfKl6H3). The shop's mission is to be a one-stop resource for all reloading needs, allowing their customers to customize their ammunition and improve shooting accuracy and performance. They emphasize the benefits of reloading, such as cost savings, enhanced shooting enjoyment, and the ability to create tailored cartridges for specific firearms and shooting styles. Precision Reloading Shop prides itself on offering competitive prices, secure payment options, and excellent customer support. They provide free shipping on all orders over $499 and promote various promotions and discounts to help their customers save money on their reloading supplies. Overall, Precision Reloading Shop appears to be a well-stocked and customer-focused online retailer that caters to the needs of both seasoned reloaders and those new to the hobby, ensuring their customers can find the right reloading components and equipment to enhance their shooting experiences. precision reloaders titewad powder precision reloading solutions imr 4831 powder alliant blue dot load data alliant steel powder winchester hd blue dot powder for sale precision reloading csupplies precision reloading catalog federal small pistol magnum primers small pistol magnum primers nobel sport 688 primers precision reloading equipment federal small pistol primer titewad powder for sale imr 4831 alliant steel load data blue dot powder ramshot tac powder titewad 12 gauge reloading data precision reloading.com cci 41 vihtavuori smokeless powder
precisionreloading
1,926,016
Introduction to ElasticSearch in Laravel
Introduction Elasticsearch is a tool that helps you search and analyze large amounts of...
0
2024-07-16T23:19:28
https://dev.to/devbalop/introduction-to-elasticsearch-in-laravel-1e34
### Introduction Elasticsearch is a tool that helps you search and analyze large amounts of information very quickly. Imagine it as a super-fast librarian who can find exactly what you need from a huge collection of books in just a few seconds. When used with Laravel, Elasticsearch makes it easy to add advanced search features to your projects. This article will explain how to integrate Elasticsearch with Laravel, its advantages, disadvantages, and provide some examples of how to use it. Think of Elasticsearch as a search engine for websites and apps, similar to how Google works for the internet. Here’s a simple comparison: - **Google Search**: Helps you find web pages, images, videos, etc from the entire internet quickly. - **Elasticsearch**: Helps you find specific information from your website or app's data quickly. Just like Google can instantly give you results for any search query, Elasticsearch can do the same for the data in your website or app. It’s incredibly fast and can handle a lot of data at once, making it ideal for large websites or applications with lots of information. ### Technical Definition of Elasticsearch Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As an open-source search engine, it is built on Apache Lucene and is known for its powerful and flexible search capabilities. Integrating Elasticsearch with Laravel, allows developers to implement advanced search functionalities efficiently. ### Advantages of Using Elasticsearch with Laravel 1. **High Performance**: Elasticsearch is optimized for full-text search and performs complex queries in milliseconds. 2. **Scalability**: It can scale horizontally, handling large volumes of data by distributing them across multiple nodes. 3. **Real-time Data**: Provides near real-time search and analytics, which is crucial for applications needing up-to-date information. 4. **Flexible Querying**: Supports a wide range of search capabilities, including fuzzy search, keyword matching, and complex boolean queries. 5. **Community and Documentation**: As a widely-used tool, Elasticsearch has comprehensive documentation and a large community for support. ### Disadvantages of Using Elasticsearch with Laravel 1. **Complexity**: Setting up and configuring Elasticsearch can be complex compared to traditional SQL databases. 2. **Resource Intensive**: It requires significant memory and CPU resources, especially for large-scale applications. 3. **Data Consistency**: Elasticsearch may not always guarantee immediate consistency, which could be an issue for some applications. 4. **Learning Curve**: Requires a learning curve for developers unfamiliar with its querying language and configuration. ### Applications of Elasticsearch in Laravel - **E-commerce Platforms**: For product search and filtering. - **Content Management Systems**: To enable powerful content search and indexing. - **Real-time Analytics**: For analyzing logs, metrics, and monitoring data in real-time. - **Social Networks**: To implement search functionalities for users, posts, and other entities. - **Enterprise Search**: For indexing and searching across internal documents and databases. ### Integrating Elasticsearch with Laravel To integrate Elasticsearch with Laravel, we use Laravel Scout, a driver-based library for adding full-text search to Eloquent models, and the Elasticsearch driver for Laravel Scout. #### Step 1: Install Elasticsearch First, install Elasticsearch on your local machine or server. Follow the installation instructions from the [Elasticsearch website](https://www.elastic.co/downloads/elasticsearch). #### Step 2: Install Laravel Scout and Elasticsearch Driver Run the following commands to install Laravel Scout and the Elasticsearch driver: ```bash composer require laravel/scout composer require babenkoivan/scout-elasticsearch-driver ``` #### Step 3: Configure Laravel Scout Publish the Scout configuration file and set the driver to Elasticsearch: ```bash php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider" ``` Update the `.env` file: ```env SCOUT_DRIVER=elastic ``` Configure Elasticsearch in `config/scout.php`: ```php 'driver' => env('SCOUT_DRIVER', 'algolia'), 'elasticsearch' => [ 'index' => env('ELASTICSEARCH_INDEX', 'your_index_name'), 'hosts' => [ env('ELASTICSEARCH_HOST', 'http://localhost'), ], ], ``` #### Step 4: Add Searchable Trait to Models To make a model searchable, add the `Searchable` trait to the model class. For example: ```php use Laravel\Scout\Searchable; class Post extends Model { use Searchable; public function toSearchableArray() { return $this->toArray(); } } ``` #### Step 5: Index Data Index your existing data using the `scout:import` command: ```bash php artisan scout:import "App\\Models\\Post" ``` #### Step 6: Perform Search Queries Use the `search` method to perform search queries on your model: ```php $posts = Post::search('example search term')->get(); ``` ### Sample Usage Here’s a simple search implementation in Laravel: #### Search Form (Blade Template) ```html <form action="{{ route('posts.search') }}" method="GET"> <input type="text" name="query" placeholder="Search posts..."> <button type="submit">Search</button> </form> ``` #### Controller Action ```php use App\Models\Post; public function search(Request $request) { $query = $request->query; $posts = Post::search($query)->get(); return view('posts.search_results', compact('posts')); } ``` #### Search Results Blade Template ```html @if($posts->isEmpty()) <p>No posts found.</p> @else <ul> @foreach($posts as $post) <li>{{ $post->title }}</li> @endforeach </ul> @endif ``` ### Conclusion Integrating Elasticsearch with Laravel provides powerful and flexible search capabilities that enhance the functionality of any application. Despite the complexity and resource requirements, the benefits of high performance, scalability, and real-time data handling make Elasticsearch a valuable tool for developers. By following the steps outlined above, you can efficiently implement Elasticsearch in your Laravel projects, providing users with a robust search experience.
devbalop
1,926,037
HIRE LEE ULTIMATE HACKER FOR SCAMMED CRYPT0 RECOVERY.
LEEULTIMATE HACKER@ AOL. COM Support @ leeultimatehacker .com telegram:LEEULTIMATE wh@tsapp +1 (715)...
0
2024-07-16T23:29:19
https://dev.to/zoe_lola_3e15ee842c361d1f/hire-lee-ultimate-hacker-for-scammed-crypt0-recovery-ged
recoverlostcrypto, cryptorecoveryexpert
LEEULTIMATE HACKER@ AOL. COM Support @ leeultimatehacker .com telegram:LEEULTIMATE wh@tsapp +1 (715) 314 - 9248 https://leeultimatehacker.com I wanted to take a moment to address a topic that is of great concern - the effects of online binary investments. Binary investments can massively improve one’s financial situation but it can also cause devastating financial losses when you don’t get it done right, wreaking havoc on your physical health, mental well-being, and relationships. I was so excited to finally have help from Lee Ultimate Hacker in this David & Goliath battle I had been fighting alone. I reached out to the team, Yet at the same time, I was very scared given what I heard about dishonest digital assets recovery services. My heart racing, I listened to what the man had to say, and asked my questions, all his replies were on point, and professionally tackled the questions I’d been asking myself, which did ease my nerves a little. I gave my permission immediately for them to proceed with the tracing process, forwarding all available information and details of my transaction with the company to their email support. In less than an hour, he was reading the tracing report to me which concluded on what I was already suspecting. Thankfully, Lee Ultimate Hacker also informed me that my case could still be resolved and my funds recovered back to me, then he explained how the team would immediately go about the process which lasted for about 2 days then I got a deposit confirmation in my wallet the next morning. It has indeed been a life-changing experience for me but I’m glad I got the right professionals to step in; they helped make sense of what seemed like spinning tires in the mud because I was distraught at first. Thanks for being good people. Faith in humanity was restored at least a bit. Lee Ultimate Hacker proved to be a light in the darkness of my financial crisis. When I initially stumbled upon their services, I was skeptical. The internet is filled with stories of individuals being taken advantage of by recovery firms promising the world but delivering little. My hesitation quickly dissolved, however, as I interacted with their team. From the outset, they exuded professionalism and genuine concern for my situation. They understood the complexities of online fraud and approached my case with diligence and expertise. The transparency of their process was a breath of fresh air. Unlike my previous encounters with recovery services that left me feeling more uncertain, Lee Ultimate Hacker laid out a clear plan of action. They patiently explained each step, ensuring I understood the strategies they would employ to trace and recover my lost funds. This level of clarity was crucial in rebuilding my trust and confidence in their capabilities. The speed with which Lee Ultimate Hacker operated was astounding. Within hours of initiating contact, they had compiled a comprehensive tracing report that confirmed my suspicions regarding the fraudulent activities. Moreover, they swiftly assured me that recovery was indeed possible. This assurance was a lifeline during a time when I felt helpless and betrayed. Throughout the process, communication remained a cornerstone of their service. The team at Lee Ultimate Hacker maintained constant contact, updating me on progress and promptly addressing any concerns I had along the way. Their availability and responsiveness alleviated much of the anxiety I initially felt, allowing me to focus on other aspects of rebuilding my life. When the moment of resolution arrived – a confirmation of the funds restored to my wallet – I was overcome with relief and gratitude. Lee Ultimate Hacker not only recovered my financial losses but also restored my faith in the power of integrity and professionalism. They turned what initially seemed like an insurmountable challenge into a manageable, albeit transformative, experience. Looking back on my journey with Lee Ultimate Hacker, I am struck by their unwavering commitment to justice and their dedication to their clients. They are more than just a recovery service; they are guardians of hope for those navigating the treacherous waters of online fraud. My encounter with them was not just about reclaiming lost funds; it was about reclaiming a sense of security and trust in a digital world fraught with uncertainty. I wholeheartedly recommend Lee Ultimate Hacker to anyone who finds themselves ensnared in the aftermath of online financial scams. They are a beacon of integrity and competence in an industry often tainted by deception. Trust in their expertise, and allow them to guide you towards resolution and recovery. My experience with Lee Ultimate Hacker has been nothing short of life-changing, and I am profoundly grateful for their unwavering support and professionalism during my darkest time ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7borxvdf0ywb5leqq74.jpg)
zoe_lola_3e15ee842c361d1f
1,926,038
no AdMob account input AdMob 계좌 입력란이 없고
** I was confused because there was no AdMob account input field and only a part asking for identity...
0
2024-07-16T23:29:23
https://dev.to/sidcodeme/no-admob-account-input-admob-gyejwa-ibryeograni-eobsgo-103i
admob, 애드몹
** I was confused because there was no AdMob account input field and only a part asking for identity verification appeared. AdMob 계좌 입력란이 없고, 본인인증 하라는 부분만 나와서 당황했다. ## AdMob sends a mail letter with a PIN number to the user when the first $10 is reached and after entering the PIN number and verifying identity, the account information field to receive the deposit opens. ## AdMob은 최초 $10 가 되는 시점에 사용자에게 pin번호가 있는 우편 편지을 보내고, 이 후에 pin번호 입력과 본인확인 후 입금받을 계좌 정보란이 열린다. **
sidcodeme
1,926,040
[Game of Purpose] Day 59 - Following a path either by distance or Spline points
Today I was playing around with supporting 2 ways of following a path. By distance - Given a path...
27,434
2024-07-16T23:37:31
https://dev.to/humberd/game-of-purpose-day-59-4d5i
gamedev
Today I was playing around with supporting 2 ways of following a path. * By distance - Given a path it moves to a point every `x` distance. * By points - Given a path it moves to each point the Spline has configured. https://blueprintue.com/blueprint/zmunmar-/ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/01blxebe475zw7illax6.png) And my full path-following code looks like this: ```cpp #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "Components/SplineComponent.h" #include "DrawDebugHelpers.h" #include "SplineFollowerBase.generated.h" UENUM(BlueprintType) enum class EFollowingType : uint8 { ByDistance UMETA(DisplayName = "By Distance"), ByPoints UMETA(DisplayName="By Points") }; UCLASS(BlueprintType, Blueprintable) class SKY_PATROL_API USplineFollowerBase : public UActorComponent { GENERATED_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline") USplineComponent* TargetSpline; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline") float DistanceToMove = 200.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline") EFollowingType FollowingType = EFollowingType::ByDistance; protected: UFUNCTION(BlueprintCallable) UPARAM(DisplayName="NextTargetDistance") float CalculateNextTargetDistanceBase(); UFUNCTION(BlueprintCallable) UPARAM(DisplayName="NextPointIndex") int CalculateNextPointIndexBase(); private: float NextTargetDistance = -1.0f; int NextPointIndex = -1; }; ``` ```cpp #include "SplineFollowerBase.h" #include "Utils/MyStringUtils.h" float USplineFollowerBase::CalculateNextTargetDistanceBase() { check(TargetSpline != nullptr); const auto TargetSplineTotalLength = TargetSpline->GetSplineLength(); // staring the movement if (NextTargetDistance < 0.0f) { NextTargetDistance = 0.0f; } // looping else if (NextTargetDistance >= TargetSplineTotalLength) { NextTargetDistance = 0.0f; } else { NextTargetDistance = FMath::Clamp(NextTargetDistance + DistanceToMove, 0.0f, TargetSplineTotalLength); } PrintString(FString::Printf(TEXT("NextTargetDistance: %f"), NextTargetDistance)); return NextTargetDistance; } int USplineFollowerBase::CalculateNextPointIndexBase() { check(TargetSpline != nullptr); const auto TargetSplineTotalPoints = TargetSpline->GetNumberOfSplinePoints(); NextPointIndex = (NextPointIndex + 1) % TargetSplineTotalPoints; PrintString(FString::Printf(TEXT("NextPointIndex: %d"), NextPointIndex)); return NextPointIndex; } ```
humberd
1,926,041
How to structure your files with VIPER Architecture
Maybe you already had the theory of how VIPER Architecture work but that's only the THEORY, in the...
0
2024-07-16T23:39:48
https://dev.to/sazardev/how-to-structure-your-files-with-viper-architecture-4do
architecture, mobile, viper, development
Maybe you already had the theory of how VIPER Architecture work but that's only the THEORY, in the real work can be painful implement a Software Architecture because you can have a lot of cases that you can't know how to implement correctly accordly VIPER Architecture (But this can happen when whatever Architecture). I'll explain you how to implement correctly VIPER with a common cases, but if you have an especific scenario you can comment to discuss how VIPER can solvent correctly. ## PhonebookApp (iOS) A classic one. Let's supouse that you need to do a simple Phonebok application where stores contact. ```python PhonebookApp # Root directory of the application ├── Common # Shared code between features │ ├── Models # Data models representing entities │ ├── Contact.swift # Represents a single contact with its information │ └── ContactGroup.swift # Represents a group of contacts │ ├── Utils # Utility classes for common functionalities │ ├── NetworkManager.swift # Handles communication with network services │ └── StorageManager.swift # Handles data persistence and retrieval │ └── ViewModels # View models for data presentation │ ├── ContactDetailViewModel.swift # Prepares data for the contact detail view │ ├── ContactGroupListViewModel.swift # Prepares data for the contact group list view │ └── ContactListViewModel.swift # Prepares data for the contact list view ├── Features # Individual features of the application # Feature for managing a single contact ├── ContactDetail ├── Views # UI components for displaying the contact │ └── ContactDetailView.swift # Xcode Storyboard or SwiftUI view for contact details ├── Interactors # Business logic for contact data │ └── ContactDetailInteractor.swift # Fetches, updates, and deletes contact data ├── Presenters # Prepares data for the contact detail view │ └── ContactDetailPresenter.swift # Receives data from interactor and formats it for view └── Routers # Navigation logic for the contact detail screen └── ContactDetailRouter.swift # Handles navigation to other features from contact detail # Feature for managing contact groups ├── ContactGroupList ├── Views # UI components for displaying contact groups │ └── ContactGroupListView.swift # Xcode Storyboard or SwiftUI view for contact group list ├── Interactors # Business logic for contact group data │ └── ContactGroupListInteractor.swift # Fetches, updates, and manages contact groups ├── Presenters # Prepares data for the contact group list view │ └── ContactGroupListPresenter.swift # Receives data from interactor and formats it for view └── Routers # Navigation logic for the contact group list screen └── ContactGroupListRouter.swift # Handles navigation to other features from contact group list # Feature for managing the list of contacts └── ContactList ├── Views # UI components for displaying contacts │ └── ContactListView.swift # Xcode Storyboard or SwiftUI view for contact list ├── Interactors # Business logic for contact data │ └── ContactListInteractor.swift # Fetches, updates, and manages contacts ├── Presenters # Prepares data for the contact list view │ └── ContactListPresenter.swift # Receives data from interactor and formats it for view └── Routers # Navigation logic for the contact list screen └── ContactListRouter.swift # Handles navigation to other features from contact list ├── App # Entry point and core application logic │ ├── AppDelegate.swift # Manages the application lifecycle │ ├── SceneDelegate.swift # Manages window scene lifecycle and transitions on iOS 13+ │ └── MainCoordinator.swift # Coordinates navigation between features ├── Tests # Unit tests for application components │ ├── CommonTests # Tests for shared code │ ├── ModelsTests.swift # Unit tests for `Contact` and `ContactGroup` models │ └── UtilsTests.swift # Unit tests for `NetworkManager` and `StorageManager` │ ├── FeaturesTests # Tests for individual features │ ├── ContactDetailTests.swift # Unit tests for contact detail functionality │ ├── ContactGroupListTests.swift # Unit tests for contact group list functionality │ └── ContactListTests.swift # Unit tests for contact list functionality │ └── AppTests # Tests for application entry point │ └── AppDelegateTests.swift # Unit tests for `AppDelegate` └── Resources # Assets and configuration files ├── Images.xcassets # App icons and other images ├── LaunchScreen.storyboard # Storyboard for the launch screen └── Info.plist # Configuration file for the application ``` ## Shop App (Android) ```python ShopApp ├── app │ ├── build.gradle │ ├── src │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── ... # app assets like images │ ├── java │ └── com.yourcompany.shop │ ├── data │ ├── model │ ├── Product.java # Represents a product with details │ └── ProductCategory.java # Represents a product category │ ├── network │ └── ApiManager.java # Handles network communication │ ├── persistence │ └── LocalStorage.java # Handles data persistence on device │ ├── repository │ └── ProductRepository.java # Provides access to product data │ ├── features │ ├── productdetail # Feature for managing a single product detail │ │ ├── contract │ │ │ ├── ProductDetailContract.kt # Interface for VIPER communication │ │ │ ├── ProductDetailView.kt # Interface for View │ │ │ ├── ProductDetailInteractor.kt # Interface for Interactor │ │ │ ├── ProductDetailPresenter.kt # Interface for Presenter │ │ │ └── ProductDetailRouter.kt # Interface for Router │ │ ├── data │ │ │ └── ProductDetailRepositoryImpl.kt # Implementation of ProductRepository for product detail │ │ ├── presentation │ │ │ ├── ProductDetailPresenterImpl.kt # Implementation of ProductDetailPresenter │ │ ├── ui │ │ │ └── ProductDetailActivity.kt # Activity for displaying product details │ │ └── ... (other implementation classes) │ ├── productlist # Feature for managing the product list │ │ ├── contract │ │ │ ├── ProductListContract.kt # Interface for VIPER communication │ │ │ ├── ProductListView.kt # Interface for View │ │ │ ├── ProductListInteractor.kt # Interface for Interactor │ │ │ ├── ProductListPresenter.kt # Interface for Presenter │ │ │ └── ProductListRouter.kt # Interface for Router │ │ ├── data │ │ │ └── ProductListRepositoryImpl.kt # Implementation of ProductRepository for product list │ │ ├── presentation │ │ │ ├── ProductListPresenterImpl.kt # Implementation of ProductListPresenter │ │ ├── ui │ │ │ └── ProductListActivity.kt # Activity for displaying product list │ │ └── ... │ ├── ... │ └── util │ └── ... # Utility classes │ └── gradle.properties │ └── gradlew.bat # or gradlew (depending on OS) ├── build.gradle ├── gradle.properties └── local.properties # Optional for local development configuration ```
sazardev
1,926,042
Access Request Headers in a Rails Controller
Heads Up A coworker presented a failing request spec. They asked if they were passing...
0
2024-07-16T23:43:47
https://dev.to/kevin_j_m/access-request-headers-in-a-rails-controller-3b27
ruby, rails
## Heads Up A coworker presented a failing request spec. They asked if they were passing headers incorrectly in the test. ```ruby it "reports to be a teapot when asked to brew coffee" do headers = { "X-COMMAND" => "brew coffee" } get drinks_url, headers: headers expect(response.status).to eq 418 end ``` They wrote the test exactly like I'd [expect](https://rspec.info/features/6-0/rspec-rails/request-specs/request-spec/). But, rather than providing the 418, a 200 OK was the status code. I then looked at the controller this request spec was accessing. ```ruby def index if headers["X-COMMAND"] == "brew coffee" head 418 end @drinks = Drink.all end ``` Nothing *obvious* caught my attention. But now that I'd been effectively [nerd sniped](https://xkcd.com/356/), I had to figure out what was going on. ## Heading In For a Closer Look I added a breakpoint inside the controller to inspect the headers when the test was running. ```ruby irb:001:0> headers => {"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"0", "X-Content-Type-Options"=>"nosniff", "X-Download-Options"=>"noopen", "X-Permitted-Cross-Domain-Policies"=>"none", "Referrer-Policy"=>"strict-origin-when-cross-origin"} ``` As expected, given the failing test, the `X-COMMAND` header was nowhere to be found. But luckily, they did seem familiar to me. They looked to be Rails' [default headers](https://github.com/rails/rails/blob/f1aa436d738af1852b610189aeb93a5609bfe3b0/actionpack/lib/action_dispatch/railtie.rb#L30). But those [default headers](https://edgeguides.rubyonrails.org/configuring.html#config-action-dispatch-default-headers) are for the __response__, not the *request*. I still had my console session with my breakpoint, so I asked what kind of headers we were interacting with. ```ruby irb:002:0> headers.class => ActionDispatch::Response::Header ``` This confirmed we were dealing with the response, not request, headers. ## Heads Down I needed to trace my way backwards from what I have or know. I asked what defines the headers method by asking for the [source location](https://ruby-doc.org/3.2.1/Method.html#method-i-source_location). That'll tell me the file and line number. ```ruby irb:003:0> method("headers").source_location => [".../gems/actionpack-7.0.3.1/lib/action_controller/metal.rb", 147] ``` [That line](https://github.com/rails/rails/blob/7-0-stable/actionpack/lib/action_controller/metal.rb#L147) shows `headers` delegated to an [internal attribute](https://guides.rubyonrails.org/active_support_core_extensions.html#internal-attributes) `@_response`. ```ruby delegate :headers, :status=, :location=, :content_type=, :status, :location, :content_type, :media_type, to: "@_response" ``` That internal attribute is accessible in the controller by calling `response`. We can see that from the `attr_internal` definition on [line 145](https://github.com/rails/rails/blob/7-0-stable/actionpack/lib/action_controller/metal.rb#L145). ```ruby attr_internal :response, :request ``` `response` isn't the ONLY internal attribute on that line though. There's ALSO a `request`. In our console, let's see what that request is. ```ruby irb:004:0> request.class => ActionDispatch::Request ``` That class also [responds to](https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-headers) `headers`, providing the [request headers](https://api.rubyonrails.org/classes/ActionDispatch/Http/Headers.html). ## Heading In For The Close The change to get our test to pass is small. We don't want the response headers, which is what the `headers` variable is. We need the request headers, which are accessible at `request.headers`. ```ruby def index if request.headers["X-COMMAND"] == "brew coffee" head 418 end @drinks = Drink.all end ``` Now that we're accessing the headers of the __request__ our test passes. Naming is hard. Asking for a controller's headers could be either the request or the response headers. Turns out, Rails will give you the response headers. To access the request headers, explicitly ask for them from the request object.
kevin_j_m
1,926,043
Top Github repositories for 10+ programming languages
Hello friends, This is an extensive list of GitHub repositories to begin and grow your journey as a...
0
2024-07-16T23:58:23
https://dev.to/shreyvijayvargiya/top-github-repositories-for-10-programming-languages-10pi
webdev, beginners, programming, githunt
Hello friends, This is an extensive list of GitHub repositories to begin and grow your journey as a programmer. This collection contains the 10+ languages' top GitHub repositories to learn for FREE and stay updated as well. ## How to use it? It's simple whenever you want to start learning something get the basic overview as well as a roadmap. These repositories provide a sort of roadmap, for example, for anyone who wants to learn mobile app development in Flutter or React Native the following added GitHub repository will certainly help you to proceed and learn easily as well as get the overview. ## Is it good for Experienced devs? To all experience devs, yes, most of us know nothing about another programming language because we are working a lot in our niche. Anytime you want to switch to try new language the following repositories collection will be a good starting point. ## What about other programming languages? I'll add them in future, so feel free to mention them in the comments section. ## Check roadmap templates Lastly, I would love to take you a fraction of a second, we have 3 templates to begin and embark on your journey as a developer. [Frontend Roadmap](https://shreyvijayvargiya.gumroad.com/l/frontend-development-roadmap?layout=profile) [React Native Roadmap](https://shreyvijayvargiya.gumroad.com/l/nodejs-roadmap?layout=profile) [Node.js Roadmap](https://shreyvijayvargiya.gumroad.com/l/react-native-roadmap?layout=profile) PS - All the below links and another such extensive resource can be found in the above templates ## Javascript repos [WTFJS](https://github.com/denysdovhan/wtfjs) This repository explains the core mind-boggling JS concepts that always trigger the developer's mind, it shows how crazy JS is. It explains more than 20/30 JS concepts inspired by the book WTFJS. [30 Days of JS preparation](https://github.com/Asabeneh/30-Days-Of-JavaScript) 30 Days of Javascript preparation that teaches JS topics in 30 days one topic per day, quite a good roadmap as well to learn JS from scratch. [JS Algorithms](https://github.com/trekhleb/javascript-algorithms) JS Algorithms and Data Structures entire documentation teaching ranges of or almost all the DSA required topics javascript-algorithms [JS Questions and Preparations](https://github.com/lydiahallie/javascript-questions) Long list of JS questions along with answers to go through all the JS interview prep, concepts in one go. [Technical Interview JS](https://github.com/yangshun/tech-interview-handbook) This is self-explanatory and helps a lot of developers to crack interviews in JS as frontend/backend developer positions. [You Don't Know JS](https://github.com/getify/You-Dont-Know-JS) ## React JS Repos [Awesome React](https://github.com/enaqx/awesome-react?tab=readme-ov-file#readme) The awesome reactjs packages, tools, resources, npm modules, interview questions, remove job resources, podcasts, books, react-native and more in one single repository [CodingKnite - Frontend Development Resources](https://github.com/codingknite/frontend-development?tab=readme-ov-file#blogs) Github repository for Frontend devs, collection of Frameworks, Packages, Websites, Frontend Blogs, Tutorials, Interview questions, Books, Podcasts, Youtube resources and so on [Reactjs Interview Questions](Reactjs 500+ Interview questions of all categories) An extensive list of interview questions with answers, detailed explanation of concepts such as state management, Virtual DOM, props, and prototypes. [React Bits](https://github.com/vasanthk/react-bits?tab=readme-ov-file) [30 Seconds of React](https://github.com/Chalarangelo/30-seconds-of-react?tab=readme-ov-file) [React Developer Roadmap](https://github.com/adam-golab/react-developer-roadmap?tab=readme-ov-file) [Under the Hood Reactjs](https://github.com/Bogdan-Lyashenko/Under-the-hood-ReactJS) [Reactjs interview questions](https://github.com/sudheerj/reactjs-interview-questions) [Awesome React](https://github.com/enaqx/awesome-react) ## Vue JS repos [Awesome Vuejs](https://github.com/vuejs/awesome-vue) ## C++ repos [Awesome CPP Libraries](https://faraz.work/awesome-cpp/) [Awesome C++ resources](https://github.com/rigtorp/awesome-modern-cpp) [Free programming books repository](https://github.com/EbookFoundation/free-programming-books) [Coding interview university](https://github.com/jwasham/coding-interview-university) [Roadmap for software developer](https://github.com/kamranahmedse/developer-roadmap/blob/master/readme.md) ## Python [30 Days of Python](https://github.com/Asabeneh/30-Days-Of-Python) [The algorithms python](https://github.com/TheAlgorithms/Python) [Amazing Python scripts](https://github.com/avinashkranjan/Amazing-Python-Scripts) [Python Geekbook](https://github.com/geekcomputers/Python) [Python programming exercise](https://github.com/zhiwehu/Python-programming-exercises) [Python guide](https://github.com/realpython/python-guide/tree/master) ## Rust repos [Rust Learning](https://github.com/ctjhoa/rust-learning) [Awesome Rust](https://github.com/rust-unofficial/awesome-rust) [Comprehensive Rust](https://github.com/google/comprehensive-rust) ## Go repos [Awesome Go](https://github.com/avelino/awesome-go) [Learn Go](https://github.com/inancgumus/learngo) [Learning Go](https://github.com/vladimirvivien/learning-go) ## Nodejs [Awesome Nodejs learning repo](https://github.com/kryz81/awesome-nodejs-learning) [Nodejs learning repo](https://github.com/sergtitov/NodeJS-Learning) [Nodejs practical tutorials](https://github.com/practical-tutorials/project-based-learning) ## AWS [AWS practical guide](https://github.com/open-guides/og-aws) [AWS Zero to Hero](https://github.com/iam-veeramalla/aws-devops-zero-to-hero) [Awesome AWS](https://github.com/donnemartin/awesome-aws) ## SQL [SQL MAP, learning SQL](https://github.com/sqlmapproject/sqlmap) [Data Engineering SQL](https://github.com/DataTalksClub/data-engineering-zoomcamp) ## MongoDB [Awesome mongoDB](https://github.com/ramnes/awesome-mongodb) [MongoDB basics](https://github.com/learning-zone/mongodb-basics) [MongoDB interview questions](https://github.com/Devinterview-io/mongodb-interview-questions) ## Backend Development [Awesome Nodejs resources](https://github.com/goldbergyoni/nodebestpractices?source=post_page-----55c9f5b72cec--------------------------------) [Awesome backend](https://github.com/zhashkevych/awesome-backend?source=post_page-----55c9f5b72cec--------------------------------) [Backend resources](https://github.com/shahednasser/awesome-resources?source=post_page-----55c9f5b72cec--------------------------------) [System design explanation](https://github.com/donnemartin/system-design-primer?source=post_page-----55c9f5b72cec--------------------------------) ## Odin programming language [Awesome Odin](https://github.com/jakubtomsu/awesome-odin) [Odin examples](https://github.com/odin-lang/examples) ## Machine Learning && Data Science && AI [Machine Learning Youtube courses](https://github.com/dair-ai/ML-YouTube-Courses) [Mathematics for Machine Learning](https://github.com/mml-book/mml-book.github.io) [MIT deep learning PDF](https://github.com/janishar/mit-deep-learning-book-pdf) [Machine learning for beginners](https://github.com/microsoft/ML-For-Beginners) [Data science learning bootcamp](https://github.com/DataTalksClub/machine-learning-zoomcamp) [Machine learning and deep learning tutorials](https://github.com/ujjwalkarn/Machine-Learning-Tutorials) [Awesome machine learning](https://github.com/josephmisiti/awesome-machine-learning) [Awesome production machine learning](https://github.com/EthicalML/awesome-production-machine-learning) [Awesome data science](https://github.com/academic/awesome-datascience) [Best of ml python](https://github.com/ml-tooling/best-of-ml-python) [Tensorflow examples](https://github.com/aymericdamien/TensorFlow-Examples) [Machine learning interview](https://github.com/khangich/machine-learning-interview) [Machine learning deep learning computer vision and NLP](https://github.com/kmario23/deep-learning-drizzle#tada-deep-learning-deep-neural-networks-confetti_ball-balloon) [Data science python notebooks](https://github.com/donnemartin/data-science-ipython-notebooks) [500 AI machine learning NLP programming projects](https://github.com/ashishpatel26/500-AI-Machine-learning-Deep-learning-Computer-vision-NLP-Projects-with-code) [Data science for beginners](https://github.com/microsoft/Data-Science-For-Beginners) [Ai learning](https://github.com/apachecn/ailearning) ## Game Development [Game dev resources](https://github.com/Kavex/GameDev-Resources) ## Web3 [Awesome web3](https://github.com/ahmet/awesome-web3) [Ethereum Book](https://github.com/ethereumbook/ethereumbook) ## React Native [React native examples](https://github.com/amandeepmittal/react-native-examples) [Awesome react-native library](https://github.com/jondot/awesome-react-native) [React native resources](https://github.com/chefk5/react-native-resources) ## Solidity [Awesome Solidity](https://github.com/bkrem/awesome-solidity) [Full blockchain solidity course](https://github.com/smartcontractkit/full-blockchain-solidity-course-js) ## Flutter [Awesome flutter](https://github.com/Solido/awesome-flutter) [Flutter Samples](https://github.com/flutter/samples) ## Cpp [Awesome C++](https://github.com/fffaraz/awesome-cpp) [Modern Cpp](https://github.com/rigtorp/awesome-modern-cpp) [Awesome cpp examples](https://github.com/pawelborkar/awesome-repos) [LearnCPP](https://github.com/Lakhankumawat/LearnCPP) [CPP best practises](https://github.com/cpp-best-practices/cppbestpractices)
shreyvijayvargiya
1,926,044
Home Loan EMI Calculation Made Simple - Tools and Tips for Smart Borrowing
Many find calculating home loan EMIs daunting, but with the right tools and tips, you can make smart...
0
2024-07-17T00:09:43
https://dev.to/moovendran_veerapandian/home-loan-emi-calculation-made-simple-tools-and-tips-for-smart-borrowing-5fbj
homeloan, homeloantips, homeloanindia
Many find calculating home loan EMIs daunting, but with the right tools and tips, you can make smart borrowing decisions effortlessly. Whether you're a first-time homebuyer or looking to refinance, understanding how EMIs work is crucial. In this blog post, we break down the process for you and provide handy tools to simplify the calculations. By the end, you'll be equipped to make informed decisions and manage your home loan EMIs with confidence. Let's dive in! ## Key Takeaways: Understanding EMI Calculation: Knowing how Home Loan EMI is calculated helps borrowers plan repayments effectively. Use Online EMI Calculators: Online tools simplify the process of estimating EMIs based on loan amount, tenure, and interest rate. Smart Borrowing Tips: Opt for shorter loan tenure, make larger down payments, and compare loan offers to save on interest costs. ## The Importance of Accurate EMI Calculation **Why EMI calculation matters** Accurately calculating your Equated Monthly Instalment (EMI) is crucial when taking out a home loan. Knowing the exact amount you will need to pay each month helps you budget effectively and prevents any financial surprises. Having a clear understanding of your EMI amount allows you to plan your finances better and ensures that you can comfortably manage your repayment obligations without straining your budget. ## Common mistakes to avoid To ensure that you have a smooth borrowing experience, it is important to avoid common mistakes when calculating your EMI. One of the most common errors is overlooking additional charges such as processing fees or prepayment penalties, which can significantly impact your overall repayment amount. Another mistake to avoid is relying on approximate figures instead of using an online EMI calculator or seeking assistance from a financial expert to get an accurate estimation. Avoiding these mistakes not only helps you make informed decisions but also saves you from potential financial setbacks in the future. By taking the time to calculate your EMI accurately and considering all relevant factors, you can ensure a hassle-free borrowing experience and better manage your finances. ## Factors Affecting Home Loan EMI Any home loan borrower needs to understand the various factors that can affect the Equated Monthly Installment (EMI) of their loan. These factors play a crucial role in determining the overall cost of your loan and the amount you will be required to pay each month. Here are some significant factors that influence your home loan EMI: Loan amount and interest rate One of the primary factors that impact your home loan EMI is the loan amount and the interest rate offered by the lender. A higher loan amount or a higher interest rate will result in a higher EMI. It is imperative to strike a balance between the loan amount and interest rate to ensure that your EMI is affordable while also keeping the total interest payout within a reasonable range. Loan tenure and repayment frequency The loan tenure and repayment frequency also have a significant impact on your EMI amount. The longer the loan tenure, the lower your EMI will be, but you will end up paying more interest over the life of the loan. On the other hand, opting for a shorter tenure will increase your EMI but reduce the total interest payout. It is crucial to consider your financial situation and choose a loan tenure that aligns with your repayment capacity. This aspect of your loan determines how long you will be paying off your debt and how frequently you need to make payments. Make sure to select a repayment frequency that suits your cash flow and helps you manage your finances effectively. **Credit score and its impact** Your credit score plays a vital role in determining the interest rate offered by lenders. A higher credit score signifies your creditworthiness, leading to lower interest rates and, subsequently, a lower EMI. On the contrary, a lower credit score may result in higher interest rates, increasing your monthly EMI payments. Your credit score can significantly impact the overall cost of your loan and your borrowing capacity. Maintaining a good credit score is crucial to securing favorable loan terms and minimizing your EMI burden. In a nutshell, understanding the factors that influence your home loan EMI can help you make informed decisions when borrowing. By considering these aspects carefully and utilizing online tools for EMI calculation, you can ensure that your home loan borrowing is not only manageable but also financially prudent. **EMI Calculation Methods** Many borrowers wonder about the best way to calculate their Equated Monthly Installments (EMI) for a home loan. There are several methods you can use to calculate EMI, each with its own pros and cons. **Manual calculation using formulas** An easy way to calculate EMI manually is by using the formula: EMI = [P x R x (1+R)^N]/[(1+R)^N-1]. Here, P is the loan amount, R is the monthly interest rate, and N is the number of monthly installments. While this method gives you a basic understanding of how EMI is calculated, it can be time-consuming and prone to errors. Online EMI calculators and their benefits One convenient way to calculate EMI is by using online EMI calculators available on various financial websites. These calculators are easy to use; you just need to input the loan amount, interest rate, and tenure, and the calculator will give you an accurate EMI amount instantly. This saves you time and effort in manual calculations and provides quick results for your budgeting. To fully utilize online EMI calculators, make sure to use reputed and reliable financial websites for accurate results. These tools can help you compare different loan options, understand the impact of interest rates on your EMI, and make informed decisions when borrowing for your home. **Using spreadsheet software for calculations** To streamline your EMI calculations, you can use spreadsheet software like Excel. By setting up a formula in the spreadsheet, you can quickly calculate EMIs for different loan scenarios by changing variables such as loan amount, interest rate, and tenure. Spreadsheet calculations can help you visualize your repayment schedule and plan your finances accordingly. Using spreadsheet software for calculations offers flexibility and customization options, allowing you to analyze various loan options, compare interest rates, and forecast your future financial obligations accurately. This method is ideal for borrowers who prefer a more hands-on approach to EMI calculations. Online EMI calculators can simplify the **[process of calculating your home loan](https://www.sundaramhome.in/loans/home-loans)** EMIs, especially if you are not comfortable with manual calculations or spreadsheet software. These tools are user-friendly, accurate, and can provide you with instant results to plan your budget effectively. ## Essential Tools for EMI Calculation **Online EMI calculators and their features** Keep in mind that online EMI calculators are convenient tools that can help you quickly estimate your monthly loan repayments based on different interest rates and tenures. These calculators are user-friendly and require you to input specific loan details to generate accurate results. Some advanced features you may find in these calculators include the ability to factor in prepayments, processing fees, and even an amortization schedule. **Mobile apps for EMI calculation** To make EMI calculations on the go, mobile apps can be a handy solution. These apps offer the flexibility to calculate EMIs anytime, anywhere, and some may even allow you to save multiple loan profiles for easy reference. With a user-friendly interface, you can quickly adjust variables like interest rate and tenure to see how they impact your EMI. For instance, apps like 'EMI Calculator' and 'Loan EMI Calculator' are popular choices that provide accurate results and additional features such as affordability calculators and loan eligibility checks. Spreadsheets and templates for EMI calculation Spreadsheets and templates are versatile tools that allow you to customize your EMI calculations based on your unique requirements. You can create your own EMI calculator in a spreadsheet program like Excel by inputting formulas to automatically calculate monthly repayments based on your loan details. These templates can be customized further to include additional information, like total interest paid over time. Essential for individuals who prefer a more hands-on approach to EMI calculations or need a tool that can be tailored to suit their specific loan terms and conditions, spreadsheets and templates offer a high level of customization and control. ## Tips for Smart Borrowing Unlike other financial decisions, borrowing for a home loan is a long-term commitment that requires thoughtful planning and consideration. Here are some tips to help you make smart borrowing decisions: **How to negotiate with lenders** With a little research and preparation, you can improve your chances of negotiating favorable terms with lenders. Start by comparing offers from multiple lenders to leverage competitive rates. Highlight your strong credit history and stable income to demonstrate your creditworthiness. Additionally, consider negotiating for lower processing fees or a longer loan tenure to reduce your monthly EMI burden. Factors to consider before choosing a lender Before selecting a lender for your home loan, evaluate factors such as interest rates, loan tenure, processing fees, and prepayment charges. It's important to choose a lender that offers competitive interest rates and flexible repayment options to suit your financial goals. Any hidden charges could impact the total cost of borrowing, so be sure to read the fine print before signing the loan agreement. 1. Compare interest rates and processing fees from multiple lenders 2. Consider the reputation and customer service of the lender **Strategies for reducing EMI burden ** Borrowing within your means is crucial to managing your EMI burden effectively. Consider making a higher down payment to reduce the loan amount and lower your EMIs. You can also opt for a shorter loan tenure to pay off the loan faster and save on interest payments. With careful planning and budgeting, you can strike a balance between affordable EMIs and timely repayment. Explore options for making partial prepayments to reduce the principal amount Seek professional financial advice to optimize your loan structure ## Managing Your Home Loan EMI **Creating a budget for EMI payments** Your first step in managing your home loan EMI is to create a detailed budget that includes your monthly EMI payments. An effective way to do this is by assessing your monthly income and expenses. Deduct your crucial expenses from your income to determine how much you can comfortably allocate towards your EMI payments. It's crucial to ensure that your EMI payments do not exceed 30–40% of your monthly income to avoid financial strain. Prioritizing EMI payments Home loan EMI payments should be a top priority in your financial planning. Missing or delaying EMI payments can lead to penalties, affect your credit score, and even result in the risk of losing your home. Therefore, it is crucial to prioritize your EMI payments above other discretionary expenses. Make sure that you set up automatic payments or reminders to ensure timely repayment of EMIs to maintain a healthy financial profile. Understanding the importance of timely EMI payments can not only help you build a good credit history but also pave the way for future financial opportunities. It showcases your reliability as a borrower and enhances your creditworthiness, making it easier to secure loans or credit in the future. **Options for prepaying your home loan** Your home loan journey can be expedited by exploring options for prepaying your loan. Making partial prepayments or lump sum payments towards your principal amount can help you reduce the overall interest burden and shorten the loan tenure. Additionally, inquire with your lender about any prepayment penalties or charges that may apply to make an informed decision. Plus, by utilizing windfalls such as bonuses, tax refunds, or any additional income towards prepaying your home loan, you can significantly reduce your debt burden and achieve financial freedom sooner. Consider consulting with a financial advisor to understand the best prepayment options that align with your financial goals and objectives. ## Final Words Ultimately, understanding how to calculate your home loan EMI can help you make informed decisions when it comes to borrowing money for your dream home. By using online tools and following the tips provided in this article, you can easily determine your monthly payments and choose a loan that fits your budget. Remember to consider factors like interest rates, loan tenure, and additional charges to find the most suitable option for your financial situation. Smart borrowing starts with being well-informed about your home loan EMI calculations. By utilizing the tools and tips mentioned in this article, you can navigate the borrowing process with confidence and make a decision that aligns with your long-term financial goals. So, take the time to crunch the numbers, compare different loan options, and secure a home loan that works best for you. Happy house hunting! ## FAQ **Q: How is the EMI for a home loan calculated?** A: The EMI (Equated Monthly Installment) for a home loan is calculated using the formula: EMI = [P x R x (1+R)^N]/[(1+R)^N-1], where P is the principal loan amount, R is the monthly interest rate, and N is the number of monthly installments. **Q: Are there any online tools available to calculate home loan EMIs?** A: Yes, there are several online tools and calculators available that can help you calculate your home loan EMI. You can simply input the loan amount, interest rate, and tenure into these tools to get an accurate EMI calculation. **Q: What are some tips for smart borrowing when taking out a home loan?** Some tips for smart borrowing when taking out a home loan include comparing interest rates from multiple lenders, choosing the right loan tenure to fit your financial goals, making a higher down payment to reduce the loan amount, and considering additional costs like processing fees and insurance premiums.
moovendran_veerapandian
1,926,047
Python, 배수의 값을 구하기
for i in range(80, int(argv[2])+1): if int(argv[2]) % i == 0: s_i = i ...
0
2024-07-17T00:26:36
https://dev.to/sunj/python-baesuyi-gabseul-guhagi-8gl
``` for i in range(80, int(argv[2])+1): if int(argv[2]) % i == 0: s_i = i if i % 10 != 0: s_i = str(i).replace('0', '') if i % 10 == 0: c_i = str(i).count('0') if c_i > 1: s_i = str(i).replace('0', '', c_i-1) else: s_i = str(i).replace('0', '') if int(s_i) <= 30: print(s_i + "일") ```
sunj
1,926,048
Issue 53 of AWS Cloud Security Weekly
(This is just the highlight of Issue 53 of AWS Cloud Security weekly @...
0
2024-07-17T00:29:35
https://aws-cloudsec.com/p/issue-53
security, aws, news, newsletter
(This is just the highlight of Issue 53 of AWS Cloud Security weekly @ https://aws-cloudsec.com/p/issue-53 << Subscribe to receive the full version in your inbox weekly for free!!). **What happened in AWS CloudSecurity & CyberSecurity last week July 09-July 16, 2024?** - AWS Security Hub has introduced 24 new security controls (total offerings now 418). - Amazon S3 Express One Zone now supports logging all data plane API actions in AWS CloudTrail, providing detailed insights into the users making API calls to S3 Express One Zone and the timestamps of these calls. With AWS CloudTrail, you can now log not only directory and bucket-level actions like CreateBucket and DeleteBucket but also object-level activities such as PutObject and GetObject for S3 Express One Zone. - AWS Secrets Manager introduced Secrets Manager Agent, a language-agnostic local HTTP service designed for fetching secrets from Secrets Manager and caching them in memory within your compute environments. This release enables you to streamline and unify the process of accessing secrets across various compute environments, eliminating the necessity for custom code. - AWS Partner Central now includes support for multi-factor authentication (MFA) during login. Users will be required to enter a one-time passcode sent to their registered email address in addition to their login credentials to verify their identity. **Trending on the news & advisories (Subscribe to the newsletter for details):** - Google- Passkeys are now available for high risk users to enroll in the Advanced Protection Program. - CISA and FBI Release Secure by Design Alert on Eliminating OS Command Injection Vulnerabilities
aws-cloudsec
1,926,049
Optimizing SQL Queries for Performance
Introduction: Structured Query Language (SQL) is a widely used language for managing relational...
0
2024-07-17T00:34:10
https://dev.to/kartikmehta8/optimizing-sql-queries-for-performance-2e4d
Introduction: Structured Query Language (SQL) is a widely used language for managing relational databases. However, as the amount of data in databases continues to increase, optimizing SQL queries for performance has become crucial. Poorly written queries can lead to slow performance, higher resource utilization, and ultimately result in a negative impact on business operations. In this article, we will discuss the importance of optimizing SQL queries and the methods that can help achieve maximum performance. Advantages: Optimizing SQL queries can significantly improve the performance of applications that rely on databases. It can lead to faster response times, reduced server load, and improved user experience. By optimizing SQL queries, developers can also better utilize the resources of the database server, ensuring efficient use of hardware and storage. This can ultimately lead to cost savings for businesses. Disadvantages: The process of optimizing SQL queries can be time-consuming and requires a good understanding of database design and query execution. Also, poorly optimized queries can result in data inconsistencies and errors, leading to inaccurate results. It is essential to thoroughly test and validate optimized queries to avoid such issues. Features: To optimize SQL queries, developers can use techniques such as indexing, query rewrites, and query hints. By creating appropriate indexes on columns used in the queries, database servers can retrieve and process data more efficiently. Query rewrites involve analyzing the query structure and rewriting it to improve its performance. Query hints provide instructions to the database optimizer on how to execute the query, such as specifying the join order or index usage. Conclusion: In conclusion, optimizing SQL queries is crucial for improving database performance and can provide numerous benefits for businesses. It is a crucial aspect of database development and should be given proper attention. With the right approach, developers can ensure that their applications run smoothly and efficiently, even with large amounts of data in the database.
kartikmehta8
1,926,050
IntensaMente 2 Película Completa Online hdr
IntensaMente 2 Película Completa Online ➥ Ver Ahora ➢ https://bit.ly/3S9im2p Ver IntensaMente 2...
0
2024-07-17T00:37:06
https://dev.to/baixarfilmes23/intensamente-2-pelicula-completa-online-hdr-3dcf
webdev, javascript, beginners, programming
IntensaMente 2 Película Completa Online ➥ Ver Ahora ➢ [https://bit.ly/3S9im2p](https://bit.ly/3S9im2p) Ver IntensaMente 2 Película Completa Online en Español Latino. Ver la película de IntensaMente 2 online en Español sin cortes y sin publicidad, IntensaMente 2 pelicula completa online latino, esta disponible, como siempre en Repelisplay club Nuestro contenido está adaptado al Subtitulada Español, Castellano y Latino. Visita para ver IntensaMente 2 (2024) película completa online en español 460p | 720p | 1080p | 4K [Blu Ray] | Flv | Mp4 | Mkv | Cuevana | Estrenos | Pelispedia | Pelisplus | Gnula | Repelisplus | Repelis | Pelis | Pelisplus| Netflix | Cine | Cinema | Calidad | Mejor | Chile https://github.com/Onetzyvixar1/PELISPLUS-VER-IntensaMente-2-Pel-cula-ONLINE-Completa-En-Espa-ol-y-Latino https://github.com/Onetzyvixar1/Cuevana.3-Ver-IntensaMente-2-PEL-CULA-COMPLETA-ONLINE-en-Espa-ol- https://justpaste.it/7n11n https://consumer.huawei.com/ro/community/details/Despicable-Me-4-2024-Filmul-Vezi-Online-Subtitrat-in-romana/topicId_47051/ https://consumer.huawei.com/ro/community/details/Divertida-Mente-2-2024-FILME-COMPLETO-DUBLADO-EM-PORTUGUESE/topicId_47053/ https://cineblog01-when-evil-lurks-film-intero-streaming-ita-2024.ticketbud.com/ https://the-last-breath-2024-cely-film-cz-online-zdarma.ticketbud.com/ https://x.com/CampS4483/status/1812904221060309007 https://www.facebook.com/filem.online.universal/videos/491826993498875 https://www.facebook.com/filem.online.universal/videos/799540945294771 https://www.facebook.com/61561621256679/videos/2551812988542392 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/493206379863452 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/504595715424992 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/1178862686598997 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/421310874204530 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/493206379863452 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/1218506266198674 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/504240988690368 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/1654252368674010 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/1623294858469945 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/1026595391702767 https://www.facebook.com/Ver.Pelicula.completa.2024.espanol.latino.online/videos/1153480922396707 https://www.facebook.com/intensamente2.cuevana.spanyol/videos/7769962593102603 https://www.facebook.com/intensamente2.cuevana.spanyol/videos/1577056419556684 https://www.facebook.com/intensamente2.cuevana.spanyol/videos/980030637236721 https://www.facebook.com/intensamente2.cuevana.spanyol/videos/841239117562066 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/469060385998393 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/537839898814017 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/1188671108807930 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/476800121639155 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/1443990279627386 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/1399151204011048 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/1184709022536981 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/7914338798681772 https://www.facebook.com/Vezi.film.Subtitrat.in.Romana/videos/3658717307725416 https://www.facebook.com/Ver.pelicula.completa.espanol.y.latino.cuevana.3/videos/401975149544447 https://www.facebook.com/FILMS.VOIR.Streaming.VF.Complet.francais/videos/3784659231807210 https://forum.potok.digital/user/welltzxd132/posts https://pastelink.net/v1golrht https://pastelink.net/hi2e0edi https://magic.ly/welltzxd
baixarfilmes23
1,926,051
Distributed Actors in Python with Dapr
What makes a worse header image - my hand drawing of an airplane, or yet another super lame AI...
0
2024-07-17T00:42:13
https://dev.to/aaronblondeau/distributed-actors-in-python-with-dapr-4856
python, dapr, actors
What makes a worse header image - my hand drawing of an airplane, or yet another super lame AI generated picture? Anyways, imagine a scenario where you are asked to build a an app for an airplane banner message startup called "AirDisplay". AirDisplay is going to completely disrupt the towed airplane banner industry with electronic banners. Instead of planes having to return to the airport to pickup a cloth banner for each message these electronic banners can be updated instantly via the app! --- *Won't the banners be too heavy to flutter nicely behind the airplanes?* *Well, the investors already gave us millions of dollars for mentioning AI in our pitch so we have to build it now.* *The app will need a way to keep track of each banner that exists in the physical world. It will need to always be certain about the current state of each banner so that the user interface can be kept up to date in realtime. It will also need to make sure that user's messages don't overwrite each other (messages show for 60 seconds and then disappear). Finally, it will need to be scalable so that we can support millions of banners at once.* *Wait, how many banner towing airplanes are out there?* *I also put the word 'scale' all over my pitch deck. When will you have a demo ready?* --- If you try and cook up a simple rest api for this things will go great until you remember that user's messages can't overwrite each other. You will have a race condition if two users submit messages at exactly the same nanosecond. Two common options to solve race conditions are: 1) A locking mechanism like Postgres' [SKIP LOCKED](https://www.postgresql.org/docs/current/sql-select.html), or Redis' [distributed locks](https://redis.io/docs/latest/develop/use/patterns/distributed-locks/). 2) The [actor model](https://en.wikipedia.org/wiki/Actor_model). Both methods will solve the problem but you are going to have to be pretty smart to use a locking mechanism successfully. Locking also won't solve some of the other needs like streaming realtime updates to the UI. There are a lot of great actor frameworks out there: - Go has [goakt](https://github.com/Tochemey/goakt) - .Net has [Orleans](https://learn.microsoft.com/en-us/dotnet/orleans/overview) - The JVM has [Akka](https://akka.io/) - Actors are built in to [Elixir](https://elixirschool.com/en/lessons/intermediate/concurrency) - [Dapr](https://dapr.io/) (supports multiple languages) The compelling reason to use Dapr is that it includes some other tools that help solve AirDisplay's requirements : [state management](https://docs.dapr.io/developing-applications/building-blocks/state-management/), [pubsub](https://docs.dapr.io/developing-applications/building-blocks/pubsub/), and [reminders](https://docs.dapr.io/developing-applications/building-blocks/actors/actors-timers-reminders/). Unfortunately it was extremely difficult for me to process Dapr's documentation into a demo for AirDisplay. The three areas where I struggled were: 1) I failed to understand that I needed my own server **always** running alongside Dapr in order to use pubsub or actors. I thought I could drive my workflows simply by using a client. 2) Configuring Dapr was very difficult due to scattered documentation and incorrect examples. 3) A complete working set of example code in Python was difficult to find. For item 1, this is how I now visualize the basic architecture of running an app with Dapr. ![Dapr Server and Sidecar model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/seokis6ea2ho8z28xe7c.png) For items 2 and 3, here is the complete codebase : [https://github.com/aaronblondeau/python-dapr-demo](https://github.com/aaronblondeau/python-dapr-demo) The example code includes: - An actor example (actor state uses a Pydantic class) - Uses Dapr state storage to maintain Actor's state - REST API endpoints that interact with Actor - Actor reminder example - Actor state changes -> pubsub -> websocket -> UI - [Dapr's integration with FastAPI](https://docs.dapr.io/developing-applications/sdks/python/python-sdk-extensions/python-fastapi/) - A simple UI made with [Alpine.js](https://alpinejs.dev/) Hopefully this example will get you started much more quickly on your competitor to AirDisplay now that I have blown our cover here in this post.
aaronblondeau
1,926,052
Why Sista AI is the Top Choice over Alan AI for Conversational AI Integration
Discover why Sista AI outshines the competition by offering unparalleled AI integration solutions. Elevate user experience with cutting-edge technology. Explore the possibilities with Sista AI! #AI #SistaAI 🔥
0
2024-07-17T00:41:46
https://dev.to/sista-ai/why-sista-ai-is-the-top-choice-over-alan-ai-for-conversational-ai-integration-48ko
ai, react, javascript, typescript
<h2>Introduction</h2><p>In the world of AI integration, the choice between Sista AI and Alan AI is clear. Sista AI's advanced conversational AI integration platform offers unparalleled user-friendly features and versatility. With Sista AI, developers can effortlessly integrate AI voice assistants into their apps within minutes, elevating user experience to new heights.</p><h2>AI Integration Made Easy</h2><p>Compared to Alan AI, Sista AI provides a seamless and intuitive integration process. Sista AI's robust software development kit supports all frameworks, making setup and integration a breeze. Moreover, Sista AI's auto scalability ensures reliability and efficiency by dynamically adapting to changing demands, setting it apart as the preferred choice for developers.</p><h2>Enhancing User Experience and Accessibility</h2><p>Sista AI offers a wide range of features including conversational AI agents, voice user interface, multi-tasking UI controller, automatic screen reader, and real-time data integration. These features not only enhance user engagement and accessibility but also enrich the overall user experience. With its flexible pricing plans and comprehensive features, Sista AI stands out as the ideal solution for developers and businesses.</p><h2>A Developer's Dream</h2><p>Developers rave about Sista AI's ease of integration, comprehensive feature set, and scalable architecture. By choosing Sista AI, developers can seamlessly add a plug-and-play AI voice assistant to their app or website in minutes, saving time and effort. The platform's support for multiple frameworks and limitless auto scalability make it a top choice for developers looking to enhance their projects with cutting-edge AI technology.</p><h2>Innovating the Future of Interaction</h2><p>Sista AI is at the forefront of innovation, leading the charge in artificial general intelligence (AGI). By pushing industry boundaries with its advanced AI solutions, Sista AI is revolutionizing human-computer interaction and setting new standards in the field of AI. With a promise to make technology more intuitive, accessible, and user-friendly, Sista AI is the future of conversational AI.</p><p>For more information on AI voice assistant integration and to experience the power of Sista AI, visit <a href='https://smart.sista.ai/?utm_source=sista_blog&utm_medium=blog_post&utm_campaign=Why_Sista_AI_Top_Choice_over_Alan_AI'>Sista AI</a>. Explore the possibilities and transform your app into a smart, user-centric platform with Sista AI's cutting-edge AI solutions.</p><br/><br/><a href="https://smart.sista.ai?utm_source=sista_blog_devto&utm_medium=blog_post&utm_campaign=big_logo" target="_blank"><img src="https://vuic-assets.s3.us-west-1.amazonaws.com/sista-make-auto-gen-blog-assets/sista_ai.png" alt="Sista AI Logo"></a><br/><br/><p>For more information, visit <a href="https://smart.sista.ai?utm_source=sista_blog_devto&utm_medium=blog_post&utm_campaign=For_More_Info_Link" target="_blank">sista.ai</a>.</p>
sista-ai
1,926,054
Unleashing the Power of ChatGPT Prompts for LinkedIn: Elevate Your Professional Presence
In the rapidly evolving digital landscape, LinkedIn has solidified its position as the go-to platform...
0
2024-07-17T00:49:47
https://dev.to/online_2048_8d73ad8f845f2/unleashing-the-power-of-chatgpt-prompts-for-linkedin-elevate-your-professional-presence-1mf7
linkedinmarketing, chatgpt, professionalbranding, digitalnetworking
In the rapidly evolving digital landscape, LinkedIn has solidified its position as the go-to platform for professionals worldwide. With over 774 million users, it offers unparalleled opportunities for networking, job hunting, and personal branding. However, standing out in such a vast sea of profiles can be challenging. Enter [ChatGPT prompts for LinkedIn](https://vengreso.com/blog/chatgpt-prompts-for-linkedin) – a game-changer for crafting compelling content and enhancing your LinkedIn presence. What is ChatGPT? ChatGPT, developed by OpenAI, is an advanced language model capable of generating human-like text based on the input it receives. It can assist with a wide range of tasks, from writing emails and articles to creating social media posts. For LinkedIn users, ChatGPT can be particularly beneficial in generating engaging content that captures attention and drives interaction. Why Use ChatGPT Prompts for LinkedIn? 1. Consistency and Efficiency: Regularly posting high-quality content on LinkedIn can be time-consuming. ChatGPT helps streamline this process by providing instant, creative prompts that can be easily tailored to your specific needs. This ensures that you maintain a consistent posting schedule without sacrificing quality. 2. Enhanced Engagement: With its ability to generate diverse and compelling content, ChatGPT can help you create posts that resonate with your audience. Whether it's sharing industry insights, personal anecdotes, or professional advice, well-crafted content can significantly boost your engagement rates. 3. Personal Branding: A strong personal brand is crucial on LinkedIn. ChatGPT can assist in crafting a cohesive narrative that highlights your expertise, achievements, and professional journey. This not only enhances your profile but also positions you as a thought leader in your industry. How to Use ChatGPT Prompts for LinkedIn 1. Crafting a Standout Profile Your LinkedIn profile is your digital business card. It’s often the first impression potential employers, clients, or collaborators have of you. Here’s how ChatGPT can help: - Headline: Instead of a generic job title, use ChatGPT to craft a headline that showcases your unique value proposition. For example, “Driving Digital Transformation for SMEs | SEO & Digital Marketing Specialist”. - Summary: A compelling summary can set you apart. Provide ChatGPT with key points about your career, skills, and goals, and let it generate a polished and engaging summary. For instance: “With over a decade of experience in digital marketing, I specialize in helping SMEs navigate the complexities of SEO and online branding. My mission is to empower businesses to achieve their digital potential through innovative strategies and data-driven insights.” 2. Creating Engaging Posts Regularly posting on LinkedIn keeps you visible and relevant. Use ChatGPT prompts to generate a variety of post types: - Industry Insights: Share your thoughts on the latest trends and developments in your field. Prompt: “What are the current trends in digital marketing and their impact on SMEs?” - Personal Stories: Authenticity resonates. Prompt: “Share a personal story about a challenge you overcame in your career and the lessons learned.” - Professional Tips: Position yourself as an expert by sharing actionable advice. Prompt: “What are the top five SEO strategies for 2024?” 3. Writing Articles LinkedIn articles allow for deeper dives into topics that matter to your audience. ChatGPT can help generate outlines and content for these articles. For example, if you want to write about “The Future of Digital Marketing”, provide this topic to ChatGPT, and it can suggest a structured outline and even draft sections of the article. 4. Engaging with Your Network Engagement goes beyond posting content; it involves interacting with your network. Use ChatGPT to draft thoughtful comments on posts, messages to new connections, and responses to inquiries. Prompt: “Draft a message to thank someone for connecting with you and suggest a potential collaboration.” Best Practices for Using ChatGPT Prompts 1. Tailor the Output: While ChatGPT provides a great starting point, always tailor the generated content to fit your voice and style. Personalization is key to authenticity. 2. Stay Relevant: Ensure that the content generated is relevant to your audience. Regularly update your prompts to reflect current trends and topics in your industry. 3. Proofread: Despite its capabilities, ChatGPT is not infallible. Always proofread and edit the content before posting to ensure accuracy and coherence. 4. Ethical Use: Be transparent about the use of AI-generated content when necessary, and use it ethically to enhance rather than replace human interaction. Conclusion Leveraging ChatGPT prompts for LinkedIn can significantly enhance your professional presence on the platform. By providing consistent, engaging, and high-quality content, you can build a strong personal brand, foster meaningful connections, and stay ahead in your industry. Embrace the power of AI to unlock new opportunities and take your LinkedIn game to the next level.
online_2048_8d73ad8f845f2
1,926,055
Dynamic programming: Teach me like I am 5!
Imagine you have a magical notebook 📓✨. This notebook remembers answers to problems you’ve already...
0
2024-07-17T01:00:08
https://dev.to/yourtechsiss/dynamic-programming-teach-me-like-i-am-5-6o
Imagine you have a magical notebook 📓✨. This notebook remembers answers to problems you’ve already solved so you don’t have to solve them again. Let’s start with something simple: climbing stairs. Each time, you can either take 1 step or 2 steps. How many ways can you climb to the top if there are n stairs? Magical Notebook to the Rescue! Define the problem: To find the number of ways to reach the nth step. Remember the simple problems: The number of ways to get to step 1 is 1, and to step 2 is 2. Steps: If you’re on step 1, there’s only one way to stay there. If you’re on step 2, there are two ways: step 1 to step 2, or jump directly to step 2. For step 3 and beyond, you can either come from the step right before it (n-1) or jump from the step two before it (n-2). Let’s write this in code: `def climbStairs(n): if n == 1: return 1 elif n == 2: return 2 else: steps = [0] * (n + 1) steps[1] = 1 steps[2] = 2 for i in range(3, n + 1): steps[i] = steps[i - 1] + steps[i - 2] return steps[n] print(climbStairs(5)) # Output: 8` Another example! You are in a candy store, and there are different candies in a line. Each candy has a different amount of happiness points. You can’t take two candies next to each other, or you’ll get a tummy ache. How do you collect the most happiness? Magical Notebook to the Rescue! Define the problem: To find the maximum happiness you can collect without taking two candies next to each other. Remember the simple problems: The happiness points for each candy. Steps: If you only have one candy, take it. If you have two candies, take the one with more happiness. For three or more candies: Decide to take the current candy and add it to the best of skipping the next candy. Or skip the current candy and take the best up to the previous candy. Let’s write this in code: `def maxCandyHappiness(happiness): n = len(happiness) if n == 0: return 0 elif n == 1: return happiness[0] elif n == 2: return max(happiness[0], happiness[1]) else: max_happiness = [0] * n max_happiness[0] = happiness[0] max_happiness[1] = max(happiness[0], happiness[1]) for i in range(2, n): max_happiness[i] = max(max_happiness[i-1], happiness[i] + max_happiness[i-2]) return max(max_happiness) happiness = [3, 2, 5, 10, 7] print(maxCandyHappiness(happiness)) # Output: 15` Why Use Dynamic Programming? It saves time! Instead of doing the same work over and over, your helper remembers the answers and by remembering small answers, your helper can find the best way to solve the big problem! Hope this helps! Here are 3 leetcode questions to get you comfortable with this concept. Let me know how it goes ☺️ Jump Game : https://leetcode.com/problems/jump-game/description/ Unique Paths: https://leetcode.com/problems/unique-paths/description/ Scramble Strings: https://leetcode.com/problems/scramble-string/description/ Follow me on Instagram : https://www.instagram.com/yourtechsiss/ Tiktok: https://www.tiktok.com/@yourtechsiss
yourtechsiss
1,926,057
The Value of Community Conferences
Ever since returning from the last JSConf Budapest, a question has been circling in my mind: how can...
0
2024-07-17T01:12:02
https://dev.to/amandamartindev/the-value-of-community-conferences-5fh3
devrel, techtalks, community, marketing
Ever since returning from the last [JSConf Budapest](https://jsconfbp.com/), a question has been circling in my mind: how can we effectively sell the idea of community conferences to companies? It's a topic that seems to resonate with many in the tech field, from developers to developer advocates. ## Why Community Conferences Matter Those of us in tech who have been to many events big and small know there's something unmatched about a well curated community conference. They're not just events; they're breeding grounds for innovation, learning, and networking. You leave with deep knowledge, friendship, and opportuities you really can't find at larger events. Anyone you ask in tech will agree that community led events matter and need support but the reality is they are struggling. Beloved conferences like JSConf Budapest have seen their last event already while others are struggling to keep above water. So if everyone agrees that these types of events are important and necessary for developers, then what gives? **Sponsors aren't sponsoring**. Without larger corporate sponsors it's impossible for smaller events to keep costs reasonable. ## Why your company should sponsor community conferences 1\. **Cost:** The cost of the sponsorship itself will be much less than the one boasting 5 - 10,000 attendees and a yacht party. In addition to the base cost, there will be less human cost, asset costs, and swag costs as you bend your budget to figure out how to have a cooler booth than the company next to you. 2\. **Flexibiltiy**: You will be working directly with the community to plan your presence. While many community conferences aren't keen on vendor talks taking the main stage that doens't mean you can't show off your product in other ways. If you don't know how you can fit into the event, it's easy to get in touch with the organizers and a good developer relations team will be able to guide you on the best way to engage meaningfully in this space. 3\. **Stand out from the crowd**: Big conferences mean big burnout for attendees and most of your interactions will be the 10 seconds folks give you to make your pitch while they grab your swag and move on. And while many bigger conferences have space for vendor talks, this is generally becuase they are multi-track and you will be competing with big names in the tech speaker space. A personal example. My first big conference as a speaker - I was given a difficult slot in a difficult location and had 4 people in the audience. This conference had 1000's of attendees. 4\. **More impactful conversations:** Quantity != Quality. While the overall number of attendees may be lower. At a community conference you have the opportunity to really get to know attendees personally and professionally. Instead of pitching your product with the usual script or demo, you are able to have deep technical conversations with devs about what they are thinking about, building, and getting excited about. People are there to learn and be inspired and the conversations during community event downtime are always top tier. 5\. **Brand bonus points**: Your product isnt that special (oh, you have AI now too?). I mean, maybe it is - but tech is flooded with cool tools you are absolutely in competition with. Stand out by supporting communities developers love in a meaningful way. Devs talk to each other and while we want tools that solve our problems, we also love to support companies doing good in the community. If you can be both and awesome tool and a great community member, your brand wins. ## Don't get me wrong A note about all this - still do the big conferences but be more selective about this budget. I would argue by diversifying your approach to include MORE community driven events like smaller single track conferences, meetups, and whatever cool events devs are dreaming up that you will see a better ROI than blowing all your budget on the flashiest event you can find. ## A Thank You to the Community As I reflect on the experiences and insights gained from JSConf Budapest, I can't help but express my gratitude. Thank you to the organizers, the speakers, and every attendee who contributes to making these conferences a rich source of knowledge and community spirit. In conclusion, selling the concept of community conferences to companies should be a natural step. After all, the advantages are clear. It's about recognizing the importance of these events and the long-term value they bring to individuals and organizations alike. Thank you, once again, to everyone who plays a part in these incredible tech gatherings. **Drop your favorite community led event in the comments** and reach out to me to continue the conversation on [Twitter](https://x.com/hey_amandam) or [LinkedIn](https://www.linkedin.com/in/amandamartin-dev/)
amandamartindev
1,926,058
Demo
demo
0
2024-07-17T01:19:33
https://dev.to/cuongvnz/demo-3e6e
demo
cuongvnz
1,926,071
AI in Real Estate: Transforming the Industry
Introduction to AI in Real Estate Artificial Intelligence (AI) has become a transformative...
27,673
2024-07-17T01:35:15
https://dev.to/rapidinnovation/ai-in-real-estate-transforming-the-industry-20cp
## Introduction to AI in Real Estate Artificial Intelligence (AI) has become a transformative force across various industries, and real estate is no exception. AI in real estate refers to the use of machine learning, data analytics, and other AI technologies to facilitate and optimize different processes in the real estate sector. This includes everything from property search and transactions to market analysis and investment decisions. ## Overview of AI Technology AI technology encompasses a range of tools and techniques that enable machines to mimic human intelligence and behavior. Key components of AI include machine learning, natural language processing, and robotics. These technologies are increasingly being integrated into various real estate applications, providing significant advantages in terms of efficiency and accuracy. ## Importance of AI in Modern Real Estate By automating routine tasks, AI allows real estate professionals to focus on more strategic activities, thereby increasing productivity and efficiency. AI- driven analytics provide deeper insights into market dynamics, enabling better forecasting and investment planning. Furthermore, AI enhances the customer experience by offering personalized property recommendations based on user behavior and preferences. ## Evolution of Real Estate Markets with AI The real estate sector has been significantly transformed by the integration of AI, marking a new era in how properties are bought, sold, and managed. AI technologies have revolutionized the market by enhancing data analysis capabilities, improving customer service, and streamlining operations. ## AI-Driven Market Analysis AI-driven market analysis in real estate refers to the use of machine learning algorithms and big data analytics to understand and predict market trends. This technology has become a game-changer for the industry by providing deeper insights into market dynamics than traditional methods. ## Predictive Analytics for Price Forecasting Predictive analytics in real estate is primarily focused on price forecasting, which is crucial for both buyers and sellers to make informed decisions. By leveraging AI, predictive models use historical data combined with machine learning algorithms to forecast future property prices. ## Machine Learning Models in Valuation Machine learning models have revolutionized the field of property valuation by providing more accurate and efficient assessments. These models use historical data to predict the value of a property, offering instant property valuations that are particularly useful for real estate professionals and investors. ## Real-Time Data Processing Real-time data processing in real estate is a game-changer, particularly when it comes to making timely investment decisions and improving customer service. With the advent of IoT devices and sensors, data on property conditions, usage patterns, and even environmental factors are being collected continuously. ## Enhancing Property Search with AI AI is significantly enhancing the property search experience for both buyers and real estate professionals. AI-powered platforms can analyze user preferences and behavior to recommend properties that best match their needs, thereby simplifying the search process and saving time. ## Customized Search Engines Customized search engines have revolutionized the way we access information tailored to our specific needs and preferences. These engines use advanced algorithms to filter and present data that aligns closely with the user's queries and past behavior. ## Virtual Reality Tours Virtual reality (VR) tours represent a significant leap in how we experience environments remotely. Whether it's a museum, a real estate property, or a tourist destination, VR tours use immersive technology to give a realistic experience of the place without physically being there. ## Chatbots for Immediate Assistance Chatbots have become an indispensable tool for providing immediate assistance to users across various online platforms. By simulating human conversation through text or voice commands, chatbots can handle a wide range of tasks from answering FAQs to assisting in complex problem-solving scenarios. ## AI in Property Management The integration of AI in property management is revolutionizing the industry by enhancing efficiency, reducing costs, and improving tenant satisfaction. AI technologies are being employed to automate routine tasks, predict maintenance issues, optimize energy use, and much more. ## Automated Maintenance Requests Automated maintenance requests use AI to handle and process maintenance requests from tenants, ensuring that issues are addressed quickly and efficiently. AI systems can categorize and prioritize requests based on urgency and impact, schedule repairs, and even dispatch maintenance personnel without human intervention. ## Energy Management with AI AI is transforming energy management within properties by optimizing the use of resources, thereby reducing costs and environmental impact. AI systems can analyze historical energy usage data along with real-time inputs from connected devices to adjust HVAC systems, lighting, and other energy-consuming appliances to ensure optimal performance. ## Security Enhancements through AI Technologies AI has significantly transformed the landscape of security across various sectors, offering advanced solutions that enhance both cyber and physical security systems. AI systems can analyze vast amounts of data at an unprecedented speed, enabling them to identify potential threats and anomalies faster and more accurately than human capabilities. ## Blockchain Integration in Real Estate The integration of blockchain technology in real estate is revolutionizing the industry by enhancing transparency, efficiency, and trust in property transactions. Blockchain offers a decentralized ledger that records all transactions across a network of computers, making the data visible and immutable. ## Smart Contracts for Transparent Transactions Smart contracts, powered by blockchain technology, are self-executing contracts where the terms of the agreement between buyer and seller are directly written into lines of code. In real estate, smart contracts can automate and streamline the entire property transaction process, from due diligence to signing agreements to transferring property titles. ## Decentralized Marketplaces Decentralized marketplaces represent a significant shift in how transactions are conducted, moving away from centralized control and towards peer-to-peer interactions. These marketplaces operate on blockchain technology, which ensures transparency, security, and integrity of transactions without the need for a central authority. ## Tokenization of Assets Tokenization of assets is a process where the value of a real-world asset is converted into a digital token on a blockchain. This can include anything from real estate and cars to artwork and intellectual property. Tokenization makes buying, selling, and trading these assets more efficient by converting them into digital tokens that can be easily divided, exchanged, and tracked. ## Future Trends and Predictions The future of blockchain technology and digital currencies is poised for significant growth and transformation. As we look ahead, several trends are likely to shape the landscape, including the integration of blockchain into mainstream finance, the rise of Central Bank Digital Currencies (CBDCs), and advancements in blockchain interoperability and scalability. ## AI and IoT in Smart Homes The integration of AI and IoT in smart homes is revolutionizing how we interact with our living environments. AI enhances the capabilities of smart home devices through advanced data analysis and learning algorithms, enabling these devices to anticipate the needs of residents and respond accordingly. ## Regulatory Challenges and Solutions The rapid advancement of technology in areas such as AI and IoT presents significant regulatory challenges. These challenges primarily revolve around privacy, security, and ethical considerations. Governments and regulatory bodies worldwide are tasked with creating policies that protect consumers while also fostering innovation. ## The Role of AI in Sustainable Development AI's role in sustainable development is becoming increasingly crucial as the world seeks innovative solutions to environmental challenges. AI can optimize resource use and improve efficiency in various sectors, including energy, water management, and agriculture. 📣📣Drive innovation with intelligent AI and secure blockchain technology! Check out how we can help your business grow! [Blockchain Development](https://www.rapidinnovation.io/service- development/blockchain-app-development-company-in-usa) [AI Development](https://www.rapidinnovation.io/ai-software-development- company-in-usa) [Blockchain Development](https://www.rapidinnovation.io/service- development/blockchain-app-development-company-in-usa) [AI Development](https://www.rapidinnovation.io/ai-software-development-company- in-usa) ## URLs * <https://www.rapidinnovation.io/post/reimagine-real-estate-with-ai-powered-solutions> ## Hashtags #AIinRealEstate #PropTech #MachineLearning #SmartHomes #BlockchainRealEstate
rapidinnovation
1,926,866
tmux 101
tmux is a terminal multiplexer. We can have multiple terminals inside a single terminal, which is...
0
2024-07-17T15:00:45
https://dev.to/vigneshm243/tmux-101-50lm
linux, archlinux
tmux is a terminal multiplexer. We can have multiple terminals inside a single terminal, which is especially useful when we ssh into a remote machine. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uu8tb9kfgevoylnqfqp.png) tmux has 3 levels of hierarchy, - Sessions - To have completely different work environments for different concerns - Windows - To have multiple tabs for what that window represents, basically one for monitoring logs and performance and another to execute the commands required. - Panes - To have different panes inside a window, like one running top, and another running a couple of tail commands on log files. To start using tmux, we just need to run the command *tmux*. One key concept in tmux is the concept of prefix key. After pressing the prefix key, tmux enters command mode, similar to vim's insert, command, and view modes. The **prefix key** for tmux by default is **Ctrl + B**. ### Basic commands - Start a new session ```sh tmux ``` - Detach from a session ```shortcut Ctrl+B d ``` - Attach to the last accessed session ```sh tmux attach ``` - Exit and quit tmux ```sh Ctrl+B & ``` ### Session management - Create a named session ```sh tmux new -s <session_name> ``` - Attach to a session ```sh tmux attach -t <session_name> ``` or ```sh tmux a -t <session_name> ``` - Switch sessions ```sh tmux switch -t <session_name> ``` - List sessions ```sh tmux ls ``` - Kill sessions ```sh tmux kill-session -t <session_name> ``` ### Window management | Key | Operation | | ---------- | ------------------------------ | | Ctrl+B C | Create new window | | Ctrl+B N | Move to next window | | Ctrl+B P | Move to previous window | | Ctrl+B L | Move to last window | | Ctrl+B 0-9 | Move to window by index number | ### Pane management | Key | Operation | | ---------------------- | ------------------------------------------------------------ | | Ctrl+B % | Vertical split (panes side by side) | | Ctrl+B " | Horizontal split (one pane below the other) | | Ctrl+B O | Move to other pane | | Ctrl+B ! | Remove all panes but the current one from the window | | Ctrl+B Q | Display window index numbers | | Ctrl+B Ctrl-Up/Down | Resize current pane (due north/south) | | Ctrl+B Ctrl-Left/Right | Resize current pane (due west/east) | | Ctrl+B W | Open a panel to navigate across windows in multiple sessions | ### Command mode Some other key points are we can enter command mode by Ctrl + B : We can allow access to a mouse by ```sh set -g mouse ``` ### Tmux config We have a tmux config file that is a dot config file. We can create it using the following command. ```sh vi $HOME/.tmux.conf ``` We can add the above command to allow mouse usage into the tmux conf file. ### Tmux References There is a lot more to tmux than this, which we can check out from the [tmux manual](http://man.openbsd.org/OpenBSD-current/man1/tmux.1). --- Originally posted on [vignesh.page](https://vignesh.page/posts/tmux/). Hope tmux improves your daily workflow as it did mine. Comment out any cool features or tmux plugins that you find useful.
vigneshm243
1,926,072
Publishing Packages to GitHub with GitHub Actions
Publishing Packages to Github How to Publish Private NPM Packages With Github Package...
0
2024-07-17T01:36:25
https://dev.to/tkssharma/publishing-packages-to-github-with-github-actions-54bm
github, npm, package, node
Publishing Packages to Github {% embed https://www.youtube.com/watch?v=lVze5eT5DQQ&list=PLIGDNOJWiL18ucL7WGWeVjXmSzOVTRObE %} How to Publish Private NPM Packages With Github Package Registry Build and Publish Your NPM Package in 5 Minutes :) In this playlist, we are talking about publishing different types of packages to GitHub We are covering about all different package which can be published !['react package publish to github'](https://i.ytimg.com/vi/MqktacvJCqc/maxresdefault.jpg) !['nodejs package publish to github'](https://i.ytimg.com/vi/lVze5eT5DQQ/maxresdefault.jpg) !['nestjs package publish to github'](https://i.ytimg.com/vi/--lJoAwAD1A/maxresdefault.jpg) PlalyList Link https://www.youtube.com/watch?v=lVze5eT5DQQ&list=PLIGDNOJWiL18ucL7WGWeVjXmSzOVTRObE GitHub Link https://github.com/tkssharma/publish-packages 🚀 Publish Node JS Utility Package to GitHub 🚀 Publish React JS Component Package to GitHub 🚀 Publish React JS Component and deploy using CI GitHub Actions to GitHub 🚀 Publish Nest JS Utility Package to GitHub 🚀 Publish Nest JS Dynamic Package to GitHub 🚀🚀 How to Publish Private NPM Packages With Github Package Registry We'll begin by first making our modules repository private. Publishing private NPM packages using GitHub Package Registry involves several steps to configure your package and authenticate with GitHub. Here's a step-by-step guide: 🚀🚀 Prerequisites Node.js and npm: Make sure you have Node.js and npm installed. GitHub Account: Ensure you have a GitHub account and a repository where you want to host the package. Repository Permissions: Ensure you have the necessary permissions to publish to the GitHub repository. 🚀🚀We will follow these steps - Create a GitHub Personal Access Token - Authenticating With NPM Using the GitHub Registry - Publish Your Package - Using Your Private Package in Another Project 🚀🚀 Outline Video 00:00 Why do we need a Package 02:00 Things we need for publishing the package 03:30 npm login to login account 04:30 Simple Demo Code setup 05:00 Generating Access Token 05:30 npm login to GitHub npm 07:20 npm run build and publish 08:20 npm publish to publish package 09:00 Using package in another project 09:30 npmrc setup
tkssharma
1,926,073
NestJS Testing Unit and E2E
Hi Everyone, 🔥I am building nestjs testing playlist which talks all about nestjs testing...
0
2024-07-17T01:39:40
https://dev.to/tkssharma/nestjs-testing-unit-and-e2e-km2
nestjs, node, testing, javascript
{% embed https://www.youtube.com/watch?v=kv_pCCAmiLc %} Hi Everyone, 🔥I am building nestjs testing playlist which talks all about nestjs testing !['nestjs testing course 2024'](https://i.ytimg.com/vi/kv_pCCAmiLc/maxresdefault.jpg) https://www.youtube.com/watch?v=GSoGVlG1MTQ&list=PLIGDNOJWiL1-8hpXEDlD1UrphjmZ9aMT1 Github https://github.com/tkssharma/nestjs-advanced-2023 In coming videos, we are covering NestJS Testing in NestJS is crucial for ensuring your application works as expected. NestJS supports unit and end-to-end (e2e) testing, typically using the Jest framework. Here’s a brief guide on how to set up and perform both types of tests in a NestJS project. - Basic about testing controller and services - Different ways to Mock service or Providers - Mocking External auth or data services - Nest JS Testing with TypeORM interface - NestJS Testing with Knex or Prisma - Nest JS running Unit and E2E Tests on CI setup - Nest JS Testing GraphQL Interface - Nest JS Testing REST Interface - Nest JS Testing Controller and services - Nest JS Running Test Suits for APIs - Nest JS running Database seed and cleanup on Test Execution 🚀 What You'll Learn: Join us as we unravel the complexities of unit testing in Nest.js, providing you with practical insights to validate the functionality of your controllers and services. Whether you're a seasoned developer or just starting out, this tutorial will equip you with essential skills to write effective tests that enhance the quality and maintainability of your codebase. 📋 Series Highlights: - Understanding the importance of unit testing in software development - Setting up a Nest.js project for efficient testing - Writing unit tests for controllers: simulating HTTP requests and assertions - Uncovering best practices for service testing: mocking dependencies and behavior - Achieving comprehensive test coverage while avoiding common pitfalls - Exploring advanced testing techniques: spies, mocks, and stubs - Integration with testing frameworks like Jest for a seamless testing experience - Leveraging testing to catch bugs early and ensure code reliability
tkssharma
1,926,074
Elevate Your Elasticsearch Experience with Java High Level REST Client (7.x)
Introduction Java High Level REST Client (7.x) is a powerful tool for interacting with...
0
2024-07-17T01:45:55
https://dev.to/a_lucas/elevate-your-elasticsearch-experience-with-java-high-level-rest-client-7x-348k
javascript, tutorial, productivity, webdev
## Introduction Java High Level REST Client (7.x) is a powerful tool for interacting with Elasticsearch clusters, making server communication more accessible and efficient. In this guide, we will walk you through the steps to use the High Level REST Client to call Elasticsearch Java APIs on an [Alibaba Cloud Elasticsearch](https://www.alibabacloud.com/en/product/elasticsearch) cluster. <a name="IRk1L"></a> ## Preparations <a name="TcFhZ"></a> ### Step 1: Create an Elasticsearch Cluster Ensure your cluster version is the same as or newer than the Java High Level REST Client version you plan to use. For step-by-step instructions, see [Create an Alibaba Cloud Elasticsearch cluster](https://www.alibabacloud.com/en/product/elasticsearch). <a name="QgbUJ"></a> ### Step 2: Enable Auto Indexing Enable the Auto Indexing feature in the YAML configuration file. For details, see [Configure the YML file](https://www.alibabacloud.com/help/en/elasticsearch/latest/configuration). <a name="HHMzG"></a> ### Step 3: Configure IP Address Whitelist Ensure proper communication by configuring an IP address whitelist. If you're accessing the cluster over the Internet, allow requests from the required IP addresses by following the guidelines in [Configure a public or private IP address whitelist](https://www.alibabacloud.com/help/en/elasticsearch/latest/configure-a-whitelist). <a name="UDL4R"></a> ### Step 4: Install JDK Install Java Development Kit (JDK) version 1.8 or later. For more information, see [Install a JDK](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html). <a name="FB5dQ"></a> ### Step 5: Create a Java Maven Project Add the necessary dependencies to your `pom.xml` file. Change the version number in the dependencies from `7.x` to the specific version of the High Level REST Client you are using. ```xml <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.x</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.20.0</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.20.0</version> </dependency> ``` <a name="r4Cpi"></a> ## Example: Managing an Index Below is an example of creating and deleting an index using the High Level REST Client. Replace placeholders `{}` with your specific parameters. ```java import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.*; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class RestClientExample { private static final RequestOptions COMMON_OPTIONS; static { RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder(); builder.setHttpAsyncResponseConsumerFactory( new HttpAsyncResponseConsumerFactory .HeapBufferedResponseConsumerFactory(30 * 1024 * 1024)); COMMON_OPTIONS = builder.build(); } public static void main(String[] args) { final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("{Username}", "{Password}")); RestClientBuilder builder = RestClient.builder(new HttpHost("{Endpoint of the Elasticsearch cluster}", 9200, "http")) .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { @Override public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); } }); RestHighLevelClient highClient = new RestHighLevelClient(builder); try { Map<String, Object> jsonMap = new HashMap<>(); jsonMap.put("{field_01}", "{value_01}"); jsonMap.put("{field_02}", "{value_02}"); IndexRequest indexRequest = new IndexRequest("{index_name}", "_doc", "{doc_id}").source(jsonMap); IndexResponse indexResponse = highClient.index(indexRequest, COMMON_OPTIONS); long version = indexResponse.getVersion(); System.out.println("Index document successfully! " + version); DeleteRequest deleteRequest = new DeleteRequest("{index_name}", "_doc", "{doc_id}"); DeleteResponse deleteResponse = highClient.delete(deleteRequest, COMMON_OPTIONS); System.out.println("Delete document successfully! \n" + deleteResponse.toString()); highClient.close(); } catch (IOException ioException) { ioException.printStackTrace(); } } } ``` <a name="j7HBS"></a> ## High-Concurrency Configuration For high-concurrency scenarios, increase the number of client connections: ```java httpClientBuilder.setMaxConnTotal(500); httpClientBuilder.setMaxConnPerRoute(300); ``` Sample code snippet: ```java String host = "127.0.0.1"; int port = 9200; String username = "elastic"; String password = "passwd"; final int max_conn_total = 500; final int max_conn_per_route = 300; RestHighLevelClient restHighLevelClient = new RestHighLevelClient( RestClient.builder(new HttpHost(host, port, "http")).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { httpClientBuilder.setMaxConnTotal(max_conn_total); httpClientBuilder.setMaxConnPerRoute(max_conn_per_route); return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); } }) ); ``` For more details on features and configurations, see the official [Java High Level REST Client documentation](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html). <a name="M4R9H"></a> ## Conclusion Using the Java High Level REST Client ensures efficient interaction with your [Alibaba Cloud Elasticsearch](https://www.alibabacloud.com/en/product/elasticsearch) cluster. Follow this guide to make the most out of your Elasticsearch setup.<br />Ready to start your journey with Elasticsearch on Alibaba Cloud? Explore our tailored Cloud solutions and services to transform your data into a visual masterpiece. <br /> [Click here to embark on Your 30-Day Free Trial](https://c.tb.cn/F3.bTfFpS)
a_lucas
1,926,076
LED rental screen series "integrated" with the stage
With the continuous advancement of display technology, my country's display application field has...
0
2024-07-17T01:48:27
https://dev.to/sostrondylan/led-rental-screen-series-integrated-with-the-stage-94
led, rental, screen
With the continuous advancement of display technology, my country's display application field has gradually shifted from traditional display equipment to [LED rental screen applications](https://sostron.com/products/hima-indoor-and-outdoor-advertising-screens-for-rent/). The amount of information that modern audiences obtain from images far exceeds the information expressed by mechanical physical carriers such as traditional stage display and lighting. In today's image applications, what we see is not only the various effects simulated by the equipment, but also the broad perspective and perfect picture brought by the new LED rental screen. It can not only present perfect video images from different perspectives, but also show special effects on thinking, consciousness, concepts and even other abstract concepts. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlajqj216cmrhotkap93.png) Advantages brought by technological innovation The development of imaging equipment technology has made it easy to achieve effects that were previously impossible with traditional scenery. LED rental screens create a more atmospheric stage effect through virtual images, giving the audience unlimited imagination space. Professionally processing the image images according to the connotation of the stage program and selecting matching images for performance not only enhances the audience's visual enjoyment, but also forms a new stage form. [Provide you with a guide to calculating the rental price of LED display screens. ](https://sostron.com/led-screen-rental-price-calculation-guide/) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9j8uf0bvcgwx5avbken.png) Misuse and professional application In many large-scale performances, there is a phenomenon of misusing display devices. If the use of images is separated from the plot of the program, it will form a meaningless pile-up effect, which will give the audience a chaotic feeling. The LED rental series we have created can "integrate" with the stage through professional screen design and stage matching, creating different effects and bringing unlimited visual enjoyment. [Provide you with LED stage rental screen solutions. ](https://sostron.com/led-stage-rental-screen-scheme/) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90cz9ynak6e9v71m9mve.png) Summary The LED rental series has become an indispensable and important part of modern stage performances. Its wide viewing angle, high-quality display effect and perfect integration with the stage have greatly enhanced the audience's visual enjoyment. Through professional design and application, LED rental screens can not only show the depth of the program content, but also bring unprecedented stage effects. In the future development, with the continuous advancement of technology, LED rental screens will surely show their unique charm and value in more fields. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ji4bouzbaprhr2oig5mm.png) Thank you for watching. I hope we can solve your problems. Sostron is a professional [LED display manufacturer](https://sostron.com/about-us/). We provide all kinds of displays, display leasing and display solutions around the world. If you want to know: [Small pitch LED display: The potential of the future market is worth tens of billions.](https://dev.to/sostrondylan/small-pitch-led-display-the-potential-of-the-future-market-is-worth-tens-of-billions-22g4) Please click read. Follow me! Take you to know more about led display knowledge. Contact us on WhatsApp:https://api.whatsapp.com/send?phone=+8613570218702&text=Hello
sostrondylan
1,926,077
Using AWS coding with Codeguru
When it comes to coding with AWS (Amazon Web Services) and using CodeGuru, there are several specific...
0
2024-07-17T01:52:17
https://dev.to/sherlockyadav/using-aws-coding-with-codeguru-bj5
When it comes to coding with AWS (Amazon Web Services) and using CodeGuru, there are several specific ways in which CodeGuru can provide assistance and improve your coding experience: Code Reviews and Recommendations: Code Quality: CodeGuru Reviewer analyzes your code as you develop and provides recommendations to improve code quality. It identifies issues such as resource leaks, incorrect concurrency usage, and security vulnerabilities based on AWS best practices. Automated Feedback: Instead of relying solely on manual code reviews, CodeGuru offers automated feedback in real-time, helping you catch potential issues early in the development cycle. This can significantly speed up the development process and reduce the risk of deploying faulty code. Performance Optimization: CodeGuru Profiler: CodeGuru Profiler helps optimize the performance of your applications running on AWS. It uses machine learning to analyze runtime behavior and identify the most expensive lines of code, inefficient use of resources, and opportunities for optimization. Recommendations: Based on its analysis, CodeGuru Profiler provides actionable recommendations to improve application performance, such as optimizing database queries, improving memory usage, or reducing compute resource consumption. Integration with AWS Services: CodeGuru seamlessly integrates with other AWS services, such as AWS Lambda, AWS Elastic Beanstalk, and Amazon ECS. This integration allows you to optimize your applications specifically for the AWS environment, ensuring that your code performs efficiently and scales effectively. Learning and Best Practices: By using CodeGuru, developers can learn AWS-specific coding best practices directly through the tool's recommendations and insights. This includes understanding how to write efficient code that leverages AWS services effectively, adheres to AWS security standards, and scales to meet performance requirements. Continuous Improvement: CodeGuru supports continuous improvement by providing ongoing feedback and analysis. Developers can iteratively enhance their code based on CodeGuru's recommendations, leading to better application performance, increased reliability, and improved developer productivity over time. Cost Optimization: Beyond performance improvements, CodeGuru can also help optimize costs associated with running applications on AWS. By identifying inefficient resource usage and providing optimization recommendations, CodeGuru helps developers make informed decisions that can lead to cost savings. In essence, CodeGuru is a powerful tool for developers working with AWS, offering automated code reviews, performance profiling, and actionable recommendations that help improve code quality, optimize application performance, and adhere to AWS best practices. By leveraging CodeGuru's capabilities, developers can enhance their coding skills, accelerate development cycles, and build more efficient and scalable applications on AWS.
sherlockyadav
1,926,078
Publish Nest JS Dynamic Package to Github
Publish Nest JS Dynamic Package to Github In this video we are publishing Nest JS Dynamic...
0
2024-07-17T01:53:01
https://dev.to/tkssharma/publish-nest-js-dynamic-package-to-github-3k1f
nestjs, package, github, node
Publish Nest JS Dynamic Package to Github {% embed https://www.youtube.com/watch?v=YhgKijxE9Ao %} In this video we are publishing Nest JS Dynamic Package to Github, Package contains a simple NestJS Package that gives dynamic random Numbers !['private package deployed to github'](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh06yvtfjp503eud1gnt.png) !['github repo to play with package'](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gxlwhkrbpqcht5a4wcr.png) ```js // Package. import { Inject } from "@nestjs/common"; // Internal. import { RANDOM_NUMBER_CLIENT_MODULE_OPTIONS } from "./random-number.constants"; import { RandomNumberModuleOptions } from "./random-number.interface"; export class RandomNumberService { private readonly min: number = 0; private readonly max: number = 100; constructor( @Inject(RANDOM_NUMBER_CLIENT_MODULE_OPTIONS) private readonly options: RandomNumberModuleOptions ) { this.min = this.options.min; this.max = this.options.max; } generate(): number { const range = this.max - this.min; return this.min + Math.floor(Math.random() * range); } } ``` ## Nest JS Dynamic module ```js // Package. import { DynamicModule, Global, Module, Provider, Type } from "@nestjs/common"; //Internal import { RANDOM_NUMBER_CLIENT_TOKEN, RANDOM_NUMBER_CLIENT_MODULE_OPTIONS, } from "./random-number.constants"; import { RandomNumberModuleOptions, RandomNumberModuleAsyncOptions, RandomNumberModuleFactory, } from "./random-number.interface"; import { getRandomNumberModuleOptions } from "./utils"; //Code. @Global() @Module({}) export class RandomNumberModule { public static forRoot(options: RandomNumberModuleOptions): DynamicModule { const providers: Provider[] = [ { provide: RANDOM_NUMBER_CLIENT_TOKEN, useValue: getRandomNumberModuleOptions(options), } ] return { module: RandomNumberModule, providers: providers, exports: providers, }; } public static forRootAsync( options: RandomNumberModuleAsyncOptions ): DynamicModule { const provider: Provider = { inject: [RANDOM_NUMBER_CLIENT_MODULE_OPTIONS], provide: RANDOM_NUMBER_CLIENT_TOKEN, useFactory: async (options: RandomNumberModuleOptions) => getRandomNumberModuleOptions(options), }; return { module: RandomNumberModule, imports: options.imports, providers: [...this.createAsyncProviders(options), provider], exports: [provider], }; } private static createAsyncProviders( options: RandomNumberModuleAsyncOptions ): Provider[] { if (options.useExisting || options.useFactory) { return [this.createAsyncOptionsProvider(options)]; } const useClass = options.useClass as Type<RandomNumberModuleFactory>; return [ this.createAsyncOptionsProvider(options), { provide: useClass, useClass, }, ]; } private static createAsyncOptionsProvider( options: RandomNumberModuleAsyncOptions ): Provider { if (options.useFactory) { return { provide: RANDOM_NUMBER_CLIENT_MODULE_OPTIONS, useFactory: options.useFactory, inject: options.inject || [], }; } const inject = [ (options.useClass || options.useExisting) as Type<RandomNumberModuleFactory>, ]; return { provide: RANDOM_NUMBER_CLIENT_MODULE_OPTIONS, useFactory: async (optionsFactory: RandomNumberModuleFactory) => await optionsFactory.createApiModuleOptions(), inject, }; } } ``` Please checkout My video on the channel to Learn More about the package publishing to Github using Github actions ### Info About playlist PlalyList Link https://www.youtube.com/watch?v=lVze5eT5DQQ&list=PLIGDNOJWiL18ucL7WGWeVjXmSzOVTRObE GitHub Link https://github.com/tkssharma/publish-packages 🚀 Publish Node JS Utility Package to GitHub 🚀 Publish React JS Component Package to GitHub 🚀 Publish React JS Component and deploy using CI GitHub Actions to GitHub 🚀 Publish Nest JS Utility Package to GitHub 🚀 Publish Nest JS Dynamic Package to GitHub 🚀🚀 How to Publish Private NPM Packages With Github Package Registry We'll begin by first making our modules repository private. Publishing private NPM packages using GitHub Package Registry involves several steps to configure your package and authenticate with GitHub. Here's a step-by-step guide: 🚀🚀 Prerequisites Node.js and npm: Make sure you have Node.js and npm installed. GitHub Account: Ensure you have a GitHub account and a repository where you want to host the package. Repository Permissions: Ensure you have the necessary permissions to publish to the GitHub repository. 🚀🚀We will follow these steps - Create a GitHub Personal Access Token - Authenticating With NPM Using the GitHub Registry - Publish Your Package - Using Your Private Package in Another Project
tkssharma
1,926,079
Entendendo o Fluxo de Trabalho do Prisma Utilizando Migrations
Prisma é um ORM (Object-Relational Mapping) moderno que facilita a interação com bancos de dados em...
0
2024-07-17T01:56:29
https://dev.to/lemartin07/entendendo-o-fluxo-de-trabalho-do-prisma-utilizando-migrations-29cp
prisma, javascript, webdev, programming
Prisma é um ORM (Object-Relational Mapping) moderno que facilita a interação com bancos de dados em aplicações Node.js e TypeScript. Uma das funcionalidades mais importantes do Prisma é o sistema de migrações, que permite manter o esquema do banco de dados sincronizado com o modelo de dados da aplicação. Neste post, vamos explorar o fluxo de trabalho do Prisma utilizando migrations. ## O que são Migrations? Migrations são um método para controlar e aplicar alterações no esquema do banco de dados de forma sistemática e versionada. Elas permitem que você defina mudanças estruturais no banco de dados, como criar ou alterar tabelas, de maneira incremental e reversível. ## Fluxo de Trabalho do Prisma com Migrations O fluxo de trabalho típico com migrations no Prisma envolve os seguintes passos: 1. **Instalação e Configuração Inicial** 2. **Definição do Esquema** 3. **Criação de uma Migration** 4. **Aplicação da Migration** 5. **Gerenciamento de Migrations** ### Passo 1: Instalação e Configuração Inicial Primeiro, precisamos instalar o Prisma no projeto e inicializá-lo: ```bash npm install @prisma/client npx prisma init ``` Este comando cria um diretório `prisma` contendo um arquivo `schema.prisma`, onde definimos nosso modelo de dados. ### Passo 2: Definição do Esquema No arquivo `schema.prisma`, definimos os modelos que representam as tabelas do banco de dados. Por exemplo, vamos definir um modelo `User`: ``` model User { id Int @id @default(autoincrement()) email String @unique name String? } ``` Aqui, estamos definindo uma tabela `User` com colunas `id`, `email` e `name`. ### Passo 3: Criação de uma Migration Depois de definir ou alterar o esquema, criamos uma migration para refletir essas mudanças no banco de dados: ```bash npx prisma migrate dev --name init ``` O comando `migrate dev` cria uma nova migration e aplica as mudanças ao banco de dados. O parâmetro `--name` permite dar um nome descritivo à migration, como `init` no exemplo acima. ### Passo 4: Aplicação da Migration As migrations são aplicadas automaticamente ao banco de dados quando usamos o comando `migrate dev`. Isso garante que o banco de dados esteja sempre em sincronia com o modelo de dados definido no `schema.prisma`. Se você quiser aplicar migrations em um ambiente de produção, utilize o comando: ```bash npx prisma migrate deploy ``` Este comando aplica todas as migrations pendentes no banco de dados de produção. ### Passo 5: Gerenciamento de Migrations Prisma mantém um histórico de todas as migrations aplicadas no banco de dados. Isso é útil para rastrear mudanças e reverter migrations, se necessário. Para ver o histórico de migrations, você pode usar: ```bash npx prisma migrate status ``` Este comando mostra o estado atual das migrations, incluindo quais migrations foram aplicadas e quais estão pendentes. ### Exemplo Prático Vamos ver um exemplo prático de como adicionar um novo campo ao modelo `User` e criar uma migration para essa mudança. 1. **Adicionar o campo ao modelo `User` no `schema.prisma`**: ``` model User { id Int @id @default(autoincrement()) email String @unique name String? birthdate DateTime? } ``` 2. **Criar uma nova migration**: ```bash npx prisma migrate dev --name add-birthdate-to-user ``` 3. **Aplicar a migration**: O comando `migrate dev` já aplica a migration ao banco de dados. Agora, o banco de dados terá o novo campo `birthdate` na tabela `User`. 4. **Verificar o estado das migrations**: ```bash npx prisma migrate status ``` Este comando mostrará que a migration `add-birthdate-to-user` foi aplicada com sucesso. ## Conclusão O fluxo de trabalho do Prisma utilizando migrations é uma maneira eficiente e segura de gerenciar mudanças no esquema do banco de dados. Através de uma sequência clara de passos – definir o esquema, criar migrations, aplicar mudanças e gerenciar o histórico de migrations – é possível manter o banco de dados sincronizado com o modelo de dados da aplicação, facilitando o desenvolvimento e a manutenção do software. Com Prisma, você não apenas simplifica o gerenciamento do banco de dados, mas também ganha uma poderosa ferramenta para garantir que todas as mudanças sejam rastreáveis e reversíveis, contribuindo para um processo de desenvolvimento mais robusto e ágil.
lemartin07
1,926,080
Spotify Premium APK Baixar Gratis Para Android 2024
Nos dias de hoje, ouvir música faz parte do cotidiano de muitas pessoas. Com a popularização dos...
0
2024-07-17T01:56:09
https://dev.to/lestererry2/spotify-premium-apk-baixar-gratis-para-android-2024-54i4
music, mobile, android, appconfig
Nos dias de hoje, ouvir música faz parte do cotidiano de muitas pessoas. Com a popularização dos smartphones, diversos aplicativos de streaming de música surgiram para facilitar o acesso a uma vasta biblioteca musical. Entre eles, o Spotify se destaca como um dos mais populares. Para aqueles que desejam aproveitar todas as funcionalidades oferecidas pelo serviço, a versão Spotify Premium é a escolha ideal. No entanto, alguns usuários buscam alternativas para obter esses benefícios sem custos adicionais, recorrendo ao Spotify Premium APK. Neste artigo, exploraremos o que é esse APK, suas vantagens, riscos e onde encontrá-lo. Link : [https://modilimitado.io/pt/spotify-apk](https://modilimitado.io/pt/spotify-apk) O Que é Spotify Premium APK? O Spotify Premium APK é uma versão modificada do aplicativo original do Spotify. Desenvolvedores independentes criam essas versões alteradas para desbloquear as funcionalidades premium, permitindo que os usuários usufruam de recursos como: Música sem anúncios: Eliminação de todos os anúncios que interrompem a reprodução. Qualidade de áudio superior: Acesso a músicas em alta qualidade de áudio. Modo offline: Capacidade de baixar músicas para ouvir sem conexão à internet. Pular faixas ilimitadamente: Possibilidade de pular quantas faixas quiser, sem restrições. Acesso ilimitado a playlists e álbuns: Exploração completa do catálogo do Spotify sem limitações. Vantagens do Spotify Premium APK Para muitos, a principal vantagem do Spotify Premium APK é a economia de custos. Com essa versão, é possível desfrutar de todos os recursos premium sem a necessidade de uma assinatura paga. Além disso, a liberdade de pular faixas ilimitadamente e ouvir músicas offline são grandes atrativos para quem deseja uma experiência de uso mais flexível. Riscos e Considerações Apesar das vantagens aparentes, o uso do Spotify Premium APK apresenta vários riscos e desvantagens: Segurança: APKs modificados podem conter malware ou spyware, colocando em risco a segurança dos dados pessoais do usuário. Legalidade: O uso de versões modificadas de aplicativos é ilegal e viola os termos de serviço do Spotify. Isso pode resultar na suspensão ou banimento da conta do usuário. Atualizações: APKs não oficiais não recebem atualizações automáticas, o que pode levar a problemas de compatibilidade com o tempo. Suporte: Usuários de versões modificadas não têm acesso ao suporte oficial do Spotify para resolução de problemas ou dúvidas. Onde Encontrar Spotify Premium APK? Embora muitos sites ofereçam downloads do Spotify Premium APK, é crucial lembrar dos riscos associados. Sites de terceiros podem hospedar arquivos inseguros, e a busca por essas versões pode levar a problemas maiores do que os benefícios obtidos. Alternativas Seguras Para aqueles que desejam uma experiência premium no Spotify, a recomendação mais segura é optar pela assinatura oficial do Spotify Premium. O serviço oferece diferentes planos, incluindo descontos para estudantes e pacotes familiares, tornando-o mais acessível para diferentes perfis de usuários. Conclusão O Spotify Premium APK pode parecer uma solução tentadora para quem deseja acessar as funcionalidades premium sem custo, mas os riscos associados à segurança, legalidade e suporte técnico fazem com que essa não seja a melhor opção a longo prazo. Investir na assinatura oficial do Spotify Premium é a maneira mais segura e ética de garantir uma experiência de alta qualidade e suporte contínuo.
lestererry2
1,926,081
So Easy, Even Your Grandma Could Use It (But She'd Probably Just Knit Instead)
Ever felt like writing an API is like solving a Rubik’s cube with your eyes closed? Same here, until...
0
2024-07-17T01:59:47
https://dev.to/themuneebh/so-easy-even-your-grandma-could-use-it-but-shed-probably-just-knit-instead-2701
softwareengineering, fastapi
Ever felt like writing an API is like solving a Rubik’s cube with your eyes closed? Same here, until I discovered FastAPI. I mean, who enjoys all that endless configuration and boilerplate nonsense? But then FastAPI came along and made me wonder why I ever bothered with anything else. The first time I created a complex API using FastAPI, it felt like finding a hidden cheat code in a game. Seriously, I whipped up a fully functional, feature-packed API in no time, with all the boxes ticked: data validation, auto-generated docs, and even async support. It was love at first import. If you haven’t tried FastAPI yet, you’re missing out on something that makes life so much easier. Here’s why you should give it a go: It’s lightning fast, built on Starlette and Pydantic. So simple to use, thanks to its intuitive syntax and clear documentation, that even a newbie can get an API running quickly. And those automatic interactive API docs? They save you from spending hours on documentation. Plus, the clean and effective dependency injection makes your code modular and maintainable. And with async support, FastAPI lets you write non-blocking, highly efficient code. So, if you’re still struggling with complicated frameworks, do yourself a favor and try FastAPI. Who knows, it might save you enough time to pick up a new hobby – like knitting. But let’s be real: you’ll probably just end up coding more.
themuneebh
1,926,082
Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
This story starts when Sébastien Lorber, maintainer of Docusaurus, the React-based open-source documentation project, notices a Pull Request change to the package manifest. Here’s the change proposed to the popular cliui npm package:
0
2024-07-17T02:00:26
https://snyk.io/blog/threads-of-npm-supply-chain-attack/
engineering, vulnerabilityinsights, javascript, node
This story starts when [Sébastien Lorber](https://x.com/sebastienlorber), maintainer of Docusaurus, the React-based open-source documentation project, notices a Pull Request change to the package manifest. Here’s the change proposed to the popular [cliui](https://github.com/yargs/cliui?tab=readme-ov-file) npm package: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-12.png) Specifically, drawing our attention to the npm dependencies change that use an unfamiliar syntax: ``` "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" ``` Most developers would expect to see a semver version range in the value of a package or perhaps a Git or file-based URL. However, in this case, there’s a special npm: prefix syntax. What does it mean? So, in the case of the change proposed in this pull request, the package `string-width-cjs` will resolve to the package `string-width` in versions `^4.2.0`. This means there will be a node\_modules directory entry for `string-width-cjs` but with the contents of `string-width@^4.2.0` and similar behavior in the lockfile (`package-lock.json`). Package aliasing is an npm package manager feature and could legitimately be used for such cases as hinted here (to help with ESM vs CJS support). **With that said, package aliasing can be abused**. In an article and security disclosure dating back to 2021, Nishant Jain, a Snyk Ambassador, demonstrated how the official [npmjs registry could be fooled to misinform dependency information](/blog/exploring-extensions-of-dependency-confusion-attacks-via-npm-package-aliasing/) based on package aliasing as part of a dependency confusion and supply chain security concern. This pull request is indeed benign, and there’s no risk of a supply chain attack. **However, Sébastien was suspicious of such package names** and found out that there was more to be worried about. Finding suspicious behavior in npm lockfiles concerning malicious modules ------------------------------------------------------------------------- When Sébastien examined the pull request, he ran a tool called [lockfile-lint](/advisor/npm-package/lockfile-lint), which helps in validating lockfiles such as `package-lock.json` or `yarn.lock` to ensure that they weren’t tampered with to inject malicious packages instead of the original npm package. Running the tool showed the following warnings: ``` npx lockfile-lint --path package-lock.json --allowed-hosts yarn npm --validate-https --validate-package-names detected resolved URL for package with a different name: string-width-cjs expected: string-width-cjs actual: string-width detected resolved URL for package with a different name: strip-ansi-cjs expected: strip-ansi-cjs actual: strip-ansi detected resolved URL for package with a different name: wrap-ansi-cjs expected: wrap-ansi-cjs actual: wrap-ansi ✖ Error: security issues detected! ``` *Disclaimer: lockfile-lint is a tool that I developed in 2019 following my publication that disclosed the security concern with lockfiles:* [*why npm lockfiles can be a security blindspot for injecting malicious modules*](https://snyk.io/blog/why-npm-lockfiles-can-be-a-security-blindspot-for-injecting-malicious-modules/)*.* High-alert: popular packages look-alikes on npm ----------------------------------------------- Given the above lockfile-lint results, Sébastien looked up these package names on npm and surprisingly found that these do exist on the public npm registry: * [https://www.npmjs.com/package/string-width-cjs]( https://www.npmjs.com/package/string-width-cjs) * <https://www.npmjs.com/package/strip-ansi-cjs> * <https://www.npmjs.com/package/wrap-ansi-cjs> Sébastien noted that not only do these package names exist on npm, but they have indicators that raise concerns: * These packages aren’t tied to any public source code repository * If inspected for their contents, these packages are empty of any actual code. * The author's identity who published these packages is anonymous and isn’t associated with any personal or identifiable information. Looking at the npm package `strip-ansi-cjs`, there’s no README and no source code repository associated with the package but there are many legitimate and popular packages citing the same behavior. In fact, for this particular package, there are signals of popularity in the form of many dependents (other packages that depend on this one) - 529 dependents to be exact, and also a growing number of weekly downloads, totaling 7,274 at the time of writing. ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-11.png) Looking at the code for `strip-ansi-cjs` it shows that there’s only a single file in this package, the package manifest `package.json` file. So, why does a package that doesn’t do anything get so many downloads, and why do so many other packages depend on it? ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-2.png) Let’s continue to inspect the author of these npm packages. All three packages are owned by `himanshutester002`, and their packages were all published last year with programmatic version numbers. Some are interesting to call out: * `isaacs-cliui` npm package - potentially a typosquatting attempt on Isaac’s own fork of the `cliui` project and the legitimate npm package under their namespace: [@isaacs/cliui](https://www.npmjs.com/package/@isaacs/cliui). * `azure-sdk-for-net` npm package - potentially an attempt at dependency confusion campaign to attack private packages of the same name. * `link-deep` npm package - squatting on a popular capability related to utility packages such as lodash and others ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-3.png) You can also note that the user `himanshutester002` has no identifiable information on this user profile page on npmjs. We previously noted that the `strip-ansi-cjs` npm package has over 500 other packages that use it, therefore, potentially a positive indicator for popularity. Let’s look at them: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-1.png) If you give it a glance, this might transfer some sort of legitimacy with this list, but is it? For example, names like `clazz-transformer` or `react-native-multiply` or maybe `gh-monoproject-cli` seem legitimate, but are they? Here is the `react-native-multiply` npm package page: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-4.png) This package has virtually no downloads and its author is also an anonymous npm user with no identifiable information. The source URL repository this package redirects to is `https://github[.]com/hasandader/react-native-multiply` which doesn’t exist and the GitHub user profile looks very suspicious and lacks practical activity. The npm package contents might seem like there’s some actual source code in there, but in reality, it looks like a generated code sample for a “hello world” application prototype. ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-7.png) You also have to wonder, if this package is just a multiplication library, then why does it need 776 dependencies to do the following: ``` import { multiply } from 'react-native-multiply'; const result = await multiply(3, 7); ``` While some may mock JavaScript for its abuse of dependencies, contributing to an astronomical tree of nested packages, it doesn’t make any sense for a project to declare 776 direct (top-level) dependencies. Among all of these dependencies, are the 3 suspicious npm packages that our story began with: `string-width-cjs, strip-ansi-cjs`, and `wrap-ansi-cjs`: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-8.png) We mentioned that one of the `strip-ansi-cjs` dependencies was named `clazz-transformer`. Let’s look at it: ![](https://res.cloudinary.com/snyk/image/upload/v1721139021/blog-supply-chain-attack-5.png) Let’s explain what is happening here: * The npm package name is `clazz-transformer`, yet the package has a title of `class-transformer` at the top of the README’s package page here which was purposely done. * Similarly, the source code repository is `https://github[.]com/typestack/class-transformer` which might be a legitimate repository or a fake one, but it is not associating itself at all with the wording “`clazz`”. The associated repository’s `typstack/class-transformer` on GitHub has the `package.json` file as  follows: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-10.png) Looking at the `package.json` file on GitHub shows no declaration of dependencies, yet if we inspect the source code of the actual package on npmjs we see the 437 dependencies that this `clazz-transformer` is packaged with. Again, very conveniently bundling the 3 suspicious `*-cjs` packages: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-6.png) Further thoughts on suspicious npm package findings --------------------------------------------------- Before we draw further conclusions, it is important to mention a few of the traits of the npm packages we observed above: * The React Native packages seem to be derived from the `create-react-native-library` scaffold tool which also features the default `multiply` function example as part of the stock source code generated for a new project. * Packages have directory and file structures and dependencies that could be derived from Next.js 14 starter boilerplate, such as those created with `npx create-next-app@14`. Our peers at Sonatype have previously identified similar cases of flooding open-source registries with packages. In these cases, the ultimate goal was for developers to reward themselves with [Tea](https://tea.xyz/) tokens, which is a Web3 platform for monetizing open-source software. Finding some `tea.yaml` files in the mentioned packages further supports the thesis that part of this campaign’s purpose is to mine Tea tokens through the misuse of Tea. Earlier this year, on April 14th, 2024, a Tea forum user posted a [comment](https://forum.tea.xyz/t/most-of-the-projects-are-useless-spam/12684) that further supports the concern of tea abuse: ![](https://res.cloudinary.com/snyk/image/upload/v1721139020/blog-supply-chain-attack-9.png) Before reaching out with concluding thoughts, I would like to sincerely thank Sébastien Lorber for his cautious maintainer mindset and for helping unveil these threads of a potential npm supply chain attack. ### What is going on with string-width-cjs? At this point, I have high confidence that I can continue poking holes in the rest of the packages that are supposedly dependent on `string-width-cjs` to find very dubious indicators of authentic legitimacy. It is my assumption that all of these dependent packages and download boosts are leading to the sole purpose of creating false legitimacy for the 3 `*-cjs` packages so that in due time, with the proper victim at play, these fake packages will be installed and then follow with a new malicious version. To help you stay secure while working with open-source software, I highly recommend adopting security practices and specifically these follow-up educational resources: * [Why npm lockfiles can be a security blindspot for injecting malicious modules](https://snyk.io/blog/why-npm-lockfiles-can-be-a-security-blindspot-for-injecting-malicious-modules/) * [10 npm Security Best Practices](https://snyk.io/blog/ten-npm-security-best-practices/) * [NPM security: preventing supply chain attacks](https://snyk.io/blog/npm-security-preventing-supply-chain-attacks/) Did we catch a supply chain security campaign amid their foul-play, or is this all about the money trail and as such can be attributed to spam and abuse of public registries like npm and GitHub to mine for Tea tokens? However this unfolds, stay vigilant.
snyk_sec
1,926,085
Effective Methods to Increase Online Traffic to Your Site
Hey there! If you're like most website owners and digital marketers, you're probably always on the...
0
2024-07-17T02:09:00
https://dev.to/juddiy/effective-methods-to-increase-online-traffic-to-your-site-2hn4
website, learning, marketing
Hey there! If you're like most website owners and digital marketers, you're probably always on the lookout for ways to boost your site’s traffic. Whether you’re launching a new blog, running an e-commerce store, or managing a corporate site, getting more visitors is always a top priority. Let’s dive into some tried-and-true methods that can help you promote your site and see those traffic numbers climb. #### 1. Optimize for Search Engines (SEO) SEO is crucial for driving organic traffic. Make sure your website is optimized for relevant keywords, has quality meta tags, and includes proper header tags. Utilize tools like [SEO AI](https://seoai.run/), Google Analytics and Search Console to track your performance and make necessary adjustments. #### 2. Create High-Quality Content Content is the cornerstone of any successful website. Focus on producing informative, engaging, and valuable content that addresses the needs of your target audience. High-quality content is more likely to be shared and linked to, which can boost your search engine rankings. #### 3. Leverage Social Media Social media platforms are excellent channels for promoting your content. Share your blog posts, videos, and other content on platforms like Facebook, Twitter, LinkedIn, and Instagram. Engage with your audience by responding to comments and participating in conversations. #### 4. Email Marketing Build and maintain an email list to keep your audience informed about new content, updates, and promotions. Send regular newsletters with links to your latest blog posts or special offers. Personalized emails can significantly increase engagement and drive traffic to your site. #### 5. Guest Blogging Write guest posts for reputable websites in your industry. Guest blogging allows you to reach a broader audience, build backlinks, and establish authority in your niche. Ensure your guest posts are high-quality and provide value to readers. #### 6. Collaborate with Influencers Partner with influencers in your industry to promote your content. Influencers can help you reach a larger audience and build credibility. Choose influencers whose audience aligns with your target market. #### 7. Utilize Paid Advertising Invest in paid advertising to boost your website traffic. Platforms like Google Ads, Facebook Ads, and Instagram Ads allow you to target specific demographics and reach a larger audience. Paid ads can provide immediate traffic and complement your organic efforts. #### 8. Engage in Online Communities Participate in online forums and communities related to your industry. Share your expertise, answer questions, and provide valuable insights. Include links to your content where appropriate, but avoid being overly promotional. #### 9. Implement Internal Linking Use internal linking to guide visitors to other relevant pages on your website. Internal links help improve user experience, increase page views, and distribute link equity across your site, which can boost your SEO. #### 10. Monitor and Analyze Performance Regularly monitor your website’s performance using analytics tools. Track key metrics such as traffic, engagement, and conversions. Use this data to identify what works and what doesn’t, and adjust your strategy accordingly. #### 11. Utilize Video Content Video content is becoming increasingly popular and is an excellent way to engage your audience. Create informative and entertaining videos related to your niche and share them on platforms like YouTube, Vimeo, and social media. Videos can drive significant traffic and enhance user engagement. #### 12. Offer Free Resources Offer free resources such as eBooks, whitepapers, templates, or tools that provide value to your audience. This can attract visitors to your site and encourage them to share your content with others. Make sure these resources are high-quality and relevant to your target audience. #### 13. Host Webinars and Live Events Hosting webinars and live events can help you connect with your audience in real-time and provide valuable information. Promote these events through your website, email list, and social media channels. Webinars and live events can generate excitement and drive traffic to your site. #### 14. Implement Schema Markup Schema markup is a type of microdata that helps search engines understand your content better. Implementing schema markup can enhance your site's search engine listings with rich snippets, which can improve click-through rates and drive more traffic. #### 15. Leverage User-Generated Content Encourage your audience to create and share content related to your brand. User-generated content (UGC) can include reviews, testimonials, social media posts, and more. UGC can build trust and credibility, as well as attract new visitors to your site. So there you have it! By following these tips, you can effectively promote your website and watch your traffic grow. Remember, it’s all about being consistent and delivering quality content that resonates with your audience. Good luck, and happy promoting!
juddiy
1,926,096
How to Save and Load Data in Flutter Using SharedPreferences
Managing data in mobile applications is crucial for providing a seamless user experience. One of the...
0
2024-07-17T02:19:30
https://dev.to/design_dev_4494d7953431b6/how-to-save-and-load-data-in-flutter-using-sharedpreferences-5f9n
flutter, dart, data, sharedpreferences
Managing data in mobile applications is crucial for providing a seamless user experience. One of the simplest ways to store data in Flutter is by using the shared_preferences package. This package allows you to save and retrieve data in a key-value pair format, making it perfect for storing simple data like user preferences, settings, and basic app state information. In this blog, we’ll cover: 1. Setting up your Flutter project with shared_preferences 2. Saving and loading numbers 3. Saving and loading strings 4. Saving and loading JSON data 5. A real-life use case example ## 1. Setting Up Your Flutter Project with SharedPreferences ### Step 1: Add Dependencies First, add the shared_preferences package to your project. Open pubspec.yaml and add the dependency: ``` dependencies: flutter: sdk: flutter shared_preferences: ^2.0.8 ``` Run `flutter pub get` to install the package. ### Step 2: Import the Package Import the shared_preferences package in your Dart file: `import 'package:shared_preferences/shared_preferences.dart';` ## 2. Saving and Loading Numbers ### Saving a Number To save a number, you can use the `setInt` method: ``` Future<void> saveNumber(int number) async { final prefs = await SharedPreferences.getInstance(); await prefs.setInt('my_number', number); } ``` ### Loading a Number To load a number, use the `getInt` method: ``` Future<int?> loadNumber() async { final prefs = await SharedPreferences.getInstance(); return prefs.getInt('my_number'); } ``` ## 3. Saving and Loading Strings ### Saving a String To save a string, use the `setString` method: ``` Future<void> saveString(String value) async { final prefs = await SharedPreferences.getInstance(); await prefs.setString('my_string', value); } ``` ### Loading a String To load a string, use the `getString` method: ``` Future<String?> loadString() async { final prefs = await SharedPreferences.getInstance(); return prefs.getString('my_string'); } ``` ## 4. Saving and Loading JSON Data ### Saving JSON Data To save JSON data, first convert the data to a string: ``` import 'dart:convert'; Future<void> saveJson(Map<String, dynamic> data) async { final prefs = await SharedPreferences.getInstance(); String jsonString = jsonEncode(data); await prefs.setString('my_json', jsonString); } ``` ### Loading JSON Data To load JSON data, convert the string back to a map: ``` Future<Map<String, dynamic>?> loadJson() async { final prefs = await SharedPreferences.getInstance(); String? jsonString = prefs.getString('my_json'); if (jsonString != null) { return jsonDecode(jsonString); } return null; } ``` ## 5. Real-Life Use Case Example: User Profile Management Imagine you have an app where users can set their profile information, including their age (number), name (string), and preferences (JSON). Here’s how you can save and load this information using _shared_preferences_. ### Step 1: Save User Profile ``` Future<void> saveUserProfile(int age, String name, Map<String, dynamic> preferences) async { final prefs = await SharedPreferences.getInstance(); await prefs.setInt('user_age', age); await prefs.setString('user_name', name); String preferencesString = jsonEncode(preferences); await prefs.setString('user_preferences', preferencesString); } ``` ### Step 2: Load User Profile ``` Future<Map<String, dynamic>> loadUserProfile() async { final prefs = await SharedPreferences.getInstance(); int? age = prefs.getInt('user_age'); String? name = prefs.getString('user_name'); String? preferencesString = prefs.getString('user_preferences'); Map<String, dynamic>? preferences = preferencesString != null ? jsonDecode(preferencesString) : null; return { 'age': age, 'name': name, 'preferences': preferences, }; } ``` ### Step 3: Example Usage in a Flutter App ``` import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'dart:convert'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: UserProfilePage(), ); } } class UserProfilePage extends StatefulWidget { @override _UserProfilePageState createState() => _UserProfilePageState(); } class _UserProfilePageState extends State<UserProfilePage> { int _age = 0; String _name = ''; Map<String, dynamic> _preferences = {}; @override void initState() { super.initState(); _loadUserProfile(); } Future<void> _saveUserProfile() async { final prefs = await SharedPreferences.getInstance(); await prefs.setInt('user_age', _age); await prefs.setString('user_name', _name); String preferencesString = jsonEncode(_preferences); await prefs.setString('user_preferences', preferencesString); } Future<void> _loadUserProfile() async { final prefs = await SharedPreferences.getInstance(); setState(() { _age = prefs.getInt('user_age') ?? 0; _name = prefs.getString('user_name') ?? ''; String? preferencesString = prefs.getString('user_preferences'); _preferences = preferencesString != null ? jsonDecode(preferencesString) : {}; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('User Profile'), ), body: Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ TextField( decoration: InputDecoration(labelText: 'Name'), onChanged: (value) { setState(() { _name = value; }); }, controller: TextEditingController(text: _name), ), TextField( decoration: InputDecoration(labelText: 'Age'), keyboardType: TextInputType.number, onChanged: (value) { setState(() { _age = int.parse(value); }); }, controller: TextEditingController(text: _age.toString()), ), ElevatedButton( onPressed: () { setState(() { _preferences['dark_mode'] = !_preferences.containsKey('dark_mode') ? true : !_preferences['dark_mode']; }); }, child: Text('Toggle Dark Mode'), ), ElevatedButton( onPressed: _saveUserProfile, child: Text('Save Profile'), ), ElevatedButton( onPressed: _loadUserProfile, child: Text('Load Profile'), ), SizedBox(height: 20), Text('Name: $_name'), Text('Age: $_age'), Text('Preferences: ${_preferences.toString()}'), ], ), ), ); } } ``` ### Conclusion Using shared_preferences in Flutter is an effective way to store and retrieve simple data like numbers, strings, and JSON objects. This guide has shown you how to set up and use shared_preferences for different data types and provided a real-life example of managing user profiles. By integrating shared_preferences into your Flutter app, you can enhance user experience by maintaining state and preferences across sessions. Further Readings: [package info](https://pub.dev/packages/shared_preferences) [docs](https://docs.flutter.dev/cookbook/persistence/key-value) [youtube tutorial](https://www.youtube.com/watch?v=aIirO4sId60)
design_dev_4494d7953431b6
1,926,116
The Minimum Valuable Product Architecture Death Trap
I like to say that there are two kinds of developers, those who deal with legacy code, and those that...
0
2024-07-17T02:47:30
https://dev.to/zelcion/the-mvp-architecture-death-trap-23m1
architecture, beginners
I like to say that there are two kinds of developers, those who deal with legacy code, and those that create it, and we're often times, both. Of course we don't want to be the ones creating legacy code, but how do we prevent code from becoming outdated, or unmaintainable? In my opinion, the answers lies in how you choose to model, and evolve your project. > In this article I mean MVP as Minimum Valuable Product. ## Lifecycle of a dead project If you're like me, I'm sure you enjoy the feeling of starting a new project. Every new line down means great progress, and features are created in minutes! However, as it progresses, adding new functionality becomes increasingly difficult. ![Increasing Effort over time for development](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/74iakoaa291bbctkzv1b.png) Part of this effect is rightfully justified, as the project literally contains and manages more data, but if we don't actively look out we'll inevitably fall into the **Unmaintainability Pit**, and lead our project into an early retirement. I've seen many times this happen, _even with stuff I created_... But throughout the years you start to detect the dangerous paths earlier and better. Our goal, then, is to do work that decreases the rising rate of the effort curve, and this is what a fitting Software Architecture does! > Notice the word "fitting" instead of "good". There's **never** a _one size fits all_ solution. ## Preventing Early Death This next curve is what the development of an enterprise-level software usually looks like. Initially we have to take on additional effort, but we can at least delay reaching the unmaintainable state. ![Decreasing Later Project Effort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxwut3fgz7anu0ur8yjg.png) Although there isn't a clear guide to achieve this, here's a quick rundown on what can be done to go towards this goal: ### Take Your Time Modelling Make sure your abstraction fits the business requirements. If you're working with a client, sit down and work out what are the business actors and actions, as well as the conditions required for each action, and their outcomes. There are frameworks you can use to build your understanding about a system. I used [Lean Inception](https://caroli.org/en/livro/lean-inception-how-to-align-people-and-build-the-right-product/) before, and have been recently taking a look into [EventStorming](https://www.lucidchart.com/blog/ddd-event-storming). ### Expect Changes There's a reason software is called "soft", It is supposed to be changed and adapted, as requirements and rules changes over time. This means your modelling **should** take into consideration what kind of processes are subject to more frequent changes, and what kind of new data they may require to function. In code, this means you must have clear separation of concerns, so future changes are less likely to require scattered changes throughout your code base. Clean Architecture is a certified classic for this subject, just remember to not overdo it in the wrong area and end up with [Enterprise Edition FizzBuzz](https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition). ### Document the Process You should write down the business processes, save any diagrams you made, and how it translates into the code. The process of writing is good for both making sure you understand the concepts, and also often brings up some inconsistencies in the process that you didn't realize there were before starting to write. This one is specially true for teams, but still applies for you if you're on your own. Believe me, you won't remember parts of your software months in, and **It will come back to haunt you**. ## MVP Architecture x Planned Architecture If you're this far, you probably realized that in the end there is always effort, but you can choose to have it upfront and increase of the project's longevity, or be speedy first at the cost of maintainability later on. ![MVP X Planned](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/je5cot2097kwitpazb4l.png) The decision of which path your project will take boils down to two questions: - How fast do I need to iterate? (Need to quickly adapt to testing the market?) - How thoroughly do I know the problem I am solving? (Domain Knowledge) The answer of these questions will make you land somewhere on this decision compass. ![Decision Compass](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f09h4bo58phtit887dsr.png) ## Iterating on Architecture Itself Of course, not everything is set in stone, in terms of your architecture. You can still pick for a fast initial iterating time, and improve the architecture when you see the need. **This is actually what I've seen experienced developers do.** Of course, this is not easy as well, because you will need to pick the right abstractions at the right project maturity time. Nonetheless, it is possible and a skill you can learn. Just be sure to take action before the "Project Maturity Point", or your project will likely **not launch** because you didn't iterate fast enough, or be **legacy code** you will need to fully replace. ## What I'm doing in this front I recognized this problem early in my career (not that I'm an expert), and came up with a project that I've been working on for the last 4 Years. If you liked what you've read, you'll probably like it as well. Meet [Meta-System](https://github.com/mapikit/meta-system), The Everything Framework for Efficient Developers. It is a data-first approach to software architecture, reducing the need for duplicated code, or increasingly complex architectural setups. You can join its [discord server](https://discord.gg/ndGsnbTW7V) for talking directly with me and for clearing any questions you might have, and even contributing if that's more of your thing. ---- Connect with me on [X](https://twitter.com/ZelcionV) and [LinkedIn](https://www.linkedin.com/in/fabio-meneses-jr/).
zelcion
1,926,130
10 Best Practices for Optimizing Angular Performance
Optimizing the performance of your Angular application is crucial for providing a smooth user...
0
2024-07-17T02:22:02
https://dev.to/dipakahirav/10-best-practices-for-optimizing-angular-performance-2345
angular, webdev, javascript, productivity
Optimizing the performance of your Angular application is crucial for providing a smooth user experience. Here are 10 best practices to help you get the most out of your Angular apps. please subscribe to my [YouTube channel](https://www.youtube.com/@DevDivewithDipak?sub_confirmation=1 ) to support my channel and get more web development tutorials. --- ## 1. OnPush Change Detection Strategy 🧠 By default, Angular uses the `Default` change detection strategy, which checks all components for changes. Using the `OnPush` strategy reduces the number of checks by only checking components when their inputs change. ```typescript @Component({ selector: 'app-my-component', templateUrl: './my-component.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) export class MyComponent { @Input() data: any; } ``` --- ## 2. Use TrackBy with ngFor 🔄 Using `trackBy` in `ngFor` helps Angular identify items in a list, reducing the number of DOM manipulations. ```html <div *ngFor="let item of items; trackBy: trackByFn"> {{ item.name }} </div> ``` ```typescript trackByFn(index, item) { return item.id; } ``` --- ## 3. Lazy Loading Modules 📦 Lazy loading modules ensures that only the necessary parts of your application are loaded, reducing the initial load time. ```typescript const routes: Routes = [ { path: 'feature', loadChildren: () => import('./feature/feature.module').then(m => m.FeatureModule) } ]; ``` --- ## 4. Optimize Template Expressions 🖋️ Avoid complex calculations and function calls in template expressions. Instead, compute values in the component class and bind them to the template. ```html <!-- Instead of this --> <div>{{ computeHeavyTask() }}</div> <!-- Use this --> <div>{{ computedValue }}</div> ``` ```typescript ngOnInit() { this.computedValue = this.computeHeavyTask(); } ``` --- ## 5. Use AOT Compilation 🛠️ Ahead-of-Time (AOT) compilation pre-compiles your Angular templates and components, resulting in faster rendering and smaller bundle sizes. ```bash ng build --prod --aot ``` --- ## 6. Optimize Styles and Scripts Loading 🎨 Load styles and scripts conditionally to reduce the initial load. Use `ngStyle` and `ngClass` for conditional styling. ```html <div [ngClass]="{'class-a': conditionA, 'class-b': conditionB}"></div> ``` --- ## 7. Use Pure Pipes for Data Transformation 📊 Pure pipes are stateless and only recalculate when their input arguments change, making them more efficient than impure pipes. ```typescript @Pipe({ name: 'purePipe', pure: true }) export class PurePipe implements PipeTransform { transform(value: any, ...args: any[]): any { // Transformation logic } } ``` --- ## 8. Minimize the Use of Third-Party Libraries 📚 Only include necessary third-party libraries and remove unused ones. This reduces the bundle size and improves load times. ```bash npm prune ``` --- ## 9. Optimize Images and Assets 🖼️ Use optimized images and lazy load them to improve performance. Tools like ImageOptim or online services can help reduce image sizes. ```html <img [src]="imageSrc" loading="lazy" /> ``` --- ## 10. Avoid Memory Leaks 🧹 Unsubscribe from Observables and detach event listeners to prevent memory leaks. ```typescript @Component({ selector: 'app-my-component', templateUrl: './my-component.component.html' }) export class MyComponent implements OnDestroy { private subscription: Subscription; ngOnInit() { this.subscription = this.myService.getData().subscribe(); } ngOnDestroy() { this.subscription.unsubscribe(); } } ``` --- By following these best practices, you can optimize the performance of your Angular applications, providing a better experience for your users. Happy coding! 🚀 Feel free to leave your comments or questions below. If you found this guide helpful, please share it with your peers and follow me for more web development tutorials. Happy coding! ### Follow and Subscribe: - **Website**: [Dipak Ahirav] (https://www.dipakahirav.com) - **Email**: dipaksahirav@gmail.com - **YouTube**: [devDive with Dipak](https://www.youtube.com/@DevDivewithDipak?sub_confirmation=1 ) - **LinkedIn**: [Dipak Ahirav](https://www.linkedin.com/in/dipak-ahirav-606bba128)
dipakahirav
1,926,131
Ruby on Rails pluck method
ActiveRecord is an important part of Ruby on Rails (the M in MVC) and is an Object Relational Mapping...
0
2024-07-17T12:30:00
https://anthonygharvey.com/ruby-on-rails-pluck-method
ruby, rails, beginners
ActiveRecord is an important part of Ruby on Rails ([the M in MVC](https://guides.rubyonrails.org/active_record_basics.html#what-is-active-record-questionmark)) and is an Object Relational Mapping system (ORM) that maps the objects in your app to tables in your database. By using ActiveRecord (or any ORM) the attributes of your objects and the relationships between them can be saved and retrieved from your database without writing SQL statements. One of the helpful methods that ActiveRecord provides to help facilitate this is `pluck`. ## What is the `pluck` method? According to the [Rails Guides](https://guides.rubyonrails.org/active_record_querying.html#pluck): > [`pluck`](https://api.rubyonrails.org/v7.1.3.4/classes/ActiveRecord/Calculations.html#method-i-pluck) can be used to pick the value(s) from the named column(s) in the current relation. It accepts a list of column names as an argument and returns an array of values of the specified columns with the corresponding data type. Put another way, `pluck` let's you specify one or more columns that are defined on an ActiveRecord model and returns the values in an Array. ```ruby Order.pluck(:id) # SELECT orders.id FROM orders => [1, 2, 3] ``` Passing more than one column argument returns a nested array with values for each of the columns in each of the inner arrays. In this example the values for `id` and `shipped` will be in the inner arrays. ```ruby Order.pluck(:id, :status) # SELECT orders.id, orders.status FROM orders => [[1, "shipped"], [2, "pending"], [3, "pending"]] ``` You can achieve similar results using `select` and `map`, but `pluck` allows you to just specify the column(s) you want and get that data back. ```ruby Order.select(:id).map{ |o| o.id } Order.select(:id).map(&:id) Order.select(:id, :status).map{ |o| [o.id, o.status] } ``` Using `select` and `map` together like this produces the same results, but you can replace the above code with `pluck` and avoid chaining multiple methods. Plus, it's a little more concise, easier to read and usually faster. ## What makes `pluck` faster than `select` and `map`? When using `select`, it builds entire ActiveRecord objects from the database, which can be costly for large objects and for large queries if there are a lot of objects retrieved. Plus, there's the added step of mapping over the results to return the data in the shape that you want. `pluck`, on the other hand, skips creating ActiveRecord objects entirely and only returns the data from the columns that you specified. ## Using `pluck` to query multiple tables You can also use `pluck` to query across joined tables as well. ```ruby Order.joins(:customer).pluck("orders.id, customers.first_name") ``` ## Using `pluck` on Enumerables You can also use `pluck` on Enumerables to return the values you want by specifying the key(s). You just have to `require` ActiveSupport, which [extends Enumerable](https://guides.rubyonrails.org/active_support_core_extensions.html#pluck) with the `pluck` method. ```ruby [{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name) # => ["David", "Rafael", "Aaron"] [{ id: 1, name: "David" }, { id: 2, name: "Rafael" }].pluck(:id, :name) # => [[1, "David"], [2, "Rafael"]] ``` ## When to not use `pluck` One thing to keep in mind when using `pluck` is if you already have access to an Array of ActiveRecord objects that you're retrieved from the database. Calling `pluck` on that Array of ActiveRecord objects will trigger an additional query to the database. You can avoid this extra round trip to the database by using `map` instead. ```ruby order_ids = [] completed_orders = Order.where(status: "completed") completed_orders.each do |order| # .each will make a database call order_ids << order.id end # will trigger an unecessary database call completed_orders.pluck(:total) # the completed_orders array is already loaded in memory # and we can just map over the array completed_orders.map(&:total) ``` ## Recent Update to `pluck` A [Pull Request](https://github.com/rails/rails/pull/51565) was introduced by [fatkodima](https://github.com/fatkodima) and merged into Rails on April 13, 2024 to allow `ActiveRecord::Base#pluck` to accept hash values! From the PR: ```ruby # Before Post.joins(:comments).pluck("posts.id", "comments.id", "comments.body") # After Post.joins(:comments).pluck(posts: [:id], comments: [:id, :body]) ``` --- ## Resources 1. [RailsGuides: Finding by SQL - pluck](https://guides.rubyonrails.org/active_record_querying.html#pluck) 2. [Rails API Docs - Active Record Calculations - pluck](https://api.rubyonrails.org/v7.1.3.4/classes/ActiveRecord/Calculations.html#method-i-pluck) _This article was originally published on [anthonygharvey.com](url) on July 16th, 2024._
anthonyharvey
1,926,132
Highly Recommended 'Quick Start with Rust' Course
The article is about the "Quick Start with Rust" course, which is highly recommended for those looking to dive into the world of Rust programming. The course provides a comprehensive introduction to the Rust language, covering essential topics such as installation, syntax, core concepts, and practical application through the development of a guessing game. The article highlights the course's key features, including setting up a Rust development environment, understanding Rust's fundamentals, and gaining hands-on experience. With a focus on guiding learners from beginner to proficient Rust developers, this course is an excellent starting point for anyone interested in exploring the capabilities of this powerful programming language.
27,674
2024-07-17T02:29:56
https://dev.to/labex/highly-recommended-quick-start-with-rust-course-jao
labex, programming, course, linux
Rust is a powerful and versatile programming language that has gained significant popularity in recent years, particularly in the realm of systems programming, web development, and beyond. If you're looking to dive into the world of Rust and kickstart your journey as a Rust developer, the [Quick Start with Rust course](https://labex.io/courses/quick-start-with-rustgetting-started-with-rust) offered by LabEx is an excellent starting point. ![MindMap](https://internal-api-drive-stream.feishu.cn/space/api/box/stream/download/authcode/?code=ZjEyMmE0ZWNlOTU2ODVjMmUxM2EwM2U2NzIzOGRlYjRfZTVmYjIxZGRjZDg4NzJkY2Q4MDY1MWNlNGY2OTNmNTVfSUQ6NzM5MTU0NzcxNTY1OTc5MjM4OF8xNzIxMTgzMzkzOjE3MjEyNjk3OTNfVjM) ## Course Overview This comprehensive course is designed to provide you with a solid foundation in the Rust programming language. Whether you're a seasoned programmer or a complete beginner, the course will guide you through the essential concepts and equip you with the necessary skills to write robust and efficient Rust applications. ## Key Topics Covered ### 1. Rust Installation and Cargo The course begins by teaching you how to set up a Rust development environment and familiarize yourself with the Cargo build system, which is the de facto standard for managing Rust projects. ### 2. Rust Syntax and Core Concepts You'll dive into the core syntax and language features of Rust, including variable declarations, data types, functions, and control flow structures. This foundational knowledge will serve as the building blocks for your Rust programming journey. ### 3. Rust in Practice Throughout the course, you'll have the opportunity to apply your newfound knowledge by developing a simple guessing game application using Rust. This hands-on experience will help you solidify your understanding and gain practical skills in Rust programming. ## Learning Outcomes By the end of this course, you will be able to: - Set up a Rust development environment and utilize Cargo for project management - Write basic Rust programs that demonstrate a strong grasp of the language's syntax and core concepts - Develop a simple yet engaging guessing game application using Rust - Confidently continue your Rust learning journey and explore more advanced topics Don't miss this chance to [dive into the world of Rust with the Quick Start with Rust course](https://labex.io/courses/quick-start-with-rustgetting-started-with-rust). Enroll today and embark on an exciting path towards becoming a proficient Rust developer. ## LabEx: A Comprehensive Learning Platform LabEx stands out as a premier online learning platform that seamlessly combines interactive coding environments with step-by-step tutorials, making it an ideal choice for aspiring programmers, especially beginners. Each course offered by LabEx is accompanied by a dedicated Playground environment, allowing learners to put their newfound knowledge into practice immediately. The platform's structured approach to learning ensures a smooth and engaging experience. Learners can progress through the lessons step-by-step, with each step supported by automated verification. This immediate feedback mechanism helps learners quickly identify and address any gaps in their understanding, accelerating their learning journey. Furthermore, LabEx provides an AI-powered learning assistant to support learners throughout their studies. This intelligent assistant offers valuable services, such as code error correction and concept explanation, ensuring that learners receive the guidance they need to overcome challenges and deepen their comprehension of the material. By leveraging the power of interactive coding environments, structured tutorials, and AI-driven assistance, LabEx creates a comprehensive learning platform that empowers students to master programming languages and develop practical skills with confidence. --- ## Want to Learn More? - 🌳 Explore [20+ Skill Trees](https://labex.io/learn) - 🚀 Practice Hundreds of [Programming Projects](https://labex.io/projects) - 💬 Join our [Discord](https://discord.gg/J6k3u69nU6) or tweet us [@WeAreLabEx](https://twitter.com/WeAreLabEx)
labby
1,926,133
Turning Documentation into a Product: Best Practices for Success
Explore best practices for turning documentation into a successful product with real-world insights. Elevate your docs by learning from industry experts!
25,852
2024-07-17T02:36:59
https://codingcat.dev/podcast/turning-documentation-into-a-product-best-practices-for-success
webdev, javascript, beginners, podcast
Original: https://codingcat.dev/podcast/turning-documentation-into-a-product-best-practices-for-success {% youtube https://youtu.be/5XP0uwMFP20 %} ## Introduction and Tech-Related Banter * **Technical Setup Issues**: The video begins with the host experiencing some technical difficulties related to the pre-roll video. * **Guest Introduction**: Vincent, the guest, is introduced. He recently changed jobs and shares some light-hearted banter with the host. ## Vincent's Journey into Tech * **Career Path**: Vincent explains his unique journey from aspiring to be an electrical engineer to becoming involved in software development. He cites his initial influence from a Minecraft streamer. * **Role Transition**: He details his transition from electrical engineering to mobile QA, firmware development, product management, and finally technical writing and developer relations. ## Challenges in Technical Writing * **Language Barriers**: Vincent discusses the nuances of English as a second language and how it impacts his technical writing. * **Writing Style**: He emphasizes the importance of clear, simple language in technical writing to ensure comprehensibility. Complicated language often makes documentation less accessible. ## Importance of Documentation * **Product Discovery**: The discussion includes how crucial it is for documentation to aid in the user journey from discovering the product to effectively using it. * **Feedback Loop**: Vincent shares his practice of testing documentation clarity by walking through it with colleagues or new hires to identify pain points. ## Analyzing Documentation Layouts * **Various Documentation Sites**: The host and Vincent review different documentation sites (Cloudinary, Algolia, Appwrite, and Stripe) highlighting strengths and weaknesses. * **User Experience**: They discuss how the organization and presentation of documentation significantly affect user retention and education. ## Treating Documentation as a Product * **Investment in Documentation**: Vincent suggests documenting like a product, highlighting the importance of making a business case for comprehensive documentation. * **User Journey in Docs**: He explains that documentation should be tailored to closely follow the user journey, from first-time use to advanced usage scenarios. ## Pain Points and Best Practices * **Design Collaboration**: He advises integrating documentation writing within the product design phase to ensure that both documentation and product flow are aligned from the beginning. * **Measuring Effectiveness**: Vincent talks about using analytics to track user engagement with documentation, identifying drop-off points, and iterating based on these insights. ## Future of Documentation and AI * **AI Integration**: The conversation veers into the future role of AI in generating and maintaining documentation. Vincent believes that while AI can assist, human-written documentation will always be required for niche, complex use cases. * **Role Transition**: He envisions AI handling more straightforward documentation tasks with technical writers focusing on nuanced, detailed, and unique documentation needs. ## Personal Insights and Preferences * **Preferred Tools**: Vincent suggests starting with markdown-based documentation tools like Starlight from Astro for their flexibility and ease of migration. * **Tips for New Businesses**: He recommends keeping documentation simple and generic initially to allow for future adjustments and scalability. ## Documentation Tools [https://www.gitbook.com/](https://www.gitbook.com/) [https://docusaurus.io/](https://docusaurus.io/) [https://starlight.astro.build/](https://starlight.astro.build/) [https://vuepress.vuejs.org/](https://vuepress.vuejs.org/)
codercatdev
1,926,135
Ubat Buasir Untuk Ibu Mengandung
Ubat Buasir untuk Ibu Mengandung: Panduan dan Pertimbangan Buasir, atau hemoroid, adalah masalah...
0
2024-07-17T02:37:59
https://dev.to/indah_indri_a299aff67faef/ubat-buasir-untuk-ibu-mengandung-3c0c
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zyiwcp1gah560fpiq8j.jpeg) **Ubat Buasir untuk Ibu Mengandung: Panduan dan Pertimbangan** Buasir, atau hemoroid, adalah masalah umum yang boleh dialami oleh sesetengah wanita semasa kehamilan. Ini berlaku apabila urat di dalam dubur atau sekeliling dubur menjadi bengkak dan meradang. Bagi ibu mengandung, memilih ubat yang sesuai untuk merawat buasir adalah penting kerana keselamatan dan kesihatan bayi yang dikandung perlu dipertimbangkan dengan teliti. **Penyebab Buasir Semasa Kehamilan** Buasir semasa kehamilan biasanya disebabkan oleh peningkatan tekanan pada urat dubur akibat faktor-faktor berikut: 1. Peningkatan Tekanan Perut: Pertumbuhan janin yang membesar boleh memberi tekanan pada saluran pencernaan, termasuk usus besar. 2. Perubahan Hormonal: Perubahan hormon semasa kehamilan boleh menyebabkan dinding urat menjadi lebih lemah dan mudah bengkak. 3. Kegagalan Pergerakan Usus: Kebiasaan sembelit semasa kehamilan boleh **meningkatkan tekanan pada urat dubur** Pengurusan Buasir Semasa Kehamilan Untuk merawat buasir semasa hamil, penting untuk mengambil langkah-langkah yang sesuai dan berhati-hati. Berikut adalah beberapa panduan umum: 1. Penjagaan Kecemasan: Amalkan diet tinggi serat untuk mengelakkan sembelit. Minum banyak air dan senaman ringan seperti berjalan kaki boleh membantu meningkatkan pergerakan usus. 2. Penggunaan Ubat: Menggunakan ubat topikal seperti krim atau salep boleh membantu mengurangkan kesakitan dan bengkak. Walau bagaimanapun, ubat ini harus digunakan mengikut arahan doktor kerana tidak semua ubat selamat untuk ibu mengandung. 3. Saranan Perubatan: Selalu berbincang dengan doktor sebelum mengambil ubat-ubatan tertentu. Mereka akan dapat memberikan nasihat yang terbaik berdasarkan keadaan kesihatan anda dan tahap kehamilan. **Ubat Buasir Selamat untuk Ibu Mengandung** Dalam kebanyakan kes, doktor mungkin akan menasihati penggunaan ubat-ubatan tempatan yang mengandungi bahan seperti kortikosteroid atau anaestetik untuk mengurangkan gejala buasir. Walau bagaimanapun, ubat-ubatan ini harus digunakan dengan berhati-hati dan mengikut preskripsi doktor ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tqebn8s2m7qthuan3dn.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k96iopc616t56mw6zbqa.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrpb1ezmlm5furcwug10.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3y0vifc9p9gunwf060q0.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wex7nkeckhstsodj8xix.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dq2qw9rvz1nxl5ivxlq8.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cswqi9rpq38adwvpbo8r.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhzqlc5lc3zak7f555a6.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjlnsnw8cpg9rl6gi6uh.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/48rpbrfayhcvjbrh7dox.jpeg) HUBUNGI KAMI [KLIK DISINI](https://wa.link/7ar38m) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4le2rfxp4vw9lb4t56hc.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phihwb8k5l7xf5rueg0w.jpeg) SUMBER https://www.sembuhlah.com/ubat-buasir-herba/
indah_indri_a299aff67faef
1,926,136
Upgrading badly with AI
A Linux user’s anecdote about updating Linux Mint 20 Una to Linux Mint 21 Vera using advice from the AI search tool Perplexity
0
2024-07-17T10:00:00
https://dev.to/strivenword/upgrading-badly-with-ai-45m4
linux, ai, llm, upgrading
--- title: Upgrading badly with AI published: true description: A Linux user’s anecdote about updating Linux Mint 20 Una to Linux Mint 21 Vera using advice from the AI search tool Perplexity tags: [linux, ai, llm, upgrading] cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mp7quvoclizu53lz4dch.jpg # Use a ratio of 100:42 for best results. published_at: 2024-07-17 06:00 -0400 --- This is an anecdotal take on my experience of updating from Linux Mint 20 Una to Linux Mint 21 Vera and my experience of using an AI chatbot tool, Perplexity, for my information searching and troubleshooting processes. I didn’t follow the officially recommended upgrade procedure or properly use the distro’s upgrade tool. I got a broken DE, but everything ended up being okay. I offer my chat [transcript](https://www.perplexity.ai/search/i-want-to-manually-upgrade-fro-z2FDK65iQke4XTC56hBydg) in Perplexity as a resource. I wasn’t directly following any official [guides](https://blog.linuxmint.com/?p=4629) or community forum discussions. I wasn’t expecting my ultimate success. I had copied all my stuff onto a USB drive, an activity that is basically a personal ritual at this point, since I’ve been sloppily hacking my way through Linux for 12 years. In fact, I had been planning to wipe the system and start over with Arch Linux, but unfortunately the Arch Linux live installer didn’t find my wifi hardware. With several experiences of struggling tediously and often fruitlessly to fix Linux driver problems, I wagered it would be more worthwhile and more fun to try to hack my disappointingly stable Linux Mint installation than to follow the rules. The major oversight was not ensuring that the desktop environment, Cinnamon, was reconfigured and upgraded from the new Vera repositories. I dealt with the broken DE, going through the process in a circular discussion with Perplexity that highlights to me the reasonable limitations of AI. The AI failed to suggest that I simply needed to use the command ``startx`` to reload the DE after I had upgraded Cinnamon. It seemed to think the problem lay with my NVIDIA driver, and the rabbit hole of web [sources](https://forums.developer.nvidia.com/t/linux-kernel-vs-nvidia-driver-version/287029) cited by Perplexity lead me to **nvidia-driver-535**. It seems to me that AI currently can’t reason outside of its functional loop, even though that functional loop is now subjective and hard to define. Our newly subjective models can pull off a lot of heavy information work and can spark useful brainstorming, but they need input from beyond the reach of their processes. This is a feature, not a bug. Getting clever responses from AI and using those responses well requires creative reasoning. Because I was cowboy-hacking based on a language model’s broadly cast artificial-neural dump from the silicone representation of the collective consciousness, I didn’t know that I was supposed to use the tool **mintupgrade** to manage the repository transition process. Perplexity had suggested I run **mintupgrade** after I update the repositories from **una** and **focal** to **vera** and **jammy**. I had rebooted after manually replacing the string ”focal” with ”jammy” in all the repo source configuration files. I had forgotten at first to also replace every occurrence of ”una” with ”vera”. This was probably the cause of the broken DE. I’m not sure whether or not the DE would have broken after I had upgraded if I had initially done the Linux Mint repository transition as well as the Ubuntu transition. From the broken system I encountered after the reboot, I simply had to edit the configuration files accordingly, update and upgrade again, reinstall Cinnamon, and then restart the X server with the command ``startx``. (If you happen to be reading this and are becoming frustrated that I have but vaguely described the process I went through, I can only apologize with an equally vague gesture toward the fact of mental exhaustion. I have had many maddening and even depressing experiences combing over step-by-step descriptions of others’ Linux troubleshooting writeups on forums and blogs and wikis, becoming increasingly perturbed by my promising progress and increasing understanding while tripping up without hope of recovery due to the omission of critical little details that I needed. This is a reason why LLM chatbots are helpful tools.) *Cover image generated using DALL-E.*
strivenword
1,926,137
Tracking Health with Data Engineering - Chapter 1: Meal Optimization
Introduction Hello, everyone! This will be my first post so be harsh with me, critique me...
0
2024-07-17T10:13:14
https://dev.to/wilyanse/tracking-health-with-data-engineering-chapter-1-meal-optimization-2cl7
datascience, dataengineering, python
# Introduction Hello, everyone! This will be my first post so be harsh with me, critique me where you think I can improve on and I will surely take it into account next time. For the past few months, I have been deeply into health, mainly exercising and watching what I eat, and now that I think I've got a solid grasp on it, I wanted to see how I can further optimize in the case that there are some things that I might have missed. # Objectives For this chapter, I wish to go into studying my meals throughout my health journey and conclude with a meal plan for the next week that (1) hits my minimum protein requirements, (2) does not go past my calorie limit, (3) hits my minimum fiber requirements, and (4) minimizes cost. # Dataset We start by introducing the dataset, the food that we've tracked using Cronometer. [Cronometer](https://cronometer.com/about/) has been working with me side-by-side in my journey and now, I will be exporting the data that I've input to analyze for myself with the objectives I have previously listed. Luckily for me, Cronometer lets me export data to a .csv file with ease on their website. ![Screenshot of the export options from Cronometer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su7fkrzhq3yefhon28sx.png) For this chapter, we will be exporting only the 'Food & Recipe Entries' dataset. We start with examining the data we got from 'Food & Recipe Entries'. The dataset is very comprehensive, which I'm sure will be great for future chapters! In this chapter, we do want to limit it to the name of the food, its amount, protein, calories, and fiber. ``` # Importing and checking out the dataset df = pd.read_csv("servings.csv") df.head() ``` # Data Preprocessing We already have some columns set for us, in 'Food Name', 'Amount', 'Energy (kcal)', 'Fiber (g)', and 'Protein (g)'. Perfect! Now, the only thing we lack is to get the cost for each food given a certain amount as it was not being tracked in the dataset. Luckily for me, I was the one who input the data in the first place so I can input the prices that I do know. However, I will not be inputting prices for all of the food items. Instead, we ask our good old friend ChatGPT for their estimate and fill in the prices that we do know by tweaking the .csv file. We store the new dataset in 'cost.csv' which we derived by taking the 'Food Name' and 'Amount' columns from the original dataset. ``` # Group by 'Food Name' and collect unique 'Amount' for each group grouped_df = df.groupby('Food Name')['Amount'].unique().reset_index() # Expand the DataFrame so each unique 'Food Name' and 'Amount' is on a separate row expanded_df = grouped_df.explode('Amount') # Export the DataFrame to a CSV file expanded_df.to_csv('grouped_food_names_amounts.csv') # Read the added costs and save as a new DataFrame df_cost = pd.read_csv("cost.csv").dropna() df_cost.head() ``` Some foods were dropped simply because they were too oddly specific and would not be in the scope of the data of being low-calorie, nutritious, and/or cheap (or simply because I could not be bothered with making the recipe again). We then would need to merge two data frames, the original dataset and the one with the cost, in order to obtain the supposed 'final' dataset. Since the original dataset contains the entries for each food, this means the original dataset has multiple entries of the same food, especially those that I eat repeatedly (i.e. eggs, chicken breast, rice). We also want to fill columns without values with '0' as the most likely source of problems here would be the 'Energy', 'Fiber', 'Protein', and 'Price' columns. ``` merged_df = pd.merge(df, df_cost, on=['Food Name', 'Amount'], how='inner') specified_columns = ['Food Name', 'Amount', 'Energy (kcal)', 'Fiber (g)', 'Protein (g)', 'Price'] final_df = merged_df[specified_columns].drop_duplicates() final_df.fillna(0, inplace=True) final_df.head() ``` # Optimization Perfect! Our dataset is finished and now, we begin with the second part, optimization. Recalling the objectives of the study, we want to identify the least cost given a minimum amount of protein and fiber, and a maximum amount of calories. The option here is to brute force every single combination, but in the industry the proper term is ["Linear Programming" or "Linear Optimization" ](https://en.wikipedia.org/wiki/Linear_programming#:~:text=Linear%20programming%20(LP)%2C%20also,are%20represented%20by%20linear%20relationships) but don't quote me on that. This time, we will be using [puLP](https://coin-or.github.io/pulp/index.html) which is a Python library that is aimed towards doing exactly that. I do not know much about using it besides following the template, so do browse their [documentation](https://coin-or.github.io/pulp/index.html) instead of reading my unprofessional explanation of how it works. But for those who do want to listen to my casual explanation of the topic, we're basically solving for y = ax1 + bx2 + cx3 + ... + zxn. The template we will be following is the template for the [Case Study of the Blending problem](https://coin-or.github.io/pulp/CaseStudies/a_blending_problem.html), where we follow similar objectives but in this case, we want to blend our meals throughout the day. In order to start, we would need to convert the DataFrame into dictionaries, specifically, the 'Food Name' as a list of independent variables that serve as the series of x's, then Energy, Fiber, Protein, and Price as a dictionary such that 'Food Name': value for each. Do note that the Amount will be foregone from here on out, and will instead be concatenated with the 'Food Name' as we will not be using it quantitatively. ``` # Concatenate Amount into Food Name final_df['Food Name'] = final_df['Food Name'] + ' ' + final_df['Amount'].astype(str) food_names = final_df['Food Name'].tolist() # Create dictionaries for 'Energy', 'Fiber', 'Protein', and 'Price' energy_dict = final_df.set_index('Food Name')['Energy (kcal)'].to_dict() fiber_dict = final_df.set_index('Food Name')['Fiber (g)'].to_dict() fiber_dict['Gardenia, High Fiber Wheat Raisin Loaf 1.00 Slice'] = 3 fiber_dict['Gardenia, High Fiber Wheat Raisin Loaf 2.00 Slice'] = 6 protein_dict = final_df.set_index('Food Name')['Protein (g)'].to_dict() price_dict = final_df.set_index('Food Name')['Price'].to_dict() # Display the results print("Food Names Array:", food_names) print("Energy Dictionary:", energy_dict) print("Fiber Dictionary:", fiber_dict) print("Protein Dictionary:", protein_dict) print("Price Dictionary:", price_dict) ``` For those without keen eyesight, continue scrolling. For those who did notice the eerie 2 lines of code, let me explain. I saw this while I was grocery shopping but the nutrition facts on Gardenia's High Fiber Wheat Raisin loaf do not actually have 1 slice be 9 grams of Fiber, it has 2 slices for 6 grams. This is a big deal and has caused me immeasurable pain knowing that the values may be incorrect due to either a misinput of data or a change of ingredients which caused the data to be outdated. Either way, I needed this justice corrected and I will not stand for any less Fiber than I deserve. Moving on. We go straight into plugging in our values using the template from the Case Study data. We set variables to stand for the minimum values we want out of Protein and Fiber, as well as the maximum Calories we are willing to eat. Then, we let the magical template code do its work and get the results. ``` # Set variables min_protein = 120 min_fiber = 40 max_energy = 1500 # Just read the case study at https://coin-or.github.io/pulp/CaseStudies/a_blending_problem.html. They explain it way better than I ever could. prob = LpProblem("Meal Optimization", LpMinimize) food_vars = LpVariable.dicts("Food", food_names, 0) prob += ( lpSum([price_dict[i] * food_vars[i] for i in food_names]), "Total Cost of Food daily", ) prob += ( lpSum([energy_dict[i] * food_vars[i] for i in food_names]) <= max_energy, "EnergyRequirement", ) prob += ( lpSum([fiber_dict[i] * food_vars[i] for i in food_names]) >= min_fiber, "FiberRequirement", ) prob += ( lpSum([protein_dict[i] * food_vars[i] for i in food_names]) >= min_protein, "ProteinRequirement", ) prob.writeLP("MealOptimization.lp") prob.solve() print("Status:", LpStatus[prob.status]) for v in prob.variables(): if v.varValue > 0: print(v.name, "=", v.varValue) print("Total Cost of Food per day = ", value(prob.objective)) ``` # Results ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kxqmw9ppz6ty5dec9po1.png) In order to get 120 grams of protein and 40 grams of fiber, I would need to spend 128 Philippine Pesos on 269 grams of chicken breast fillet, and 526 grams of mung beans. This... does not sound bad at all considering how much I love both ingredients. I will definitely try it out, maybe for a week or a month just to see how much money I would save despite having just enough nutrition. That was it for this chapter of Tracking Health with Data Engineering, if you want to see the data I worked on in this chapter, visit the [repository](https://github.com/wilyanse/dev_blog_notebooks) or visit the [notebook](https://github.com/wilyanse/dev_blog_notebooks/blob/main/01_Meal_Optimization/Meal_Optimization.ipynb) for this page. Do leave a comment if you have any and try to stay healthy.
wilyanse
1,926,138
React is not hard - React from 0 to expert
Hi! 👋 I'm Juan, I have more than 6 years of experience working with React, and I think it's not that...
0
2024-07-17T02:49:03
https://dev.to/juanemilio31323/react-is-not-hard-react-from-0-to-expert-2ge
frontend, react, backend, webdev
Hi! 👋 I'm Juan, I have more than 6 years of experience working with React, and I think it's not that hard. For that reason, I've decided to create a series that will teach you React from 0, and if you already know React, it will help you go to the next level. We'll talk about really basic things in depth and really advanced topics. My objective at the end of this series is to give you enough context and knowledge so you can create your own React project, like a library. ## What are we going to learn in this series? 1. How to build a React library the easy way 2. Interesting React helpers and React methods 3. Strange exports that can make your code more reusable 4. File systems to organize your project 5. Obviously, how to build a React project 6. Much more... ## What level do you need to start? Do you know how to write code in any language? Pay attention to my words: "Know how to write code." I didn't say: "How to write good code." If the answer is yes, you are good to go. You'll start to get it sooner or later. And if you do not, leave a message with any doubt you have. With all of this said, we can finally start. ## What's JS and why is it amazing? JS is one of the greatest pieces of art ever created. It is a single-threaded, cross-platform, easy-to-use, and understandable programming language. It was primarily designed to run code on the web, inspired by its bigger brother C#, sharing many syntactical aspects (they have similar writing). It's really helpful for projects that are just starting because, thanks to the use of an engine that implements an interpreter and a compiler, JS can run almost anywhere: your phone, your computer, your smartwatch, and your browser. ## Playing with the browser I've mentioned that JS was originally intended to run on the web and indeed, it is one of the fundamental pieces of the modern web that we all enjoy these days. Let me show an example of JS running in the browser: ```typescript // Function to get the window size and set it into the <p> tag function updateWindowSize() { const width = window.innerWidth; const height = window.innerHeight; const sizeText = `Width: ${width}px, Height: ${height}px`; // Get the <p> tag by its id const windowSizeElement = document.getElementById('window-size'); // Set the window size text into the <p> tag windowSizeElement.textContent = sizeText; } // Update window size on load window.addEventListener('load', updateWindowSize); // Update window size on resize window.addEventListener('resize', updateWindowSize); ``` Here we can see a function that gets the size of the window and sets it into a `<p>` tag. This is something that until recent times was only possible with JS. This is because this was the only code that was able to run on the client side. Besides accessing the browser properties like the Window Object, JS also can modify the DOM and add elements. That enables the possibility of dynamically rendering different parts of the application. Let me show you: ```typescript // Function to render a form with fields: name, last name, and password function renderForm() { // Create form element const form = document.createElement('form'); // Create name field const nameLabel = document.createElement('label'); nameLabel.textContent = 'Name: '; const nameInput = document.createElement('input'); nameInput.type = 'text'; nameInput.name = 'name'; nameInput.id = 'name'; nameLabel.appendChild(nameInput); form.appendChild(nameLabel); form.appendChild(document.createElement('br')); // Line break for better layout // Create last name field const lastNameLabel = document.createElement('label'); lastNameLabel.textContent = 'Last Name: '; const lastNameInput = document.createElement('input'); lastNameInput.type = 'text'; lastNameInput.name = 'last_name'; lastNameInput.id = 'last_name'; lastNameLabel.appendChild(lastNameInput); form.appendChild(lastNameLabel); form.appendChild(document.createElement('br')); // Line break for better layout // Create password field const passwordLabel = document.createElement('label'); passwordLabel.textContent = 'Password: '; const passwordInput = document.createElement('input'); passwordInput.type = 'password'; passwordInput.name = 'password'; passwordInput.id = 'password'; passwordLabel.appendChild(passwordInput); form.appendChild(passwordLabel); form.appendChild(document.createElement('br')); // Line break for better layout // Create submit button const submitButton = document.createElement('button'); submitButton.type = 'submit'; submitButton.textContent = 'Submit'; form.appendChild(submitButton); // Append the form to the container const formContainer = document.getElementById('form-container'); formContainer.appendChild(form); } // Call the function to render the form renderForm(); ``` This is a function that is able to render a form on the screen, but probably you are thinking: _"Man!!! This is huge"_ yep, it is. In fact, this function has 47 lines of code that are not easy to read. ## How's that happening? If you are something like me, probably you are asking yourself: _"How can JS change the DOM?"_ or even _"What's the DOM?"_ Let's be honest, nobody is asking these questions, but stay with me. Those are great questions, let me show you: ![Dom draw](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1egjednmnlm9lhedc927.png) This tree-like structure is the skeleton of our page, and JS is naturally prepared to interact with it. ## It's not that good We’ve been seeing how amazing JS is and all the power that it has, but there's a caveat. It's not that good. As we already have seen, the syntax to do modifications on the DOM is kind of hard to read, easy to break, and difficult to scale into bigger ventures. Not to mention the **HORRIBLE** performance that comes with directly manipulating the DOM. Each time you make a modification to the DOM, it triggers a re-rendering on the screen, which also produces recalculation of the sizes of the elements, checking on the style sheets all over again, and it’s really hard to tell the possible side effects of some modifications. For that reason, directly manipulating the DOM at a bigger scale can be really complex. If you want to know more about it, here is an excellent resource: [Performance considerations when manipulating the DOM](https://borstch.com/blog/development/performance-considerations-when-manipulating-the-dom). ## What's React and why is it amazing? React is a library—mark my words: _"A library"_, not a framework nor magic, **Library**. Great, now that we’ve made that clear, we can continue. React was created as a solution for the problems previously mentioned, trying to implement a solution that is easy to use, understand, and grow in order to create more sustainable and complex applications on the client side. But what does that mean? It means that React is easy, scalable (I might disagree with this one), and performant (Yes and no, we’ll understand it later). Let's see React in action: ```typescript import React from 'react'; const FormComponent = () => { const handleSubmit = (e) => { e.preventDefault(); console.log('Form submitted:', formData); }; return React.createElement( 'form', { onSubmit: handleSubmit }, React.createElement( 'label', null, 'Name:', React.createElement('input', { type: 'text', name: 'name' }) ), React.createElement('br', null), React.createElement( 'label', null, 'Last Name:', React.createElement('input', { type: 'text', name: 'lastName', }) ), React.createElement('br', null), React.createElement( 'label', null, 'Password:', React.createElement('input', { type: 'password', name: 'password', }) ), React.createElement('br', null), React.createElement( 'button', { type: 'submit' }, 'Submit' ) ); }; export default FormComponent; ``` This ugly piece of art is React creating the same form that we were seeing just before in plain JS. And I know, I know, many of you out there may be saying that this is not React and that React should look something more like this: ```tsx import React from 'react'; const FormComponent = () => { const handleSubmit = (e) => { e.preventDefault(); // Handle form submission console.log('Form submitted:', formData); }; return ( <form onSubmit={handleSubmit}> <label> Name: <input type="text" name="name" onChange={handleChange} /> </label> <br /> <label> Last Name: <input type="text" name="lastName" onChange={handleChange} /> </label> <br /> <label> Password: <input type="password" name="password" onChange={handleChange} /> </label> <br /> <button type="submit">Submit</button> </form> ); }; export default FormComponent; ``` And you are almost right, with the little caveat that this is not React, it is React DOM (something independent from React), React and a compiler working together. Let's try to understand. ## What's going on? I know, the previous point was a little confusing, but it’s just about to make sense. Before, we need to understand how React is working behind the scenes. ### React ```tsx React.createElement('button', { type: 'submit' }, 'Submit') ``` This, my friends, is plain React. Most of the code that you will see when writing React will transform into this. And a really good question to ask now would be: "What does this code do?" And the answer is: It mutates the VDOM (Virtual DOM). ### What's the VDOM? We mentioned before that mutating the DOM was expensive and extremely slow, and that React is the solution to this problem (one of many solutions). This is because the React method "createElement" doesn't directly manipulate the DOM; it manipulates the VDOM. The VDOM is a tree-like data structure and conceptual representation of the real DOM that keeps track of our React components, like, for example, the button that we just created. It also keeps track of metadata that helps React to more efficiently mutate the UI. The process that React follows is: each time something changes in the UI, for example, when we mount or unmount (mount refers to inserting the component into the VDOM) our button component, it’s compared to the last VDOM render with the current version, and updates the parts affected by our actions, in this case the div element and the button. It would look something like this: ![VDOM Draw](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2mgqf7wxttyyv2vnkln5.png) This part that I just explained here is called _reconciliation_. If you want to know more, go and check [React documentation](https://react.dev/learn/preserving-and-resetting-state). ## What's React DOM? React DOM is a library that is mostly used with React to render elements on the screen, giving us the tools and methods required to render our components (our React code). A method that we normally use is: ```tsx ReactDOM.createRoot(document.getElementById("root")!).render(); ``` This method creates the so-called "mounting point," which is the basic element that will contain our entire application. In this case, and most often, our mounting point is a div with the id: "root". ## What's a compiler? Before some people jump to my neck, let me do a little clarification here. Explaining what a compiler is can be really complex, and in this case, it doesn't make sense. Not to mention that the definition of a compiler and a transpiler is blurry. So for the purpose of keeping this post more understandable, I'll keep it simple and won't dive into the details. Most often, you will see React and React DOM used in this way: ```tsx const Component = () => ( <div> //our code </div> ) ``` This, my friend, is JSX. And we are able to write this understandable and beautiful code because of a compiler. A compiler is a program that translates code into some other code. It can be low-level code or just any other code. It doesn't even need to change the programming language, like in this case. We are transforming React JSX, which is just JavaScript with a special syntax, into normal JavaScript, giving us the possibility to combine a markup language like XML with JavaScript, hence the name: JSX (JavaScript XML). There are many compilers that can transform JSX into JS, but the one that you probably are going to hear of is Babel. ## What's the state and why should you care? We mentioned before that React keeps track of the modifications that we do on the VDOM, but something that I didn't mention was that modifying the VDOM doesn't only mean that we are going to mount or unmount parts and React is going to notice that. React also keeps track of the mutations that happen to the **state**. The state is a data structure where you can store almost anything (there are some limitations, but we are going to check them in the next chapter). React keeps track of this "store," and each time you modify it, it's going to notice and will _reconcile_ (if you don't understand this term, go back to _"What's the VDOM"_). ### How do we manipulate the state? To manipulate the state, we will use the React Hook **useState** (Hooks are just pieces of code that execute some logic that uses React, like a function-helper but with React code). Let's see: ```tsx import {useState} from 'react' const Button = () => { const [amount, setAmount] = useState(0) const increaseAmount = () => { setAmount(amount+1) } return <button onClick={increaseAmount}>This is our amount {amount}</button> } ``` Here we are using the state to store a number that each time we click on our button will increase the amount. ## The final piece for reconciliation So far, we have seen that reconciliation happens when we alter the VDOM structure by mounting or unmounting, when we alter the state, and finally when we change the props of a component. ### What's a prop? React was created with code-splitting in mind, so in order to make our components more flexible, we can use props. Props are just values that we pass down from one component to another. Something just like this: ```jsx const Button = ({text, onClick}) => { return <button onClick={onClick}>{text}</button> } export default Button ``` ```jsx import { useState } from 'react' import Button from './Button' const Landing = () => { const [counter, setCounter] = useState(0) return ( <div> <Button text="I'm a button" onClick={() => setCounter(counter+1)}/> </div> ) } ``` As you can see, we are moving the state up. This is known as lifting up the state, and also we customized our button. ### Default props: There are some props that come by default in React, they are really helpful ### The key ```jsx const ImageGrid = ({images}) => { return images.map((src) => <img key={src} src={src} />) } ``` The key is normally used when you are doing a map to dynamically transform data into a bunch of elements, like in this case, where I'm rendering images by mapping over a list of them and I want to help React keep track of them, in case these images change. The key is always a unique identifier. ### Children This is used to pass a component inside another one. For example: ```jsx const Button = ({children, onClick}) => { return <button onClick={onClick}>{children}</button> } export default Button ``` ```jsx const Icon = () => { return <svg /> } export default Icon ``` ```jsx import Button from './Button' const Landing = () => { return ( <div> <Button> <Icon/> </Button> </div> ) } ``` If you change any prop, expect React to know it. The only exception to this is when you are passing a value by reference, but we’ll talk about it in the next chapter of the series. Follow me to don't loose it. ## Before moving on... If you are really enjoying this post and consider that my effort is worth promoting, take one minute to give me a hand [buying me a coffee](https://buymeacoffee.com/juanemilio). You have no idea how helpful and motivating this is. ## Why so much drama? The name of this library is really descriptive, and you are just about to understand why. We now know that React code creates a visual representation of our UI, compares it between the different updates that we can do, and updates it as efficiently as it possibly can. But let's be honest, isn't this a little bit overkill to just write some weird HTML? Yes, it is, but we are not just writing weird HTML; we are overcharging it with React, giving us a powerful interface to dynamically render elements on the screen and connecting them with our JS code, all in the same place. ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Button and Message</title> </head> <body> <button id="show-message-button">Show/Hide Message</button> <div id="message-container"></div> <script src="script.js"></script> </body> </html> ``` ```js // Function to toggle the <p> tag with a message function toggleMessage() { const messageContainer = document.getElementById('message-container'); const message = document.getElementById('message'); if (message) { // If the message exists, remove it messageContainer.removeChild(message); } else { // If the message does not exist, create and mount it const p = document.createElement('p'); p.id = 'message'; p.textContent = 'Hello, this is your message!'; messageContainer.appendChild(p); } } // Add event listener to the button const button = document.getElementById('show-message-button'); button.addEventListener('click', toggleMessage); ``` This is all the code that we need to render a button on the screen that will work like a switch: when it's on, it will render a message on the screen; when it's off, it will hide it. It's not that complex, but let's see how this can be done with React. ```tsx import { useState } from 'react' const MessageSwitch = () => { const [show, setShow] = useState(false) return ( <> <button onClick={() => setShow(!show)}> {show ? 'Hide' : 'Show'} Message </button> { show ? <p>Hello, this is your message!</p> : '' } </> ) } export default MessageSwitch ``` Yep, this is all the code that you need. That's why React is amazing. At this point, you should now understand what React is, what the state is, what the VDOM is, and what reconciliation is. You now have all the basics, so you are ready to start working with React. ## How to start a project? Probably you are asking yourself: "Now I have to install React DOM, React, and Babel to start the project?" Nope, there are scaffolding projects and frameworks that implement all these technologies for you. ## Vite If you are asking what Vite is, let's give them the opportunity to tell you: > Vite (French word for "quick", pronounced `/vit/`, like "veet") is a build tool that aims to provide a faster and leaner development experience for modern web projects This build tool is incredibly fast and super easy to use. It will configure a React project with the options that you choose, avoiding the need to configure a compiler, a bundler, hot reloading, and many other things. To use Vite, run the command: ```bash npm create vite@latest ``` Insert your project name, select your framework (React), and select either JavaScript + SWC or Typescript + SWC, go into the folder, and do npm i. You should have something like this (I chose Typescript + SWC): ![Vite basic project structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrbo09zoz6mpx6mjywcd.png) Congratulations, now let's dive into the project: ## index.html ![Index HTML React Project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3x0hdt5jv90ena2myc02.png) We can see our mounting point and the React implementation. That's all the HTML that the client is going to render when they first enter the application. Later, the script tag will run and the page will be populated with our React code. ## src/main.tsx ![Main tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oh8hmu7d9s6y2uw0x5y5.png) ## src/App.tsx ![App tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psapwivi6jqn8p45jbm9.png) This is the default code that comes pre-implemented with Vite. Let's see it. To run the React application in development mode, we have to run: ```bash npm run dev ``` That will start the project on port 5173 and it will display this: ![Vite run dev](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pvew39w7xbypx1063c3d.png) ## Project Structure I remember when I was a beginner, I hated that no one told me how to structure my files, and to be honest, it took me a while to figure out a way to do it properly. There are many ways to do it, and how you do it will depend on the kind of project that you are building, but I'll give you one that is good enough for most cases. ![Project structure src](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv1d17py1mqgv4gm8k9l.png) You'll add two new folders: pages and components. In components, you are going to store the code that you are going to reuse all across the application. Something like this: ![Project structure components](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84yocz7aj6ih256dp1sv.png) Probably you'll want to reuse your input and button across your application. You probably noticed that I created the component: Input, and the Logic. That's because ideally, we don't want our JSX and our Logic together. Let me show you how to do this: ```tsx import { ChangeEvent, useState } from "react"; const regex = /[!@#$%^&*(),.?":{}|<>]/; const Logic = () => { const [value, setValue] = useState(""); const handleChange = (e: ChangeEvent<HTMLInputElement>) => { const value = e.currentTarget.value; if (regex.test(value)) { return; } setValue(value); }; return { value, handleChange }; }; export default Logic; ``` In the Logic component of the button, we use all the things that are not directly part of the JSX. In this case, we have a function that handles the change in the input value and changes the state. We are also validating for special characters, not setting the values if it is the case. ```tsx import Logic from "./Logic"; const Input = () => { const { handleChange, value } = Logic(); return <input value={value} onChange={handleChange}></input>; }; export default Input; ``` And here we have our Input component with the special Logic that we wanted to implement. This is a pattern that we are going to repeat all over our application. And yes, this Logic component is some kind of custom-hook (Go back to _"How we manipulate the state"_) Finally, in the pages folder, we will have a recursive structure (recursive means that it repeats) with folders that will describe features of the application, having on them multiple components that refer to that page specifically. Let's see: ![Pages folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi8bmc5ezyqazjgdjf8q.png) ## Coming to an end If you have reached this point, it means that you now have the basics to start working with React. Go and keep practicing, creating something of your own and applying these concepts. In the next couple of days, I'm going to bring you chapter two, where I'll talk about more complex topics and advanced techniques. ## You have doubts - Get in touch with me? If you have any doubts or you need help pushing your project or knowledge one step forward, contact me. I'm starting a new project where you can talk with me for an hour, and I'll try to help you to make the progress you are looking for: [Get in touch](https://buymeacoffee.com/juanemilio/e/277947) ## The end If you really enjoyed this post, please share it, follow, and like it. Thanks for reading and I hope I'll see you again. <a href="https://www.buymeacoffee.com/juanemilio" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a> ## Credit If you like the picture of the post consider checking the work of [Lautaro](https://unsplash.com/@lautaroandreani) his the owner.
juanemilio31323
1,926,139
Best Digital Marketing Institute In Sikandrabad: Just Digital Duniya
Discover the Best Digital Marketing Institute in Sikandrabad for comprehensive training and industry...
0
2024-07-17T02:49:21
https://dev.to/rihankhan02/best-digital-marketing-institute-in-sikandrabad-just-digital-duniya-hii
webdev, javascript
Discover the Best Digital Marketing Institute in Sikandrabad for comprehensive training and industry insights. Our expert instructors provide hands-on experience in SEO, SEM, social media, and analytics, equipping you with essential skills for today's digital landscape. Join our supportive community and gain practical knowledge through real-world projects. Whether you're a beginner or aiming to advance your career, our tailored courses ensure you excel in digital marketing. Enroll now and embark on your journey to success with the best in Sikandrabad https://www.justdigitalduniya.com/best-digital-marketing-institute-in-sikandrabad #bestdigitalmarketingcompany #sikandrabadinstitute #digitalsikandrabad #digitalmarketingsikandrabad
rihankhan02
1,926,140
gambling
Hi, recommend a site for the game ?
0
2024-07-17T02:50:54
https://dev.to/rixy/gambling-9n1
Hi, recommend a site for the game ?
rixy
1,926,141
Buy verified BYBIT account
https://dmhelpshop.com/product/buy-verified-bybit-account/ Buy verified BYBIT account In the...
0
2024-07-17T02:54:56
https://dev.to/nadah10995/buy-verified-bybit-account-1e5l
webdev, javascript, beginners, programming
https://dmhelpshop.com/product/buy-verified-bybit-account/ ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgc6s8z61xo7ayv0gj4s.png) Buy verified BYBIT account In the evolving landscape of cryptocurrency trading, the role of a dependable and protected platform cannot be overstated. Bybit, an esteemed crypto derivatives exchange, stands out as a platform that empowers traders to capitalize on their expertise and effectively maneuver the market. This article sheds light on the concept of Buy Verified Bybit Accounts, emphasizing the importance of account verification, the benefits it offers, and its role in ensuring a secure and seamless trading experience for all individuals involved. What is a Verified Bybit Account? Ensuring the security of your trading experience entails furnishing personal identification documents and participating in a video verification call to validate your identity. This thorough process is designed to not only establish trust but also to provide a secure trading environment that safeguards against potential threats. By rigorously verifying identities, we prioritize the protection and integrity of every individual’s trading interactions, cultivating a space where confidence and security are paramount. Buy verified BYBIT account Verification on Bybit lies at the core of ensuring security and trust within the platform, going beyond mere regulatory requirements. By implementing robust verification processes, Bybit effectively minimizes risks linked to fraudulent activities and enhances identity protection, thus establishing a solid foundation for a safe trading environment. Verified accounts not only represent a commitment to compliance but also unlock higher withdrawal limits, empowering traders to effectively manage their assets while upholding stringent safety standards. Advantages of a Verified Bybit Account Discover the multitude of advantages a verified Bybit account offers beyond just security. Verified users relish in heightened withdrawal limits, presenting them with the flexibility necessary to effectively manage their crypto assets. This is especially advantageous for traders aiming to conduct substantial transactions with confidence, ensuring a stress-free and efficient trading experience. Procuring Verified Bybit Accounts The concept of acquiring buy Verified Bybit Accounts is increasingly favored by traders looking to enhance their competitive advantage in the market. Well-established sources and platforms now offer authentic verified accounts, enabling users to enjoy a superior trading experience. Buy verified BYBIT account. Just as one exercises diligence in their trading activities, it is vital to carefully choose a reliable source for obtaining a verified account to guarantee a smooth and reliable transition. Conclusionhow to get around bybit kyc Understanding the importance of Bybit’s KYC (Know Your Customer) process is crucial for all users. Bybit’s implementation of KYC is not just to comply with legal regulations but also to safeguard its platform against fraud. Although the process might appear burdensome, it plays a pivotal role in ensuring the security and protection of your account and funds. Embracing KYC is a proactive step towards maintaining a safe and secure trading environment for everyone involved. Ensuring the security of your account is crucial, even if the KYC process may seem burdensome. By verifying your identity through KYC and submitting necessary documentation, you are fortifying the protection of your personal information and assets against potential unauthorized breaches and fraudulent undertakings. Buy verified BYBIT account. Safeguarding your account with these added security measures not only safeguards your own interests but also contributes to maintaining the overall integrity of the online ecosystem. Embrace KYC as a proactive step towards ensuring a safe and secure online experience for yourself and everyone around you. How many Bybit users are there? With over 2 million registered users, Bybit stands out as a prominent player in the cryptocurrency realm, showcasing its increasing influence and capacity to appeal to a wide spectrum of traders. The rapid expansion of its user base highlights Bybit’s proactive approach to integrating innovative functionalities and prioritizing customer experience. This exponential growth mirrors the intensifying interest in digital assets, positioning Bybit as a leading platform in the evolving landscape of cryptocurrency trading. With over 2 million registered users leveraging its platform for cryptocurrency trading, Buy Verified ByBiT Accounts has witnessed remarkable growth in its user base. Bybit’s commitment to security, provision of advanced trading tools, and top-tier customer support services have solidified its position as a prominent competitor within the cryptocurrency exchange market. For those seeking a dependable and feature-rich platform to engage in digital asset trading, Bybit emerges as an excellent choice for both novice and experienced traders alike. Enhancing Trading Across Borders Leverage the power of buy verified Bybit accounts to unlock global trading prospects. Whether you reside in bustling financial districts or the most distant corners of the globe, a verified account provides you with the gateway to engage in safe and seamless cross-border transactions. The credibility that comes with a verified account strengthens your trading activities, ensuring a secure and reliable trading environment for all your endeavors. A Badge of Trust and Opportunity By verifying your BYBIT account, you are making a prudent choice that underlines your dedication to safe trading practices while gaining access to an array of enhanced features and advantages on the platform. Buy verified BYBIT account. With upgraded security measures in place, elevated withdrawal thresholds, and privileged access to exclusive opportunities, a verified BYBIT account equips you with the confidence to maneuver through the cryptocurrency trading realm effectively. Why is Verification Important on Bybit? Ensuring verification on Bybit is essential in creating a secure and trusted trading space for all users. It effectively reduces the potential threats linked to fraudulent behaviors, offers a shield for personal identities, and enables verified individuals to enjoy increased withdrawal limits, enhancing their ability to efficiently manage assets. By undergoing the verification process, users safeguard their investments and contribute to a safer and more regulated ecosystem, promoting a more secure and reliable trading environment overall. Buy verified BYBIT account. Conclusion In the ever-evolving landscape of digital cryptocurrency trading, having a Verified Bybit Account is paramount in establishing trust and security. By offering elevated withdrawal limits, fortified security measures, and the assurance that comes with verification, traders are equipped with a robust foundation to navigate the complexities of the trading sphere with peace of mind. Discover the power of ByBiT Accounts, the ultimate financial management solution offering a centralized platform to monitor your finances seamlessly. With a user-friendly interface, effortlessly monitor your income, expenses, and savings, empowering you to make well-informed financial decisions. Buy verified BYBIT account. Whether you are aiming for a significant investment or securing your retirement fund, ByBiT Accounts is equipped with all the tools necessary to keep you organized and on the right financial path. Join today and take control of your financial future with ease. Contact Us / 24 Hours Reply Telegram:dmhelpshop WhatsApp: +1 ‪(980) 277-2786 Skype:dmhelpshop Email:dmhelpshop@gmail.com
nadah10995
1,926,142
🔒 Essential Node.js Security Best Practices
Securing your Node.js applications is crucial to protecting your data and ensuring the integrity of...
0
2024-07-17T02:58:26
https://dev.to/dipakahirav/essential-nodejs-security-best-practices-2mh8
node, npm, webdev, javascript
Securing your Node.js applications is crucial to protecting your data and ensuring the integrity of your services. Here are some essential best practices to help you enhance the security of your Node.js applications. please subscribe to my [YouTube channel](https://www.youtube.com/@DevDivewithDipak?sub_confirmation=1 ) to support my channel and get more web development tutorials. --- ## 1. Keep Dependencies Updated 📦 Regularly update your dependencies to fix known vulnerabilities. Use tools like `npm audit` to check for security issues in your packages. ```bash npm audit fix ``` --- ## 2. Use Environment Variables for Configuration 🔧 Store sensitive information like API keys and database credentials in environment variables instead of hardcoding them in your application. ```javascript require('dotenv').config(); const apiKey = process.env.API_KEY; ``` --- ## 3. Validate and Sanitize User Input 🧼 Always validate and sanitize user inputs to prevent injection attacks like SQL injection, NoSQL injection, and XSS. ```javascript const express = require('express'); const { body, validationResult } = require('express-validator'); const app = express(); app.post('/submit', [ body('email').isEmail().normalizeEmail(), body('password').isLength({ min: 6 }).trim().escape() ], (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(400).json({ errors: errors.array() }); } // Process the input }); ``` --- ## 4. Use HTTPS for Secure Communication 🌐 Always use HTTPS to encrypt data transmitted between the client and the server. Tools like Let's Encrypt can help you obtain SSL/TLS certificates for free. ```javascript const https = require('https'); const fs = require('fs'); const app = require('./app'); const options = { key: fs.readFileSync('key.pem'), cert: fs.readFileSync('cert.pem') }; https.createServer(options, app).listen(443, () => { console.log('Server running on port 443'); }); ``` --- ## 5. Implement Rate Limiting 🚦 Prevent brute-force attacks by limiting the number of requests a client can make in a given period. Use middleware like `express-rate-limit`. ```javascript const rateLimit = require('express-rate-limit'); const limiter = rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 100 // limit each IP to 100 requests per windowMs }); app.use(limiter); ``` --- ## 6. Protect Against CSRF Attacks 🛡️ Use CSRF tokens to protect against Cross-Site Request Forgery (CSRF) attacks. Libraries like `csurf` can help. ```javascript const csurf = require('csurf'); const csrfProtection = csurf({ cookie: true }); app.use(csrfProtection); app.get('/form', (req, res) => { res.render('send', { csrfToken: req.csrfToken() }); }); ``` --- ## 7. Secure Your HTTP Headers 🛠️ Use the `helmet` middleware to set secure HTTP headers and protect your app from well-known web vulnerabilities. ```javascript const helmet = require('helmet'); app.use(helmet()); ``` --- ## 8. Use a Reverse Proxy 📡 Use a reverse proxy like Nginx to handle SSL termination, load balancing, and to hide the structure of your backend services. ```nginx server { listen 443 ssl; server_name example.com; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` --- ## 9. Avoid Using Deprecated or Unsafe APIs 🚫 Avoid using deprecated or insecure Node.js APIs. Regularly review the Node.js security advisories and update your code accordingly. --- ## 10. Monitor and Log Activity 📊 Implement logging and monitoring to detect suspicious activities. Tools like Winston for logging and services like New Relic for monitoring can help you keep an eye on your application's health and security. ```javascript const winston = require('winston'); const logger = winston.createLogger({ level: 'info', format: winston.format.json(), transports: [ new winston.transports.File({ filename: 'error.log', level: 'error' }), new winston.transports.File({ filename: 'combined.log' }) ] }); ``` --- By following these best practices, you can significantly improve the security of your Node.js applications. Remember, security is an ongoing process, so stay vigilant and keep your applications up to date with the latest security measures. Happy coding! 🔐 --- Feel free to leave your comments or questions below. If you found this guide helpful, please share it with your peers and follow me for more web development tutorials. Happy coding! ### Follow and Subscribe: - **Website**: [Dipak Ahirav] (https://www.dipakahirav.com) - **Email**: dipaksahirav@gmail.com - **YouTube**: [devDive with Dipak](https://www.youtube.com/@DevDivewithDipak?sub_confirmation=1 ) - **LinkedIn**: [Dipak Ahirav](https://www.linkedin.com/in/dipak-ahirav-606bba128)
dipakahirav
1,926,873
Wearable technology
Introduction to Wearable Technology Wearable technology has revolutionized the way we interact with...
0
2024-07-17T15:17:14
https://dev.to/techabi/wearable-technology-4523
**Introduction to Wearable Technology** [Wearable technology](https://techabi.online/wearable-technology-healthcare-smartwatch-fitness/) has revolutionized the way we interact with our world. From fitness trackers to smartwatches, these innovative devices offer convenience, connectivity, and valuable health insights right on our wrists. **The Rise of Wearable Technology** Fitness and Health Monitoring Wearable tech has made a significant impact in the health and fitness industry. Devices like Fitbit and Apple Watch track steps, monitor heart rates, and even analyze sleep patterns, helping users maintain a healthier lifestyle. **Smartwatches and Connectivity** Smartwatches have evolved beyond mere timekeeping. They now provide notifications, allow for phone calls, and even support apps that enhance productivity and entertainment. **Medical Applications** Beyond fitness, wearable technology plays a critical role in healthcare. Devices such as glucose monitors and ECG sensors provide real-time data, enabling better disease management and proactive health monitoring. **Benefits of Wearable Technology** Convenience: Always-on devices that keep you connected and informed. Health Insights: Real-time health data for better lifestyle choices. Enhanced Safety: Features like fall detection and emergency SOS improve personal safety. **The Future of Wearable Technology** The future of wearable technology looks promising with advancements in AI and machine learning. These devices are becoming more intuitive, providing personalized insights and predictive health analytics. Integration with IoT (Internet of Things) will further enhance their capabilities, making them an indispensable part of our daily lives. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8vava3t3ycbh0tdn30q.jpg) **Conclusion** [Wearable technology](https://techabi.online/wearable-technology-healthcare-smartwatch-fitness/) is not just a trend; it is a transformative tool that enhances our daily lives, promotes better health, and keeps us connected. As technology continues to evolve, wearables will undoubtedly become even more integral to our personal and professional lives.
techabi
1,926,143
Best Social Seeding Service – comment-marketing.com
Today, social seeding on platforms is a highly effective way to promote products. With huge user...
0
2024-07-17T02:58:27
https://dev.to/jagger_chi/best-social-seeding-service-comment-marketingcom-35pm
socialmedia, socialseeding, marketing, commentmarketing
Today, social seeding on platforms is a highly effective way to promote products. With huge user bases and traffic, you can gain significant benefits and quickly increase brand awareness. Comment marketing, known for its low cost, no ad fees, precise targeting, high conversion rates, and SEO optimization, stands out among these methods. Comment-marketing.com excels with its automation, low cost, multi-platform support, and friendly comments. Let's see what it offers. Automated Management Comment-marketing.com’s automation is a major highlight. Users only need to provide their website and email, and the platform will find relevant posts and publish comments. This saves significant time and effort, allowing marketers to focus on more important tasks. The intelligent algorithm ensures comments are posted at the optimal time and place for maximum impact. Precise Targeting The platform accurately targets audiences, ensuring each comment is placed in relevant discussions to increase exposure and conversion rates. This precision ensures that marketing messages reach the most suitable user groups. By leveraging deep analysis and big data technology, comment-marketing.com identifies the most relevant discussion areas and topics, bringing users higher interaction rates and potential customer conversions. Multi-Platform Support Comment-marketing.com supports multiple social media platforms, including Reddit, Quora, and Hacker News. This multi-platform support allows marketers to promote across various channels, further expanding brand influence and awareness. Regardless of which platform your target audience is on, comment-marketing.com helps you reach them effectively, enhancing promotion outcomes. Friendly Comments The platform’s comments are carefully designed and written to attract the target audience's attention and encourage interaction and discussion. Friendly comment styles not only help improve brand image but also enhance user trust and recognition. Comment-marketing.com ensures each comment complies with platform regulations, has a friendly tone, and provides valuable content, naturally integrating into the discussion. commentcomment2 Through these aspects, comment-marketing.com helps marketers achieve more efficient promotion on social platforms with its unique advantages. If you are looking for a low-cost, high-return promotion tool, try comment-marketing.com. It not only saves time and effort but also makes your marketing activities more precise and effective, helping you stand out in a competitive market.
jagger_chi
1,926,144
#27 — Group and Summarize A Table Where Every N Rows Consists of A Range by Column
Problem description &amp; analysis: Below is an Excel table. Every two rows form a range; and in...
0
2024-07-17T03:00:41
https://dev.to/judith677/27-group-and-summarize-a-table-where-every-n-rows-consists-of-a-range-by-column-3863
beginners, programming, tutorial, productivity
**Problem description & analysis**: Below is an Excel table. Every two rows form a range; and in each range, each pair of cells up and down is regarded as a piece of data that stores client and working hours that can be empty. ![original tabel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjqltpg5y9ny8j35zf8p.png) We need to find the hours of work for each client. ![desired table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2dub1mv91y3xa2qvopu.png) **Solution**: Use _**SPL XLL**_ to do this: ``` =spl("=E@b(?.group((#-1)\2).conj(E@pb(~)).groups(#1;sum(#2)))",A1:G4) ``` As shown in the picture below: ![result table with code entered](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7z2vt0ekfs2rtkz3dmj.png) **Explanation**: group()function groups rows and retains the grouping result details. groups() function performs grouping and aggregation; # represents the current sequence number in a sequence, and ~ is the current member of a sequence. E@pb converts a sequence to a table sequence without column headers.
judith677
1,926,145
Buy GitHub Accounts
https://reviewsiteusa.com/product/buy-github-accounts/ Buy GitHub Accounts GitHub, a renowned...
0
2024-07-17T03:03:36
https://dev.to/nadah10995/buy-github-accounts-4n7l
tutorial, react, python, ai
ERROR: type should be string, got "https://reviewsiteusa.com/product/buy-github-accounts/\n![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlig9tpamc9pju4rnm6s.png)\n\n\n\nBuy GitHub Accounts\nGitHub, a renowned platform for hosting and collaborating on code, is essential for developers at all levels. With millions of projects worldwide, having a GitHub account is a valuable asset for seasoned programmers and beginners alike. However, the process of creating and managing an account can be complex and time-consuming for some.\n\nThis is where purchasing GitHub accounts becomes advantageous. By buying a GitHub account, individuals can streamline their development journey and access the numerous benefits of the platform efficiently. Whether you are looking to enhance your coding skills or expand your project collaborations, a purchased GitHub account can be a practical solution for optimizing your coding experience.\n\nWhat is GitHub Accounts\nGitHub accounts serve as user profiles on the renowned code hosting platform GitHub, where developers collaborate, track code changes, and manage version control seamlessly. Creating a GitHub account provides users with a platform to exhibit their projects, contribute to diverse endeavors, and engage with the GitHub community. Buy verified BYBIT account\n\nYour GitHub account stands as your virtual identity on the platform, capturing all your interactions, contributions, and project involvement. Embrace the power of GitHub accounts to foster connections, showcase your skills, and enhance your presence in the dynamic world of software development. Buy GitHub Accounts.\n\nCan You Buy GitHub Accounts?\n Rest assured when considering our buy GitHub Accounts service, as we distinguish ourselves from other PVA Account providers by offering 100% Non-Drop PVA Accounts, Permanent PVA Accounts, and Legitimate PVA Accounts. Our dedicated team ensures instant commencement of work upon order placement, guaranteeing a seamless experience for you. Embrace our service without hesitation and revel in its benefits.\n\nGitHub stands as the largest global code repository, playing a pivotal role in the coding world, especially for developers. It serves as the primary hub for exchanging code and engaging in collaborative projects.\n\nHowever, if you find yourself without a GitHub account, you may be missing out on valuable opportunities to share your code, learn from others, and contribute to open-source projects. A GitHub account not only allows you to showcase your coding skills but also enhances your professional network and exposure within the developer community.\n\nAccess To Premium Features\nUnlock a realm of possibilities and boost your productivity by harnessing the full power of Github’s premium features. Enjoy an array of benefits by investing in Github accounts, consolidating access to premium tools under a single subscription and saving costs compared to individual purchases. Buy GitHub Accounts.\n\nCultivating a thriving Github profile demands dedication and perseverance, involving continuous code contributions, active collaboration with peers, and diligent repository management. Elevate your development journey by embracing these premium features and optimizing your workflow for success on Github.\n\nGitHub private repository limits\nFor those of you who actively develop and utilize GitHub for managing your personal coding projects, consider the storage limitations that may impact your workflow. GitHub’s free accounts, which currently allow for up to three personal repositories, may prove stifling if your coding demands surpass this threshold. In such cases, upgrading to a dedicated buy GitHub account emerges as a viable remedy.\n\nTransitioning to a paid GitHub account not only increases repository limits but also grants a myriad of advantages, including unlimited collaborators access, as well as premium functionalities like GitHub Pages and GitHub Actions. Thus, if your involvement in personal projects confronts space constraints, transitioning to a paid account can seamlessly accommodate your expanding requirements.\n\nGitHub Organization Account\nWhen managing a team of developers, leveraging a GitHub organization account proves invaluable. This account enables the creation of a unified workspace where team members can seamlessly collaborate on code, offering exclusive features beyond personal accounts like the ability to edit someone else’s repository. Buy GitHub Accounts.\n\nEstablishing an organization account is easily achieved by visiting github.com and selecting the “Create an organization” option, wherein you define a name and configure basic settings. Once set up, you can promptly add team members and kickstart collaborative project work efficiently.\n\nTypes Of GitHub Accounts\nInvesting in a GitHub account (PVA) offers access to exclusive services typically reserved for established accounts, such as beta testing programs, early access to features, and participation in special GitHub initiatives, broadening your range of functionality.\n\nBy purchasing a GitHub account, you contribute to a more secure and reliable environment on the GitHub platform. A bought GitHub account (PVA) allows for swift account recovery solutions in case of account-related problems or unexpected events, guaranteeing prompt access restoration to minimize any disruptions to your workflow.\n\nAs a developer utilizing GitHub to handle your code repositories for personal projects, the matter of personal storage limits may be of significance to you. Presently, GitHub’s complimentary accounts are constrained to three personal repositories. Buy GitHub Accounts.\n\nShould your requirements surpass this restriction, transitioning to a dedicated GitHub account stands as the remedy. Apart from elevated repository limits, upgraded GitHub accounts provide numerous advantages, including access to unlimited collaborators and premium functionalities like GitHub Pages and GitHub Actions.\n\nThis ensures that if your undertakings encompass personal projects and you find yourself approaching storage boundaries, you have viable options to effectively manage and expand your development endeavors. Buy GitHub Accounts.\n\nWhy are GitHub accounts important?\nGitHub accounts serve as a crucial tool for anyone seeking to establish a presence in the tech industry. Regardless of your experience level, possessing a GitHub account equates to owning a professional online portfolio that highlights your skills and ventures to potential employers or collaborators.\n\nThrough GitHub, individuals can exhibit their coding proficiency and projects, fostering the display of expertise in multiple programming languages and technologies. This not only aids in establishing credibility as a developer but also enables prospective employers to evaluate your capabilities and suitability for their team effectively. Buy GitHub Accounts.\n\nBy maintaining an active GitHub account, you can effectively demonstrate a profound dedication to your field of expertise. Employers are profoundly impressed by individuals who exhibit a robust GitHub profile, as it signifies a genuine enthusiasm for coding and a willingness to devote significant time and energy to refining their abilities.\n\nThrough consistent project sharing and involvement in open source projects, you have the opportunity to showcase your unwavering commitment to enhancing your capabilities and fostering a constructive influence within the technology community. Buy GitHub Accounts.\n\nConclusion\nFor developers utilizing GitHub to host their code repositories, exploring ways to leverage coding skills for monetization may lead to questions about selling buy GitHub accounts, a practice that is indeed permissible. However, it is crucial to be mindful of pertinent details before proceeding. Buy GitHub Accounts.\n\nNotably, GitHub provides two distinct account types: personal and organizational. Personal accounts offer free access with genuine public storage, in contrast to organizational accounts. Before delving into selling a GitHub account, understanding these distinctions is essential for effective decision-making and navigating the platform’s diverse features.\n\nContact Us / 24 Hours Reply\nTelegram:dmhelpshop\nWhatsApp: +1 ‪(980) 277-2786\nSkype:dmhelpshop\nEmail:dmhelpshop@gmail.com"
nadah10995
1,926,146
Persistent storage on Heroku
Hi All. Heroku seems like a popular PaaS(compared to Google App Engine or AWS Elastic Beanstalk) for...
0
2024-07-17T03:06:38
https://dev.to/vgtom/persistent-storage-on-heroku-2g78
Hi All. Heroku seems like a popular PaaS(compared to Google App Engine or AWS Elastic Beanstalk) for hosting my micro-saas backend. Now What kind of persistent storage can i use that is affordable? I dont want to use a database like Postgres or MongoDB but want something that looks like a filesystem. Between AWS S3 and Filestack which would prove to be a cheaper option for a small enterprise? Infact what is a popular option in the startup community?? Thanks VgTom
vgtom
1,926,148
Discover NBA YoungBoy Merch on Newspicks!
Follow NBA YoungBoy Merch on Newspicks for curated articles and updates. Stay informed about the...
0
2024-07-17T03:14:17
https://dev.to/nbayoungboymerchshop1/discover-nba-youngboy-merch-on-newspicks-5e09
nbayoungboymerch, newspicks
Follow NBA YoungBoy Merch on Newspicks for curated articles and updates. Stay informed about the latest trends, releases, and news in the merch world. Newspicks is your source for well-rounded and in-depth coverage of NBA YoungBoy's merchandise. https://newspicks.com/user/10465349 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yykb3mz4u6k862ttbv69.jpg)
nbayoungboymerchshop1
1,926,150
My Pen on CodePen
Check out this Pen I made!
0
2024-07-17T03:15:36
https://dev.to/udita_pandey_8672f3e9c0f3/my-pen-on-codepen-27ke
codepen
Check out this Pen I made! {% codepen https://codepen.io/Udita-Pandey/pen/ExBVqwV %}
udita_pandey_8672f3e9c0f3
1,926,151
Engage with NBA YoungBoy Merch on Mastodon!
Join the conversation on Mastodon and stay connected with NBA YoungBoy Merch. Follow our updates,...
0
2024-07-17T03:15:56
https://dev.to/nbayoungboymerchshop1/engage-with-nba-youngboy-merch-on-mastodon-2eha
nbayoungboymerch, mastodon
Join the conversation on Mastodon and stay connected with NBA YoungBoy Merch. Follow our updates, share your thoughts, and interact with other fans in a decentralized social network. Mastodon is the perfect platform for open and community-driven discussions. https://mastodon.social/@nbayoungboymerch39 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ccs1sxgpbkzyr1yd8rs.jpg)
nbayoungboymerchshop1
1,926,152
Support NBA YoungBoy Merch on Ko-fi!
Support our NBA YoungBoy Merch by following us on Ko-fi. Get access to exclusive content, special...
0
2024-07-17T03:16:53
https://dev.to/nbayoungboymerchshop1/support-nba-youngboy-merch-on-ko-fi-2ace
nbayoungboymerch, kofi
Support our NBA YoungBoy Merch by following us on Ko-fi. Get access to exclusive content, special deals, and behind-the-scenes updates. Your support helps us bring more exciting merch and experiences to the community. https://ko-fi.com/nbayoungboymerchshop ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnyd17quz69r6pd7fdw2.jpg)
nbayoungboymerchshop1
1,926,153
How to Structure Your Backend Code in Node.js (Express.js)
When developing a Node.js application using Express.js, structuring your codebase effectively is...
0
2024-07-17T03:18:01
https://dev.to/vyan/how-to-structure-your-backend-code-in-nodejs-expressjs-2bdd
webdev, javascript, beginners, programming
When developing a Node.js application using Express.js, structuring your codebase effectively is crucial for maintainability, scalability, and ease of collaboration. A well-organized project structure allows you to manage complexity, making it easier to navigate and understand the code. In this blog, we'll explore a typical folder structure for an Express.js application and explain the purpose of each directory and file. ## Project Structure Overview Here’s a common folder structure for an Express.js application: ``` 📁 ├── 📄 app.js ├── 📁 bin ├── 📁 config ├── 📁 controllers │ ├── 📄 customer.js │ ├── 📄 product.js │ └── ... ├── 📁 middleware │ ├── 📄 auth.js │ ├── 📄 logger.js │ └── ... ├── 📁 models │ ├── 📄 customer.js │ ├── 📄 product.js │ └── ... ├── 📁 routes │ ├── 📄 api.js │ ├── 📄 auth.js │ └── ... ├── 📁 public │ ├── 📁 css │ ├── 📁 js │ ├── 📁 images │ └── ... ├── 📁 views │ ├── 📄 index.ejs │ ├── 📄 product.ejs │ └── ... ├── 📁 tests │ ├── 📁 unit │ ├── 📁 integration │ ├── 📁 e2e │ └── ... ├── 📁 utils │ ├── 📄 validation.js │ ├── 📄 helpers.js │ └── ... └── 📁 node_modules ``` ### Explanation of Each Directory and File #### `app.js` The `app.js` file is the entry point of your application. It’s where you initialize the Express app, set up middleware, define routes, and start the server. Think of it as the control center of your web application. ```javascript const express = require('express'); const app = express(); const config = require('./config'); const routes = require('./routes'); // Middleware setup app.use(express.json()); // Routes setup app.use('/api', routes); // Start server const PORT = config.port || 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); module.exports = app; ``` #### `bin` The `bin` directory typically contains scripts for starting your web server. These scripts can be used to set environment variables or manage different environments (e.g., development, production). **Example: `bin/www`** ```javascript #!/usr/bin/env node const app = require('../app'); const debug = require('debug')('your-app:server'); const http = require('http'); const port = normalizePort(process.env.PORT || '3000'); app.set('port', port); const server = http.createServer(app); server.listen(port); server.on('error', onError); server.on('listening', onListening); function normalizePort(val) { const port = parseInt(val, 10); if (isNaN(port)) return val; if (port >= 0) return port; return false; } function onError(error) { if (error.syscall !== 'listen') throw error; const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; switch (error.code) { case 'EACCES': console.error(bind + ' requires elevated privileges'); process.exit(1); break; case 'EADDRINUSE': console.error(bind + ' is already in use'); process.exit(1); break; default: throw error; } } function onListening() { const addr = server.address(); const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; debug('Listening on ' + bind); } ``` #### `config` The `config` directory holds configuration files for your application, such as database connections, server settings, and environment variables. **Example: `config/index.js`** ```javascript module.exports = { port: process.env.PORT || 3000, db: { host: 'localhost', port: 27017, name: 'mydatabase' } }; ``` #### `controllers` Controllers contain the logic for handling incoming requests and generating responses. Each file in the `controllers` directory typically corresponds to a different part of your application (e.g., customers, products). **Example: `controllers/customer.js`** ```javascript const Customer = require('../models/customer'); exports.getAllCustomers = async (req, res) => { try { const customers = await Customer.find(); res.json(customers); } catch (err) { res.status(500).json({ message: err.message }); } }; ``` #### `middleware` Middleware functions are used to process requests before they reach the controllers. They can handle tasks like authentication, logging, and request validation. **Example: `middleware/auth.js`** ```javascript module.exports = (req, res, next) => { const token = req.header('Authorization'); if (!token) return res.status(401).json({ message: 'Access Denied' }); try { const verified = jwt.verify(token, process.env.JWT_SECRET); req.user = verified; next(); } catch (err) { res.status(400).json({ message: 'Invalid Token' }); } }; ``` #### `models` Models define the structure of your data and handle interactions with the database. Each model file typically corresponds to a different data entity (e.g., Customer, Product). **Example: `models/customer.js`** ```javascript const mongoose = require('mongoose'); const customerSchema = new mongoose.Schema({ name: { type: String, required: true }, email: { type: String, required: true, unique: true }, createdAt: { type: Date, default: Date.now } }); module.exports = mongoose.model('Customer', customerSchema); ``` #### `routes` Routes define the paths to different parts of your application and map them to the appropriate controllers. **Example: `routes/api.js`** ```javascript const express = require('express'); const router = express.Router(); const customerController = require('../controllers/customer'); router.get('/customers', customerController.getAllCustomers); module.exports = router; ``` #### `public` The `public` directory contains static files like CSS, JavaScript, and images that are served directly to the client. **Example: Directory Structure** ``` public/ ├── css/ ├── js/ ├── images/ ``` #### `views` Views are templates that render the HTML for the client. Using a templating engine like EJS, Pug, or Handlebars, you can generate dynamic HTML. **Example: `views/index.ejs`** ```html <!DOCTYPE html> <html> <head> <title>My App</title> <link rel="stylesheet" href="/css/styles.css"> </head> <body> <h1>Welcome to My App</h1> <div id="content"> <%- content %> </div> </body> </html> ``` #### `tests` The `tests` directory contains test files to ensure your application works correctly. Tests are often organized into unit tests, integration tests, and end-to-end (e2e) tests. **Example: Directory Structure** ``` tests/ ├── unit/ ├── integration/ ├── e2e/ ``` #### `utils` Utility functions and helper modules are stored in the `utils` directory. These functions perform common tasks like validation and formatting that are used throughout the application. **Example: `utils/validation.js`** ```javascript exports.isEmailValid = (email) => { const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return re.test(String(email).toLowerCase()); }; ``` #### `node_modules` The `node_modules` directory contains all the dependencies your project needs. This directory is managed by npm (or yarn) and includes packages installed from the npm registry. ### Conclusion A well-structured Node.js application using Express.js enhances maintainability, scalability, and collaboration. Each directory and file in the structure serves a specific purpose, from handling configuration and defining routes to managing middleware and rendering views. By organizing your codebase effectively, you can build robust and scalable applications with ease.
vyan
1,926,154
Security Meetup
Thank you to all the security researchers who participated in the 100-day country ranking...
0
2024-07-17T03:21:48
https://dev.to/tecno-security/security-meetup-4d75
cybersecurity, security, bounty
Thank you to all the security researchers who participated in the 100-day country ranking vulnerability campaign! The countries that finally got the security meetup quota are India, Bangladesh, and Vietnam! The specific data of personal and national rankings are as follows. The application channel is open, come and sign up! [Campaign Details] [No security meetup fund? We support you!](https://security.tecno.com/SRC/blogdetail/212?lang=en_US) Registration link: [TECNO Security Funds Application Form](https://docs.google.com/forms/d/e/1FAIpQLSdWF0avReNTM7FRV1XVLinJ-U1t1tHJJ60DNYpXm6qNBzbhwQ/viewform) Registration time: Now - September 9th 23:59 (UTC+8)
tecno-security
1,926,155
Good news is here! 🎉🎉🎉Use Artipub to automatically publish the article to more platforms
ArtiPub (article release assistant) is a tool library aimed at simplifying content creators to...
0
2024-07-17T03:36:54
https://dev.to/yxw007/good-news-is-here-use-artipub-to-automatically-publish-the-article-to-more-platforms-2abo
ArtiPub (article release assistant) is a tool library aimed at simplifying content creators to publish the article process.It provides a simple API that allows you to easily publish the article to any platforms, such as blogs, social media, etc., without manual operation of each platform. [artipub](https://pup007.github.io/artipub/) ## ❓ Why do you need artipub? 1. Local pictures cited in Markdown need to manually compress the picture, then upload to the bed, and finally replace the picture link 2. After Markdown finished writing, I want to publish it to other platforms to avoid manual Copy 3. After Markdown finished writing the article, I need to modify some of the contents of Markdown and let it regenerate the content of Markdown 4. ... > Note: ArtiPub will help you solve these problems automatically, and will expand more in the future ## ✨ Features - 🌐 **Multi-platform release**: Support that the Markdown article is published to multiple mainstream content platforms, including but not limited to Notion, Medium, Dev.to, etc. - ✨ **Simple and easy to use**: Provide a simple API, and only need a few lines of code to implement the article release. - 🔌 **Support middleware and plugin**: Through plug -in and middle parts, let users make more fine -grained control processing and release processes. - 📖 **Complete open source**: Encourage community contributions and continue to increase new platform support and functions. ## 📌 TODO - \[x] DevToPublisherPlugin - \[x] Document Site ## 🔧 Built-in ### Treatment middleware | Name | Support | Description | | ----------- | ------- | ------------------------------------ | | piccompress | √ | Automatic compression of the picture | | Picupload | √ | Picture Upload | ### Publish plug -in | Name | Support | Description | | --------------------- | ------- | ------------------- | | NOTIONPUBLISHERPLUGIN | √ | Published to NOTION | | DEVTOPUBLISHERPLUGIN | √ | Published to DEV.TO | ## 🌟Birth background ### Phase 1: Abandon Evernote and switch to Notion At first, I used Evernote to record notes. As time went by, I came into contact with more and more things, and naturally I recorded more and more notes. So I wanted to classify my notes more finely, but Evernote only has three levels of classification. I learned how to organize notes online, read a series of articles, and finally found that this method of classification with a maximum of three levels of directories made me very uncomfortable. Another point is to fix "Evernote" to the start screen. Every time they update the version, my "Evernote" icon is lost from the start screen. I have to add it manually every time I update, which also makes me very unhappy. I have given them feedback, but their problem has always existed. I really can't stand it, so I searched for various note-taking software on the Internet, and finally found Notion It meets my needs very well. You can create directory levels at will, article management is very convenient, and the article layout method can be adjusted very flexibly. This software is very suitable for me, so I migrated all the notes in Evernote to Notion. ### Phase 2: Break away from the notion island and share knowledge As time goes by, I have become a heavy user of Notion, which means that every note or article I write is written in Notion first. I have written a lot of notes, and I hope to share my knowledge. Then I thought of putting the article on my blog, Nuggets, Medium, dev.to and other platforms, but this process is very cumbersome, which directly wipes out your interest in writing articles and sharing knowledge. If you write your article in Chinese, it is okay to put it on your own blog or domestic platform, but if you want to put the article on a foreign platform, this process is very painful. First, you have to translate the article, and then re-upload every picture in it. The most frustrating thing is that Medium does not support copying markdown to the editor of its platform (it uses a very primitive editor, which may be designed by the platform to ensure the beauty and quality of the article). After copying the markdown content to the Medium editor, the article format is all messed up. This process makes me very painful. If you have had such an experience, you can definitely feel the pain in the middle. You may ask: "Since Medium is so difficult to use, why do you still put articles on Medium? The reason is: it is very mainstream and you can earn income by writing articles, unlike various domestic platforms..." ### Phase 3: How to distribute articles on notion? I have written so many notes, how can I share the knowledge I have mastered? So I searched for notion to markdown on the Internet, and immediately found [notion-to-md](https://github.com/souvikinator/notion-to-md). At this time, I can happily convert many of the article notes I wrote on notion into markdown, and then publish them to the blog platform. After doing it, I found that the article pictures seemed to be temporary picture addresses, and the pictures could not be found after a while. This made me a little confused. If I manually download the articles on notion, I will find that the articles and pictures are together. Then, can I write a tool to format the zip file downloaded from notion into the format of my blog article with one click? So I added some column processing functions, such as automatic decompression of zip, automatic compression of pictures, automatic upload of pictures, automatic replacement of picture addresses with cdn, automatic submission and publication of articles, etc. After this operation, can I make a library to write articles in markdown and distribute them to any platform with one click? You may ask: Why not use notion to write articles and then distribute them to any platform through tools? Of course, this is also possible, but it adds the steps of writing articles in Notion, downloading articles, and subsequent processing. So why not use markdown to write articles directly, and then use tools to automatically process articles and resources. This is more flexible, so there is artipub, an article publishing assistant. ## 🔍Artipub prototype ### ArticleProcessor - Input: markdown draft, image resources - Processing process: parsing markdown, modifying markdown content, uploading images, replacing image addresses, etc. (This process: to facilitate upper-level users to flexibly modify markdown content, so markdown AST is immediately thought of, so that markdown content can be easily modified) - Output: convert the processed ast into markdown and store it in the specified place ### PublisherManager - Input: markdown article content - Processing: Some platforms need to remove certain parts of the article or extract certain parts of the article (this process: various platform plug-ins need to be added to facilitate publishing articles to various platforms) - Output: Output the publishing results to the console > Additional note: Before the official opening, you may have all kinds of entanglements and have a fantasy: to make the best and most awesome tool, constantly high, and constantly diverge your thoughts... Special note: If this state continues, you will not be able to do anything, so you must converge your thoughts in time, put your initial ideas into practice, and then continue to iterate, so that you can make a good tool. Today I watched [Anthony's open source road: Yak Shaving "薅牛毛"](https://www.bilibili.com/video/BV1XT421r7xy/?spm_id_from=333.999.top_right_bar_window_history.content.click\&vd_source=48d3cd04603032362c730cc7de10ac65), which means that I have a deep understanding of this state, so I wrote this paragraph to warn everyone to converge their thoughts and attention in time and get started. (I used to be such a person) ## 💪Roll up your sleeves and get to work ### Phase 1: Implementing the first basic version ![git commit record](https://cdn.jsdelivr.net/gh/yxw007/BlogPicBed@master/img/1720842652294.png) > Note: The first version took a total of 10 days, and I wrote more on weekends, and only a little on weekdays. ### The second stage: Use it in your own blog project. Otherwise, how can you verify whether the library you made is usable and easy to use? At first, I sent the package directly to npm, and then used it in the blog project. I found that the package had various problems, which led me to send a lot of broken temporary packages, as shown below: ![alt text](https://cdn.jsdelivr.net/gh/yxw007/BlogPicBed@master/img/1720842653704.png) I was thinking that this was not a solution. The first problem was that my version grew too fast. The second problem was that I released so many broken packages, which was irresponsible to the users of artifactipub and would have a bad impact on the promotion of artifactipub in the future. Solution to the first problem: I searched a lot on the Internet and found many libraries that updated versions and generated changelogs, but I still couldn't choose which library to use. I accidentally opened GitHub on the subway to look at the exploration page and saw the version release. At this time, I thought about which library released the changelog that looked good, and finally found [changelogen](https://github.com/unjs/changelogen) was simple and easy to use, so I chose this library. ![alt text](https://cdn.jsdelivr.net/gh/yxw007/BlogPicBed@master//img/20240715113205.png) The solution to the second problem is to add a playground to the artifactipub project to avoid the need to publish packages frequently. In this way, various functions of artifactipub can be tested in the playground, and then the functions of artifactipub can be integrated into the blog project to avoid publishing many bad packages. ### Phase 3: Integrate Artipub into the blog project When integrating artifactipub into the blog project, I immediately discovered a problem. The blog code is still written in the commonjs specification. Although artifactipub supports both commonjs and esm specifications, the reference library still reports that the esm module cannot be introduced. I forgot the specific error. I was thinking that esm is already the trend of the future, so I might as well change the blog project to the esm specification to avoid messy errors. However, after I changed to the esm specification, I still found that there were still various problems using artifactipub. This tells me: no matter your library, there is no problem with local testing, and there is no problem with adding playground testing. If you don’t apply the library to a real project, you will never know what problems will arise, so you must apply the library to a real project in a timely manner so that you can find problems and then solve them. ## 📊Current situation - \[√] artipub has been integrated into my blog project and verified to be usable normally. - \[√] artipub has its own documentation website for easy viewing and use. [aritpub portal](https://pup007.github.io/artipub/) - \[ ] Improve api documentation - \[ ] Add test cases - \[ ] Support publishing articles to more platforms If you are interested in this project, please help me click a star🌟. You are also welcome to join us so that we can improve this project together and help more people. 😊 ## 📝Summarize - From an idea to its actual implementation, there are many ups and downs in the middle. Ideas, inspirations, and fantasies will make your mind diverge constantly. Finally, you must converge your thoughts and attention in time, implement your ideas, and then continue to iterate, so that you can make your tool. - Copilot is a very easy-to-use AI assistant. I personally feel that it is much better than other assistants. After all, it has the best model training data github. If you encounter various problems in the process, it can basically help you solve them, but it also has its limitations. For example: if you want to make a function, the idea is not very clear. You can keep communicating with it, so that your ideas can be formed into a draft and then implemented. This process is still very helpful. At first, I tried it for a month with $9.9, and later found that it was very easy to use and the money was worth it, so I immediately switched to an annual subscription. I recommend everyone to try [GitHub Copilot](https://github.com/features/copilot/plans) ## 📚参考资料 - [notion-to-md](https://github.com/souvikinator/notion-to-md) - [unified](https://github.com/unifiedjs/unified) - [unist-util-visit](https://github.com/syntax-tree/unist-util-visit) - [remark-parse](https://github.com/remarkjs/remark/tree/main) - [notion-sdk-js](https://github.com/makenotion/notion-sdk-js) - [@tryfabric/martian](https://github.com/tryfabric/martian) - [Dev api](https://developers.forem.com/api/v1) - [changelogen](https://github.com/unjs/changelogen) - [rollup](https://github.com/rollup/rollup) - [mlly](https://github.com/unjs/mlly) - [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) - [sharp](https://github.com/lovell/sharp) - [tslib](https://github.com/Microsoft/tslib) - [Github GraphQL API](https://docs.github.com/en/graphql/overview/explorer)
yxw007
1,926,156
Matplotlib in Flask Web Application Server
This tutorial lab will guide you through using Matplotlib in a Flask web application server. You will learn how to create figures using the .Figure constructor and save them to in-memory buffers, embed the resulting figures in HTML output, and run the Flask application using the flask command-line tool.
27,678
2024-07-17T03:24:47
https://dev.to/labex/matplotlib-in-flask-web-application-server-2okj
labex, python, coding, programming
## Introduction This article covers the following tech skills: ![Skills Graph](https://skills-graph.labex.io/web-application-server-sgskip-49031.jpg) This tutorial lab will guide you through using Matplotlib in a Flask web application server. You will learn how to create figures using the `.Figure` constructor and save them to in-memory buffers, embed the resulting figures in HTML output, and run the Flask application using the `flask` command-line tool. ### VM Tips After [the VM](https://labex.io/tutorials/web-application-server-sgskip-49031) startup is done, click the top left corner to switch to the **Notebook** tab to access Jupyter Notebook for practice. Sometimes, you may need to wait a few seconds for Jupyter Notebook to finish loading. The validation of operations cannot be automated because of limitations in Jupyter Notebook. If you face issues during learning, feel free to ask Labby. Provide feedback after the session, and we will promptly resolve the problem for you. ## Install Dependencies Before we get started, make sure you have the necessary packages installed. You can install them using pip. ```python pip install matplotlib flask ``` ## Import Dependencies In this step, we will import the necessary dependencies. We will use `base64` to encode the image data, `BytesIO` to store the image data in memory, `Flask` to create the web application server, and `Figure` to create the figures. ```python import base64 from io import BytesIO from flask import Flask from matplotlib.figure import Figure ``` ## Create the Flask Application In this step, we will create the Flask application. We will define a route for the home page (`"/"`) and a function to generate and embed the Matplotlib figure. ```python app = Flask(__name__) @app.route("/") def home(): # Generate the figure **without using pyplot**. fig = Figure() ax = fig.subplots() ax.plot([1, 2]) # Save it to a temporary buffer. buf = BytesIO() fig.savefig(buf, format="png") # Embed the result in the html output. data = base64.b64encode(buf.getbuffer()).decode("ascii") return f"<img src='data:image/png;base64,{data}'/>" ``` ## Run the Flask Application In this step, we will run the Flask application using the `flask` command-line tool. Assuming that the working directory contains this script, run the following command to start the server: ```console FLASK_APP=matplot_lib_tutorial_lab flask run ``` ## View the Output In this step, we will view the output of the Flask application by navigating to `http://localhost:5000/` in a web browser. The Matplotlib figure should be displayed on the page. ## Summary In [this tutorial](https://labex.io/tutorials/web-application-server-sgskip-49031) lab, we learned how to use Matplotlib in a Flask web application server. We created a Flask application, generated a Matplotlib figure, embedded the figure in the HTML output, and ran the Flask application using the `flask` command-line tool. ![MindMap](https://internal-api-drive-stream.feishu.cn/space/api/box/stream/download/authcode/?code=MjkyYmRmOGYzMjM0NDBiMzJiMjdlMjdkY2JlZWYwYzRfZjVlZDU2MzNiYzI1ZDBkNzJjNzdiY2U0MDEzYWExMzdfSUQ6NzM5MjQ0MDQ1MzMxODQ0MzAxMF8xNzIxMTg2Njg2OjE3MjEyNzMwODZfVjM) --- > 🚀 Practice Now: [Web Application Server Sgskip](https://labex.io/tutorials/web-application-server-sgskip-49031) --- ## Want to Learn More? - 🌳 Learn the latest [Python Skill Trees](https://labex.io/skilltrees/python) - 📖 Read More [Python Tutorials](https://labex.io/tutorials/category/python) - 💬 Join our [Discord](https://discord.gg/J6k3u69nU6) or tweet us [@WeAreLabEx](https://twitter.com/WeAreLabEx)
labby
1,926,157
Kubernetes -Services, Ingress, and ConfigurationsDay 9 of 50 days DevOps Tools Series
Introduction Welcome to Day 9 of our 50 Days DevOps Tools series. Over the past two days,...
0
2024-07-17T12:59:30
https://dev.to/shivam_agnihotri/kubernetes-services-ingress-and-configurationsday-9-of-50-days-devops-tools-series-95b
kubernetes, devops, development, containers
## **Introduction** Welcome to Day 9 of our 50 Days DevOps Tools series. Over the past two days, we have covered the fundamental and advanced concepts of Kubernetes, including its architecture, basic commands, Deployments, StatefulSets, and persistent storage. Today, we will delve into more advanced Kubernetes concepts such as Services, Ingress, and Configurations. These concepts are essential for managing network traffic and configuring applications within Kubernetes. **Services** In Kubernetes, a Service is an abstraction that defines a logical set of pods and a policy by which to access them. Services enable loose coupling between dependent pods. Kubernetes supports several types of services, such as ClusterIP, NodePort, and LoadBalancer. **Key Features of Services:** **Stable Network Endpoint:** Services provide a stable IP address and DNS name. **Load Balancing:** Distributes traffic across multiple pods. **Service Discovery:** Kubernetes automatically discovers services and endpoints. **Isolation:** Services can isolate internal and external traffic. **Types of Services** **ClusterIP:** Exposes the service on an internal IP in the cluster. This is the default service type. **NodePort:** Exposes the service on the same port of each selected node in the cluster. **LoadBalancer:** Exposes the service using a cloud provider's load balancer. **ExternalName:** Maps the service to the contents of the externalName field (e.g., foo.bar.example.com). **Creating a Service:** Here’s how to create a Service using a YAML configuration file. **ClusterIP Service (default)** ``` apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376 ``` **NodePort Service** ``` apiVersion: v1 kind: Service metadata: name: my-service spec: type: NodePort selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376 nodePort: 30007 ``` **LoadBalancer Service** ``` apiVersion: v1 kind: Service metadata: name: my-service spec: type: LoadBalancer selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376 ``` **Explanation:** **apiVersion:** Specifies the API version. **kind:** Specifies the type of Kubernetes object (Service). **metadata:** Contains metadata about the Service, including the name. **spec:** Defines the desired state of the Service. **type:** Specifies the type of Service (ClusterIP, NodePort, LoadBalancer). **selector:** Selects pods based on labels. **ports:** Defines the port configurations for the Service. **Commands:** kubectl apply -f service.yaml #Create a service kubectl get services #Get services kubectl describe service my-service #Describe a service kubectl delete service my-service #Delete a service ## **Ingress** Ingress is a Kubernetes object that manages external access to services within a cluster, typically HTTP. Ingress can provide load balancing, SSL termination, and name-based virtual hosting. **Key Features of Ingress:** **Load Balancing:** Distributes traffic across multiple backend services. **SSL/TLS Termination:** Terminate SSL/TLS at the ingress point. **Name-Based Virtual Hosting:** Route traffic based on the host name. **Creating an Ingress Resource:** Here’s how to create an Ingress resource using a YAML configuration file. ``` apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress spec: rules: - host: my-app.example.com http: paths: - path: / pathType: Prefix backend: service: name: my-service port: number: 80 ``` **Explanation:** **apiVersion:** Specifies the API version. **kind:** Specifies the type of Kubernetes object (Ingress). **metadata:** Contains metadata about the Ingress, including the name. **spec:** Defines the desired state of the Ingress. **rules:** Specifies the routing rules for the Ingress. **host:** The host name to match. **http:** Specifies the HTTP rules. **paths:** Defines the paths to match and the backend services to route to. **path:** The path to match. **pathType:** The type of path matching (Prefix, Exact). **backend:** The backend service and port to route to. ## Configurations: ConfigMaps and Secrets Kubernetes provides ConfigMaps and Secrets to manage configuration data and sensitive information, respectively. **ConfigMaps** ConfigMaps are used to store non-confidential data in key-value pairs. They can be used to configure applications without hardcoding configuration data in the container images. **Creating a ConfigMap:** Here’s how to create a ConfigMap using a YAML configuration file. ``` apiVersion: v1 kind: ConfigMap metadata: name: my-config data: database_url: mongodb://my-db:27017 feature_enabled: "true" ``` **Explanation:** **apiVersion:** Specifies the API version. **kind:** Specifies the type of Kubernetes object (ConfigMap). **metadata:** Contains metadata about the ConfigMap, including the name. **data:** Defines the key-value pairs for the configuration data. **Secrets** Secrets are used to store confidential data, such as passwords, OAuth tokens, and SSH keys. Secrets are similar to ConfigMaps but are specifically designed to store sensitive information. **Creating a Secret:** Here’s how to create a Secret using a YAML configuration file. ``` apiVersion: v1 kind: Secret metadata: name: my-secret type: Opaque data: username: YWRtaW4= password: MWYyZDFlMmU2N2Rm ``` **Conclusion** Understanding Services, Ingress, and Configurations (ConfigMaps and Secrets) in Kubernetes is crucial for managing network traffic and configuring applications within a cluster. These concepts help in maintaining a stable, secure, and scalable environment for your applications. With this post, we conclude our three-day deep dive into Kubernetes. From tomorrow, we will explore other exciting DevOps tools that will further enhance your DevOps workflow. Stay tuned! 🔄 **Subscribe to our blog to get notifications on upcoming posts.**
shivam_agnihotri
1,926,158
Choosing the Right GE RPWFE Water Filter for Your Needs
Introduction Water quality is paramount in maintaining a healthy lifestyle, and selecting the right...
0
2024-07-17T03:28:43
https://dev.to/sp_mubashir_9ec27acedc04d/choosing-the-right-ge-rpwfe-water-filter-for-your-needs-3g15
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwttq84napey8yqu9z53.jpg)Introduction Water quality is paramount in maintaining a healthy lifestyle, and selecting the right water filter is crucial to ensure your water is clean and safe. The GE RPWFE water filter GE RPWFE water filter is a popular choice for many households due to its advanced filtration technology and user-friendly design. However, with different models and specifications available, it can be challenging to determine which filter is best suited for your needs. This comprehensive guide will help you choose the right GE RPWFE water filter for your home, ensuring optimal water quality and performance. Understanding the GE RPWFE Water Filter Advanced Filtration Technology The GE RPWFE water filter is renowned for its ability to remove a wide range of contaminants, including: Pharmaceuticals: Such as ibuprofen, atenolol, and fluoxetine. Heavy Metals: Including lead and mercury. Chlorine: Improving taste and odor by reducing chlorine. Particulates: Filtering out sediment, rust, and other particles. This advanced filtration technology ensures that your drinking water is safe, clean, and tastes great. User-Friendly Design One of the key features of the GE RPWFE water filter is its easy installation and replacement process. The twist-and-lock mechanism allows for quick and straightforward filter changes, making it accessible for users without technical expertise. NSF Certification GE RPWFE filters are NSF certified, meaning they meet strict standards for safety and performance. This certification guarantees that the filters effectively remove specified contaminants, providing you with peace of mind regarding your water quality. Factors to Consider When Choosing a GE RPWFE Water Filter Water Quality and Contaminants The quality of your incoming water is a crucial factor in determining which filter is best for your needs. Conduct a water test to identify the specific contaminants present in your water supply. Based on the results, you can choose a filter that effectively targets those contaminants. For instance, if your water has high levels of heavy metals, you’ll need a filter that excels in removing these impurities. Water Usage and Flow Rate Consider your household’s water usage and flow rate when selecting a filter. Filters have different capacities and flow rates, and choosing one that matches your water consumption ensures optimal performance and longevity. For larger households with high water usage, a filter with a higher flow rate and capacity may be necessary to meet the demand. Filter Lifespan and Replacement Frequency The recommended replacement interval for GE RPWFE filters is every six months. However, this can vary depending on water quality and usage. Consider the replacement frequency and factor in the cost of regular replacements when choosing a filter. Some filters may have a longer lifespan, reducing the frequency and cost of replacements. Compatibility with Your Refrigerator Ensure that the GE RPWFE filter you choose is compatible with your refrigerator model. While most GE RPWFE filters are designed to fit a range of GE refrigerator models, checking compatibility is crucial to avoid issues with installation and performance. Budget and Cost-Effectiveness Your budget plays a significant role in choosing the right filter. While higher-end models may offer additional features and longer lifespans, they also come at a higher cost. Evaluate your budget and consider the long-term cost-effectiveness of the filter, including replacement costs. Types of GE RPWFE Water Filters Standard GE RPWFE Filters The standard GE RPWFE filter is designed to provide excellent filtration for most households. It effectively removes common contaminants such as chlorine, heavy metals, and pharmaceuticals, ensuring clean and safe drinking water. GE RPWFE Advanced Filters Advanced models of the GE RPWFE filter offer enhanced filtration capabilities. These filters are designed to tackle specific contaminants more effectively, such as lead and other heavy metals, and may have longer lifespans. They are ideal for households with specific water quality concerns. GE RPWFE High-Capacity Filters High-capacity GE RPWFE filters are designed for households with high water usage. These filters offer larger filtration capacities and higher flow rates, ensuring that they can meet the demands of a busy household without compromising on water quality. Steps to Choosing the Right GE RPWFE Water Filter Step 1: Assess Your Water Quality Start by conducting a water test to determine the specific contaminants present in your water supply. This assessment will help you identify the type of filter you need to effectively address these contaminants. Step 2: Determine Your Water Usage Evaluate your household’s water usage and flow rate requirements. Consider the number of people in your household and your daily water consumption to determine the filter capacity and flow rate you need. Step 3: Check Compatibility Ensure that the GE RPWFE filter you choose is compatible with your refrigerator model. Refer to your refrigerator’s user manual or the manufacturer’s website for compatibility information. Step 4: Compare Filter Models Compare different GE RPWFE filter models based on their filtration capabilities, lifespan, and cost. Consider your water quality assessment and usage requirements to choose a filter that meets your needs. Step 5: Consider Budget and Cost-Effectiveness Evaluate your budget and the long-term cost-effectiveness of the filter. Factor in the cost of replacement filters and choose a model that offers the best value for your money. Tips for Maximizing Filter Performance and Lifespan Regular Maintenance Regular maintenance is crucial for ensuring optimal filter performance and longevity. Follow the manufacturer’s guidelines for filter replacement and maintenance to keep your filter functioning effectively. Pre-Filtration Solutions Consider installing pre-filtration solutions, such as a whole house water filter or a sediment filter, to reduce the load on your GE RPWFE filter. These pre-filters can remove larger particulates and contaminants, extending the life of your main filter. Monitor Water Quality Keep an eye on changes in your water’s taste, odor, and flow rate. Monitoring water quality allows you to address issues promptly and maintain filter performance. Use Filtered Water Wisely Be mindful of how you use filtered water. Avoid using it for tasks that don’t require high-quality water, such as watering plants or cleaning, to reduce the load on your filter and extend its lifespan. Conclusion Choosing the right GE RPWFE water filter for your needs involves assessing your water quality, determining your water usage, checking compatibility, comparing filter models, and considering your budget. By following these steps, you can ensure that you select a filter that effectively addresses your water quality concerns and meets your household’s requirements. Investing in the right GE RPWFE water filter ensures that you enjoy clean, safe, and great-tasting water in your home. Regular maintenance and mindful water usage will help you maximize the filter’s performance and lifespan, providing you with the best value for your investment. With the right filter, you can have peace of mind knowing that your drinking water is of the highest quality, contributing to a healthier and more enjoyable lifestyle.
sp_mubashir_9ec27acedc04d
1,926,162
Ubat Buasir Terbaik
Ubat Kecut Buasir dalam Masa 3 Hari: Panduan Rawatan Cepat dan Berkesan Apakah Buasir? Buasir adalah...
0
2024-07-17T03:43:46
https://dev.to/indah_indri_a299aff67faef/ubat-buasir-terbaik-5818
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y159kdxm0kkhohajd8o7.jpeg) **Ubat Kecut Buasir dalam Masa 3 Hari: Panduan Rawatan Cepat dan Berkesan Apakah Buasir?** Buasir adalah pembengkakan atau keradangan pada saluran darah di sekitar dubur atau rektum bawah. Ia boleh menyebabkan ketidakselesaan, kesakitan, dan kadang-kadang pendarahan semasa atau selepas membuang air besar. **Punca Buasir** Buasir boleh disebabkan oleh beberapa faktor, termasuk: 1. Sembelit kronik 2. Kehamilan 3. Obesiti 4. Duduk terlalu lama 5. Diet rendah serat **Tanda-tanda Buasir** Pendarahan semasa atau selepas membuang air besar Kesakitan atau ketidakselesaan di kawasan dubur 1. Pembengkakan di sekitar dubur 2. Gatal-gatal atau iritasi di kawasan dubur 3. Pencegahan Buasir 4. Mengamalkan diet tinggi serat. 5. Minum air secukupnya. 6. Mengelakkan duduk terlalu lama. 7. Berhenti menahan diri dari membuang air besar. 8. Bersenam secara teratur. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2qkiamf8bd0zpl9w64wg.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8uci59z54sclljhvab0.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vp50cphp0fe5he1gioz.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fob1eq993frapklruduz.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/laaij1i6db85s2vmn5uy.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gygsrmufdpv7gefhlxj7.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obwgnpnwsx8f2kdb4c33.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xfnoa2us1h676pd7qtpt.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qb5ifw4yp3sydx6tdpx.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcicvv7ccs1t8kr60zln.png) HUBUNGI KAMI KLIK DISINI[](url https://wa.link/7ar38m) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r77e9ry08y8gw2zrywgq.jpeg) ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7oyigiebdi93pm4uskg.jpeg) SUMBER https://www.sembuhlah.com/ubat-buasir-herba/
indah_indri_a299aff67faef
1,926,163
Build Nextjs 15 & React 19 Dashboard App Step By Step
Hello and welcome to my coding course to build a full-fledged admin dashboard by the best tech stack...
0
2024-07-17T03:47:00
https://dev.to/basir/nextjs-15-react-19-dashboard-app-step-by-step-4l2n
nextjs, postgres, tailwindcss, drizzle
Hello and welcome to my coding course to build a full-fledged admin dashboard by the best tech stack in the world: Nextjs 15, React 19, Drizzle Orm, and Shadcn UI. 👉 Code : https://github.com/basir/next-15-admin-dashboard 👉 Demo : https://next-15-admin-dashboard.vercel.app 👉 Q/A : https://github.com/basir/next-15-admin-dashboard/issues ## Watch Nextjs 15 & React 19 Dashboard App Step By Step Tutorial {% youtube 6ma9_5Mycns %} This admin dashboard is the updated version of acme project on https://nextjs.org/learn Here I walk you though all steps to build a real-world admin dashboard from scratch. - we will develop a responsive homepage that follows the best design practices we have. A header with hero section and call to action button to login. - A dashboard screen with sidebar navigation on desktop and header menu on mobile device. - We'll create stat boxes, bar charts, data tables on dashboard page. - invoice management from where you can filter, create, update and delete invoices. - also we'll create customers page where you can filter users based on their name and email. My name is Basir and I’ll be your instructor in this course. I am a senior web developer in international companies like ROI Vision in Montreal, and a coding instructor with 50 thousands students around the world. You need to open the code editor along with me and start coding throughout this course. I teach you: - creating admin dashboard web app by next.js 15 and react 19 - designing header, footer, sidebar, menu and search box by shadcn and tailwind - enable partial pre-rendering to improve website performance - create database models by drizzle orm and postgres database to handle invoices, customers and users. - handling form inputs by useActionState and Zod data validator - updating data by server actions without using any api - rendering beautiful charts by recharts - handling authentication and authorization by next-auth - and toggling dark and light theme by next-theme - at the end you'll learn how to deploy admin dashboard on vercel. I designed this course for beginner web developers who want to learn all new features of next 15 and react 19 features in a real-world project. If you are or want to a web developer, take this course to become a professional web developer, have a great project in your portfolio and get a job in 22 million job opportunities around the world. The only requirement for this course is having basic knowledge on react and next.js. ## 01. create next app 1. npm install -g pnpm 2. pnpm create next-app@rc 3. pnpm dev 4. lib/constants.ts ```ts export const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:3000' export const APP_NAME = process.env.NEXT_PUBLIC_APP_NAME || 'NextAdmin' export const APP_DESCRIPTION = process.env.NEXT_PUBLIC_APP_DESCRIPTION || 'An modern dashboard built with Next.js 15, Postgres, Shadcn' export const ITEMS_PER_PAGE = Number(process.env.ITEMS_PER_PAGE) || 5 ``` 5. components/shared/fonts.ts ```ts import { Inter, Lusitana } from 'next/font/google' export const inter = Inter({ subsets: ['latin'] }) export const lusitana = Lusitana({ weight: ['400', '700'], subsets: ['latin'], }) ``` 6. app/layout.tsx ```ts export const metadata: Metadata = { title: { template: `%s | ${APP_NAME}`, default: APP_NAME, }, description: APP_DESCRIPTION, metadataBase: new URL(SERVER_URL), } export default function RootLayout({ children, }: { children: React.ReactNode }) { return ( <html lang="en" suppressHydrationWarning> <body className={`${inter.className} antialiased`}>{children}</body> </html> ) } ``` 7. components/shared/app-logo.tsx ```ts export default function AppLogo() { return ( <Link href="/" className="flex-start"> <div className={`${lusitana.className} flex flex-row items-end space-x-2`} > <Image src="/logo.png" width={32} height={32} alt={`${APP_NAME} logo`} priority /> <span className="text-xl">{APP_NAME}</span> </div> </Link> ) } ``` 8. app/page.tsx ```ts export default function Page() { return ( <main className="flex min-h-screen flex-col "> <div className="flex h-20 shrink-0 items-center rounded-lg p-4 md:h-40 bg-secondary"> <AppLogo /> </div> <div className="mt-4 flex grow flex-col gap-4 md:flex-row"> <div className="flex flex-col justify-center gap-6 rounded-lg px-6 py-10 md:w-2/5 md:px-20"> <p className={`${lusitana.className} text-xl md:text-3xl md:leading-normal`} > <strong>Welcome to Next 15 Admin Dashboard.</strong> </p> <Link href="/login"> <span>Log in</span> <ArrowRightIcon className="w-6" /> </Link> </div> <div className="flex items-center justify-center p-6 md:w-3/5 md:px-28 md:py-12"> <Image src="/hero-desktop.png" width={1000} height={760} alt="Screenshots of the dashboard project showing desktop version" className="hidden md:block" /> <Image src="/hero-mobile.png" width={560} height={620} alt="Screenshot of the dashboard project showing mobile version" className="block md:hidden" /> </div> </div> </main> ) } ``` ## 02. create login page 1. pnpm add next-auth@beta bcryptjs 2. pnpm add -D @types/bcryptjs 3. lib/placeholder-data.ts ```ts const users = [ { id: '410544b2-4001-4271-9855-fec4b6a6442a', name: 'User', email: 'user@nextmail.com', password: hashSync('123456', 10), }, ] export { users } ``` 4. auth.config.ts ```ts import type { NextAuthConfig } from 'next-auth' export const authConfig = { pages: { signIn: '/login', }, providers: [ // added later in auth.ts since it requires bcrypt which is only compatible with Node.js // while this file is also used in non-Node.js environments ], callbacks: { authorized({ auth, request: { nextUrl } }) { const isLoggedIn = !!auth?.user const isOnDashboard = nextUrl.pathname.startsWith('/dashboard') if (isOnDashboard) { if (isLoggedIn) return true return false // Redirect unauthenticated users to login page } else if (isLoggedIn) { return Response.redirect(new URL('/dashboard', nextUrl)) } return true }, }, } satisfies NextAuthConfig ``` 5. auth.ts ```ts export const { auth, signIn, signOut } = NextAuth({ ...authConfig, providers: [ credentials({ async authorize(credentials) { const user = users.find((x) => x.email === credentials.email) if (!user) return null const passwordsMatch = await compare( credentials.password as string, user.password ) if (passwordsMatch) return user console.log('Invalid credentials') return null }, }), ], }) ``` 6. middleware.ts ```ts import NextAuth from 'next-auth' import { authConfig } from './auth.config' export default NextAuth(authConfig).auth export const config = { // https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher matcher: [ '/((?!api|_next/static|_next/image|.*\\.svg$|.*\\.png$|.*\\.jpeg$).*)', ], } ``` 7. lib/actions/user.actions.ts ```ts 'use server' export async function authenticate( prevState: string | undefined, formData: FormData ) { try { await signIn('credentials', formData) } catch (error) { if (error instanceof AuthError) { switch (error.type) { case 'CredentialsSignin': return 'Invalid credentials.' default: return 'Something went wrong.' } } throw error } } ``` 8. install shadcn-ui from https://ui.shadcn.com/docs/installation/next 9. pnpm dlx shadcn-ui@latest add button card 10. components/shared/login-form.tsx ```ts export default function LoginForm() { const [errorMessage, formAction, isPending] = useActionState( authenticate, undefined ) return ( <form action={formAction}> <div className="flex-1 rounded-lg px-6 pb-4 pt-8"> <h1 className={`${lusitana.className} mb-3 text-2xl`}> Please log in to continue. </h1> <div className="w-full"> <div> <label className="mb-3 mt-5 block text-xs font-medium " htmlFor="email" > Email </label> <div className="relative"> <input className="peer block w-full rounded-md border py-[9px] pl-10 text-sm outline-2 " id="email" type="email" name="email" placeholder="Enter your email address" required /> <AtSign className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 " /> </div> </div> <div className="mt-4"> <label className="mb-3 mt-5 block text-xs font-medium " htmlFor="password" > Password </label> <div className="relative"> <input className="peer block w-full rounded-md border py-[9px] pl-10 text-sm outline-2 " id="password" type="password" name="password" placeholder="Enter password" required minLength={6} /> <LockKeyhole className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 " /> </div> </div> </div> <div className="mt-4"> <Button aria-disabled={isPending}> Log in <ArrowRightIcon className="ml-auto h-5 w-5 " /> </Button> </div> <div className="flex h-8 items-end space-x-1" aria-live="polite" aria-atomic="true" > {errorMessage && ( <> <CircleAlert className="h-5 w-5 text-red-500" /> <p className="text-sm text-red-500">{errorMessage}</p> </> )} </div> </div> </form> ) } ``` 11. app/login/page.tsx ```ts export default function LoginPage() { return ( <div className="flex justify-center items-center min-h-screen w-full "> <main className="w-full max-w-md mx-auto"> <Card> <CardHeader className="space-y-4 flex justify-center items-center"> <AppLogo /> </CardHeader> <CardContent className="space-y-4"> <LoginForm /> </CardContent> </Card> </main> </div> ) } ``` ## 03. create dashboard page 1. pnpm dlx shadcn-ui@latest add dropdown-menu 2. pnpm add next-themes 3. app/layout.tsx ```ts <ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange > {children} </ThemeProvider> ``` 4. components/shared/dashboard/mode-toggle.tsx ```ts export default function ModeToggle() { const { theme, setTheme } = useTheme() const [mounted, setMounted] = React.useState(false) React.useEffect(() => { setMounted(true) }, []) if (!mounted) { return null } return ( <DropdownMenu> <DropdownMenuTrigger asChild> <Button variant="ghost" className="w-full text-muted-foreground justify-start focus-visible:ring-0 focus-visible:ring-offset-0" > <SunMoon className="w-6 mr-2" /> <span className="hidden md:block"> {capitalizeFirstLetter(theme!)} Theme </span> </Button> </DropdownMenuTrigger> <DropdownMenuContent className="w-56"> <DropdownMenuLabel>Appearance</DropdownMenuLabel> <DropdownMenuSeparator /> <DropdownMenuCheckboxItem checked={theme === 'system'} onClick={() => setTheme('system')} > System </DropdownMenuCheckboxItem> <DropdownMenuCheckboxItem checked={theme === 'light'} onClick={() => setTheme('light')} > Light </DropdownMenuCheckboxItem> <DropdownMenuCheckboxItem checked={theme === 'dark'} onClick={() => setTheme('dark')} > Dark </DropdownMenuCheckboxItem> </DropdownMenuContent> </DropdownMenu> ) } ``` 5. components/shared/dashboard/sidenav.tsx ```ts export default function SideNav() { return ( <div className="flex h-full flex-col px-3 py-4 md:px-2"> <div> <AppLogo /> </div> <div className="flex grow flex-row space-x-2 md:flex-col md:space-x-0 md:space-y-2 md:mt-2"> <NavLinks /> <div className="h-auto w-full grow rounded-md md:block"></div> <div className="flex md:flex-col "> <ModeToggle /> <form action={async () => { 'use server' await signOut() }} > <Button variant="ghost" className="w-full justify-start text-muted-foreground" > <PowerIcon className="w-6 mr-2" /> <div className="hidden md:block">Sign Out</div> </Button> </form> </div> </div> </div> ) } ``` 6. app/dashboard/layout.tsx ```ts export default function Layout({ children }: { children: React.ReactNode }) { return ( <div className="flex h-screen flex-col md:flex-row md:overflow-hidden"> <div className="w-full flex-none md:w-52 bg-secondary"> <SideNav /> </div> <div className="grow p-6 md:overflow-y-auto ">{children}</div> </div> ) } ``` 7. pnpm dlx shadcn-ui@latest add skeleton 8. components/shared/skeletons.tsx ```ts export function CardSkeleton() { return ( <Card> <CardHeader className="flex flex-row space-y-0 space-x-3 "> <Skeleton className="w-6 h-6 rounded-full" /> <Skeleton className="w-20 h-6" /> </CardHeader> <CardContent> <Skeleton className="h-10 w-full" /> </CardContent> </Card> ) } export function CardsSkeleton() { return ( <> <CardSkeleton /> <CardSkeleton /> <CardSkeleton /> <CardSkeleton /> </> ) } export function RevenueChartSkeleton() { return ( <Card className="w-full md:col-span-4"> <CardHeader> <Skeleton className="w-36 h-6 mb-4" /> </CardHeader> <CardContent> <Skeleton className="sm:grid-cols-13 mt-0 grid h-[450px] grid-cols-12 items-end gap-2 rounded-md p-4 md:gap-4" /> </CardContent> </Card> ) } export function InvoiceSkeleton() { return ( <div className="flex flex-row items-center justify-between border-b py-4"> <div className="flex items-center space-x-4"> <Skeleton className="w-6 h-6 rounded-full" /> <div className="min-w-0 space-y-2"> <Skeleton className="w-20 h-6" /> <Skeleton className="w-20 h-6" /> </div> </div> <Skeleton className="w-20 h-6" /> </div> ) } export function LatestInvoicesSkeleton() { return ( <Card className="flex w-full flex-col md:col-span-4"> <CardHeader> <Skeleton className="w-36 h-6 mb-4" /> </CardHeader> <CardContent> <div> <InvoiceSkeleton /> <InvoiceSkeleton /> <InvoiceSkeleton /> <InvoiceSkeleton /> <InvoiceSkeleton /> </div> </CardContent> </Card> ) } export default function DashboardSkeleton() { return ( <> <Skeleton className="w-36 h-6 mb-4" /> <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4"> <CardSkeleton /> <CardSkeleton /> <CardSkeleton /> <CardSkeleton /> </div> <div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8"> <RevenueChartSkeleton /> <LatestInvoicesSkeleton /> </div> </> ) } ``` 9. app/dashboard/(overview)/page.tsx ```ts export default async function Page() { return ( <main> <h1 className={`${lusitana.className} mb-4 text-xl md:text-2xl`}> Dashboard </h1> <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4"> <CardsSkeleton /> </div> <div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8"> <RevenueChartSkeleton /> <LatestInvoicesSkeleton /> </div> </main> ) } ``` 10. dd ```ts import DashboardSkeleton from '@/components/shared/skeletons' export default function Loading() { return <DashboardSkeleton /> } ``` ## 04. connect to database 1. create postgres database on https://vercel.com/storage/postgres 2. pnpm add drizzle-orm @vercel/postgres 3. pnpm add -D drizzle-kit 4. db/env-config.ts ```ts import { loadEnvConfig } from '@next/env' const projectDir = process.cwd() loadEnvConfig(projectDir) ``` 5. db/schema.ts ```ts import { pgTable, uuid, varchar, unique, integer, text, date, } from 'drizzle-orm/pg-core' import { sql } from 'drizzle-orm' export const customers = pgTable('customers', { id: uuid('id') .default(sql`uuid_generate_v4()`) .primaryKey() .notNull(), name: varchar('name', { length: 255 }).notNull(), email: varchar('email', { length: 255 }).notNull(), image_url: varchar('image_url', { length: 255 }).notNull(), }) export const revenue = pgTable( 'revenue', { month: varchar('month', { length: 4 }).notNull(), revenue: integer('revenue').notNull(), }, (table) => { return { revenue_month_key: unique('revenue_month_key').on(table.month), } } ) export const users = pgTable( 'users', { id: uuid('id') .default(sql`uuid_generate_v4()`) .primaryKey() .notNull(), name: varchar('name', { length: 255 }).notNull(), email: text('email').notNull(), password: text('password').notNull(), }, (table) => { return { users_email_key: unique('users_email_key').on(table.email), } } ) export const invoices = pgTable('invoices', { id: uuid('id') .default(sql`uuid_generate_v4()`) .primaryKey() .notNull(), customer_id: uuid('customer_id').notNull(), amount: integer('amount').notNull(), status: varchar('status', { length: 255 }).notNull(), date: date('date').notNull(), }) ``` 6. db/drizzle.ts ```ts import * as schema from './schema' import { drizzle } from 'drizzle-orm/vercel-postgres' import { sql } from '@vercel/postgres' const db = drizzle(sql, { schema, }) export default db ``` 7. drizzle.config.ts ```ts import '@/db/env-config' import { defineConfig } from 'drizzle-kit' export default defineConfig({ schema: './db/schema.ts', out: './drizzle', dialect: 'postgresql', dbCredentials: { url: process.env.POSTGRES_URL!, }, }) ``` 8. lib/placeholder-data.ts ```ts const customers = [ { id: 'd6e15727-9fe1-4961-8c5b-ea44a9bd81aa', name: 'Amari Hart', email: 'amari@gmail.com', image_url: '/customers/a1.jpeg', }, { id: '3958dc9e-712f-4377-85e9-fec4b6a6442a', name: 'Alexandria Brown', email: 'brown@gmail.com', image_url: '/customers/a2.jpeg', }, { id: '3958dc9e-742f-4377-85e9-fec4b6a6442a', name: 'Emery Cabrera', email: 'emery@example.com', image_url: '/customers/a3.jpeg', }, { id: '76d65c26-f784-44a2-ac19-586678f7c2f2', name: 'Michael Novotny', email: 'michael@novotny.com', image_url: '/customers/a4.jpeg', }, { id: 'CC27C14A-0ACF-4F4A-A6C9-D45682C144B9', name: 'Lily Conrad', email: 'lily@yahoo.com', image_url: '/customers/a5.jpeg', }, { id: '13D07535-C59E-4157-A011-F8D2EF4E0CBB', name: 'Ricky Mata', email: 'ricky@live.com', image_url: '/customers/a6.jpeg', }, ] const invoices = [ { customer_id: customers[0].id, amount: 15795, status: 'pending', date: '2022-12-06', }, { customer_id: customers[1].id, amount: 20348, status: 'pending', date: '2022-11-14', }, { customer_id: customers[4].id, amount: 3040, status: 'paid', date: '2022-10-29', }, { customer_id: customers[3].id, amount: 44800, status: 'paid', date: '2023-09-10', }, { customer_id: customers[5].id, amount: 34577, status: 'pending', date: '2023-08-05', }, { customer_id: customers[2].id, amount: 54246, status: 'pending', date: '2023-07-16', }, { customer_id: customers[0].id, amount: 666, status: 'pending', date: '2023-06-27', }, { customer_id: customers[3].id, amount: 32545, status: 'paid', date: '2023-06-09', }, { customer_id: customers[4].id, amount: 1250, status: 'paid', date: '2023-06-17', }, { customer_id: customers[5].id, amount: 8546, status: 'paid', date: '2023-06-07', }, { customer_id: customers[1].id, amount: 500, status: 'paid', date: '2023-08-19', }, { customer_id: customers[5].id, amount: 8945, status: 'paid', date: '2023-06-03', }, { customer_id: customers[2].id, amount: 1000, status: 'paid', date: '2022-06-05', }, ] const revenue = [ { month: 'Jan', revenue: 2000 }, { month: 'Feb', revenue: 1800 }, { month: 'Mar', revenue: 2200 }, { month: 'Apr', revenue: 2500 }, { month: 'May', revenue: 2300 }, { month: 'Jun', revenue: 3200 }, { month: 'Jul', revenue: 3500 }, { month: 'Aug', revenue: 3700 }, { month: 'Sep', revenue: 2500 }, { month: 'Oct', revenue: 2800 }, { month: 'Nov', revenue: 3000 }, { month: 'Dec', revenue: 4800 }, ] export { users, customers, invoices, revenue } ``` 9. db/seed.ts ```ts import '@/db/env-config' import { customers, invoices, revenue, users } from '@/lib/placeholder-data' import db from './drizzle' import * as schema from './schema' import { exit } from 'process' const main = async () => { try { await db.transaction(async (tx) => { await tx.delete(schema.revenue) await tx.delete(schema.invoices) await tx.delete(schema.customers) await tx.delete(schema.users) await tx.insert(schema.users).values(users) await tx.insert(schema.customers).values(customers) await tx.insert(schema.invoices).values(invoices) await tx.insert(schema.revenue).values(revenue) }) console.log('Database seeded successfully') exit(0) } catch (error) { console.error(error) throw new Error('Failed to seed database') } } main() ``` ## 05. load data from database 1. lib/actions/invoice.actions.ts ```ts export async function fetchCardData() { try { const invoiceCountPromise = db.select({ count: count() }).from(invoices) const customerCountPromise = db .select({ count: count() }) .from(customers) const invoiceStatusPromise = db .select({ paid: sql<number>`SUM(CASE WHEN status = 'paid' THEN amount ELSE 0 END)`, pending: sql<number>`SUM(CASE WHEN status = 'pending' THEN amount ELSE 0 END)`, }) .from(invoices) const data = await Promise.all([ invoiceCountPromise, customerCountPromise, invoiceStatusPromise, ]) const numberOfInvoices = Number(data[0][0].count ?? '0') const numberOfCustomers = Number(data[1][0].count ?? '0') const totalPaidInvoices = formatCurrency(data[2][0].paid ?? '0') const totalPendingInvoices = formatCurrency(data[2][0].pending ?? '0') return { numberOfCustomers, numberOfInvoices, totalPaidInvoices, totalPendingInvoices, } } catch (error) { console.error('Database Error:', error) throw new Error('Failed to fetch card data.') } } ``` 2. components/shared/dashboard/stat-cards-wrapper.tsx ```ts const iconMap = { collected: BanknoteIcon, customers: UsersIcon, pending: ClockIcon, invoices: InboxIcon, } export default async function StatCardsWrapper() { const { numberOfInvoices, numberOfCustomers, totalPaidInvoices, totalPendingInvoices, } = await fetchCardData() return ( <> <StatCard title="Collected" value={totalPaidInvoices} type="collected" /> <StatCard title="Pending" value={totalPendingInvoices} type="pending" /> <StatCard title="Total Invoices" value={numberOfInvoices} type="invoices" /> <StatCard title="Total Customers" value={numberOfCustomers} type="customers" /> </> ) } export function StatCard({ title, value, type, }: { title: string value: number | string type: 'invoices' | 'customers' | 'pending' | 'collected' }) { const Icon = iconMap[type] return ( <Card> <CardHeader className="flex flex-row space-y-0 space-x-3 "> {Icon ? <Icon className="h-5 w-5 " /> : null} <h3 className="ml-2 text-sm font-medium">{title}</h3> </CardHeader> <CardContent> <p className={`${lusitana.className} truncate rounded-xl p-4 text-2xl`} > {value} </p> </CardContent> </Card> ) } ``` 3. app/dashboard/(overview)/page.tsx ```ts <h1 className={`${lusitana.className} mb-4 text-xl md:text-2xl`}> Dashboard </h1> <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4"> <Suspense fallback={<CardsSkeleton />}> <StatCardsWrapper /> </Suspense> </div> ``` ## 06. display revenue chart 1. pnpm add recharts react-is@rc 2. components/shared/dashboard/revenue-chart.tsx ```ts 'use client' export default function RevenueChart({ revenue, }: { revenue: { month: string; revenue: number }[] }) { if (!revenue || revenue.length === 0) { return <p className="mt-4 text-gray-400">No data available.</p> } return ( <ResponsiveContainer width="100%" height={450}> <BarChart data={revenue}> <XAxis dataKey="month" fontSize={12} tickLine={false} axisLine={true} /> <YAxis fontSize={12} tickLine={false} axisLine={true} tickFormatter={(value: number) => `$${value}`} /> <Bar dataKey="revenue" fill="currentColor" radius={[4, 4, 0, 0]} className="fill-primary" /> </BarChart> </ResponsiveContainer> ) } ``` 3. components/shared/dashboard/revenue-chart-wrapper.tsx ```ts export default async function RevenueChartWrapper() { const revenue = await fetchRevenue() return ( <Card className="w-full md:col-span-4"> <CardHeader> <h2 className={`${lusitana.className} mb-4 text-xl md:text-2xl`}> Recent Revenue </h2> </CardHeader> <CardContent className="p-0"> <RevenueChart revenue={revenue} /> </CardContent> </Card> ) } ``` 4. app/dashboard/(overview)/page.tsx ```ts <div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8"> <Suspense fallback={<RevenueChartSkeleton />}> <RevenueChartWrapper /> </Suspense> </div> ``` ## 07. create latest invoices table 1. lib/actions/invoice.actions.ts ```ts export async function fetchLatestInvoices() { try { const data = await db .select({ amount: invoices.amount, name: customers.name, image_url: customers.image_url, email: customers.email, id: invoices.id, }) .from(invoices) .innerJoin(customers, eq(invoices.customer_id, customers.id)) .orderBy(desc(invoices.date)) .limit(5) const latestInvoices = data.map((invoice) => ({ ...invoice, amount: formatCurrency(invoice.amount), })) return latestInvoices } catch (error) { console.error('Database Error:', error) throw new Error('Failed to fetch the latest invoices.') } } ``` 2. components/shared/dashboard/latest-invoices.tsx ```ts export default async function LatestInvoices() { const latestInvoices = await fetchLatestInvoices() return ( <Card className="flex w-full flex-col md:col-span-4"> <CardHeader> <h2 className={`${lusitana.className} mb-4 text-xl md:text-2xl`}> Latest Invoices </h2> </CardHeader> <CardContent> <div> <div> {latestInvoices.map((invoice, i) => { return ( <div key={invoice.id} className={cn( 'flex flex-row items-center justify-between py-4', { 'border-t': i !== 0, } )} > <div className="flex items-center"> <Image src={invoice.image_url} alt={`${invoice.name}'s profile picture`} className="mr-4 rounded-full" width={32} height={32} /> <div className="min-w-0"> <p className="truncate text-sm font-semibold md:text-base"> {invoice.name} </p> <p className="hidden text-sm text-gray-500 sm:block"> {invoice.email} </p> </div> </div> <p className={`${lusitana.className} truncate text-sm font-medium md:text-base`} > {invoice.amount} </p> </div> ) })} </div> <div className="flex items-center pb-2 pt-6"> <RefreshCcw className="h-5 w-5 text-gray-500" /> <h3 className="ml-2 text-sm text-gray-500 ">Updated just now</h3> </div> </div> </CardContent> </Card> ) } ``` 3. app/dashboard/(overview)/page.tsx ```ts <div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8"> <Suspense fallback={<LatestInvoicesSkeleton />}> <LatestInvoices /> </Suspense> </div> ``` ## 08. authenticate user from database 1. lib/actions/user.actions.ts ```ts export async function getUser(email: string) { const user = await db.query.users.findFirst({ where: eq(users.email, email as string), }) if (!user) throw new Error('User not found') return user } ``` 2. auth.ts ```ts export const { auth, signIn, signOut } = NextAuth({ ...authConfig, providers: [ Credentials({ async authorize(credentials) { const parsedCredentials = z .object({ email: z.string().email(), password: z.string().min(6) }) .safeParse(credentials) if (parsedCredentials.success) { const { email, password } = parsedCredentials.data const user = await getUser(email) if (!user) return null const passwordsMatch = await bcryptjs.compare( password, user.password ) if (passwordsMatch) return user } console.log('Invalid credentials') return null }, }), ], }) ``` ## 09. list or delete invoices 1. pnpm add use-debounce 2. lib/actions/invoice.actions.ts ```ts export async function deleteInvoice(id: string) { try { await db.delete(invoices).where(eq(invoices.id, id)) revalidatePath('/dashboard/invoices') return { message: 'Deleted Invoice' } } catch (error) { return { message: 'Database Error: Failed to Delete Invoice.' } } } export async function fetchFilteredInvoices( query: string, currentPage: number ) { const offset = (currentPage - 1) * ITEMS_PER_PAGE try { const data = await db .select({ id: invoices.id, amount: invoices.amount, name: customers.name, email: customers.email, image_url: customers.image_url, status: invoices.status, date: invoices.date, }) .from(invoices) .innerJoin(customers, eq(invoices.customer_id, customers.id)) .where( or( ilike(customers.name, sql`${`%${query}%`}`), ilike(customers.email, sql`${`%${query}%`}`), ilike(invoices.status, sql`${`%${query}%`}`) ) ) .orderBy(desc(invoices.date)) .limit(ITEMS_PER_PAGE) .offset(offset) return data } catch (error) { console.error('Database Error:', error) throw new Error('Failed to fetch invoices.') } } export async function fetchInvoicesPages(query: string) { try { const data = await db .select({ count: count(), }) .from(invoices) .innerJoin(customers, eq(invoices.customer_id, customers.id)) .where( or( ilike(customers.name, sql`${`%${query}%`}`), ilike(customers.email, sql`${`%${query}%`}`), ilike(invoices.status, sql`${`%${query}%`}`) ) ) const totalPages = Math.ceil(Number(data[0].count) / ITEMS_PER_PAGE) return totalPages } catch (error) { console.error('Database Error:', error) throw new Error('Failed to fetch total number of invoices.') } } ``` 3. components/shared/search.tsx ```ts export default function Search({ placeholder }: { placeholder: string }) { const searchParams = useSearchParams() const { replace } = useRouter() const pathname = usePathname() const handleSearch = useDebouncedCallback((term: string) => { console.log(`Searching... ${term}`) const params = new URLSearchParams(searchParams) params.set('page', '1') if (term) { params.set('query', term) } else { params.delete('query') } replace(`${pathname}?${params.toString()}`) }, 300) return ( <div className="relative flex flex-1 flex-shrink-0"> <label htmlFor="search" className="sr-only"> Search </label> <input className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500" placeholder={placeholder} onChange={(e) => { handleSearch(e.target.value) }} defaultValue={searchParams.get('query')?.toString()} /> <SearchIcon className="absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 text-gray-500 peer-focus:text-gray-900" /> </div> ) } ``` 4. components/shared/invoices/buttons.tsx ```ts export function UpdateInvoice({ id }: { id: string }) { return ( <Button variant="outline" asChild> <Link href={`/dashboard/invoices/${id}/edit`}> <PencilIcon className="w-5" /> </Link> </Button> ) } export function DeleteInvoice({ id }: { id: string }) { const deleteInvoiceWithId = deleteInvoice.bind(null, id) return ( <form action={deleteInvoiceWithId}> <Button variant="outline" type="submit"> <span className="sr-only">Delete</span> <TrashIcon className="w-5" /> </Button> </form> ) } ``` 5. components/shared/invoices/status.tsx ```ts import { Badge } from '@/components/ui/badge' import { CheckIcon, ClockIcon } from 'lucide-react' export default function InvoiceStatus({ status }: { status: string }) { return ( <Badge variant={status === 'paid' ? 'secondary' : 'default'}> {status === 'pending' ? ( <> Pending <ClockIcon className="ml-1 w-4" /> </> ) : null} {status === 'paid' ? ( <> Paid <CheckIcon className="ml-1 w-4" /> </> ) : null} </Badge> ) } ``` 6. lib/utils.ts ```ts export const formatCurrency = (amount: number) => { return (amount / 100).toLocaleString('en-US', { style: 'currency', currency: 'USD', }) } export const formatDateToLocal = ( dateStr: string, locale: string = 'en-US' ) => { const date = new Date(dateStr) const options: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'short', year: 'numeric', } const formatter = new Intl.DateTimeFormat(locale, options) return formatter.format(date) } ``` 7. components/shared/invoices/table.tsx ```ts export default async function InvoicesTable({ query, currentPage, }: { query: string currentPage: number }) { const invoices = await fetchFilteredInvoices(query, currentPage) return ( <div className="mt-6 flow-root"> <div className="inline-block min-w-full align-middle"> <div className="rounded-lg p-2 md:pt-0"> <div className="md:hidden"> {invoices?.map((invoice) => ( <div key={invoice.id} className="mb-2 w-full rounded-md p-4"> <div className="flex items-center justify-between border-b pb-4"> <div> <div className="mb-2 flex items-center"> <Image src={invoice.image_url} className="mr-2 rounded-full" width={28} height={28} alt={`${invoice.name}'s profile picture`} /> <p>{invoice.name}</p> </div> <p className="text-sm text-muted">{invoice.email}</p> </div> <InvoiceStatus status={invoice.status} /> </div> <div className="flex w-full items-center justify-between pt-4"> <div> <p className="text-xl font-medium"> {formatCurrency(invoice.amount)} </p> <p>{formatDateToLocal(invoice.date)}</p> </div> <div className="flex justify-end gap-2"> <UpdateInvoice id={invoice.id} /> <DeleteInvoice id={invoice.id} /> </div> </div> </div> ))} </div> <table className="hidden min-w-full md:table"> <thead className="rounded-lg text-left text-sm font-normal"> <tr> <th scope="col" className="px-4 py-5 font-medium sm:pl-6"> Customer </th> <th scope="col" className="px-3 py-5 font-medium"> Email </th> <th scope="col" className="px-3 py-5 font-medium"> Amount </th> <th scope="col" className="px-3 py-5 font-medium"> Date </th> <th scope="col" className="px-3 py-5 font-medium"> Status </th> <th scope="col" className="relative py-3 pl-6 pr-3"> <span className="sr-only">Edit</span> </th> </tr> </thead> <tbody> {invoices?.map((invoice) => ( <tr key={invoice.id} className="w-full border-b py-3 text-sm last-of-type:border-none [&:first-child>td:first-child]:rounded-tl-lg [&:first-child>td:last-child]:rounded-tr-lg [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg" > <td className="whitespace-nowrap py-3 pl-6 pr-3"> <div className="flex items-center gap-3"> <Image src={invoice.image_url} className="rounded-full" width={28} height={28} alt={`${invoice.name}'s profile picture`} /> <p>{invoice.name}</p> </div> </td> <td className="whitespace-nowrap px-3 py-3"> {invoice.email} </td> <td className="whitespace-nowrap px-3 py-3"> {formatCurrency(invoice.amount)} </td> <td className="whitespace-nowrap px-3 py-3"> {formatDateToLocal(invoice.date)} </td> <td className="whitespace-nowrap px-3 py-3"> <InvoiceStatus status={invoice.status} /> </td> <td className="whitespace-nowrap py-3 pl-6 pr-3"> <div className="flex justify-end gap-3"> <UpdateInvoice id={invoice.id} /> <DeleteInvoice id={invoice.id} /> </div> </td> </tr> ))} </tbody> </table> </div> </div> </div> ) } ``` 8. lib/utils.ts ```ts export const generatePagination = ( currentPage: number, totalPages: number ) => { // If the total number of pages is 7 or less, // display all pages without any ellipsis. if (totalPages <= 7) { return Array.from({ length: totalPages }, (_, i) => i + 1) } // If the current page is among the first 3 pages, // show the first 3, an ellipsis, and the last 2 pages. if (currentPage <= 3) { return [1, 2, 3, '...', totalPages - 1, totalPages] } // If the current page is among the last 3 pages, // show the first 2, an ellipsis, and the last 3 pages. if (currentPage >= totalPages - 2) { return [1, 2, '...', totalPages - 2, totalPages - 1, totalPages] } // If the current page is somewhere in the middle, // show the first page, an ellipsis, the current page and its neighbors, // another ellipsis, and the last page. return [ 1, '...', currentPage - 1, currentPage, currentPage + 1, '...', totalPages, ] } ``` 9. components/shared/invoices/pagination.tsx ```ts export default function Pagination({ totalPages }: { totalPages: number }) { const pathname = usePathname() const searchParams = useSearchParams() const currentPage = Number(searchParams.get('page')) || 1 const createPageURL = (pageNumber: number | string) => { const params = new URLSearchParams(searchParams) params.set('page', pageNumber.toString()) return `${pathname}?${params.toString()}` } const allPages = generatePagination(currentPage, totalPages) return ( <div className="inline-flex"> <PaginationArrow direction="left" href={createPageURL(currentPage - 1)} isDisabled={currentPage <= 1} /> <div className="flex -space-x-px"> {allPages.map((page, index) => { let position: 'first' | 'last' | 'single' | 'middle' | undefined if (index === 0) position = 'first' if (index === allPages.length - 1) position = 'last' if (allPages.length === 1) position = 'single' if (page === '...') position = 'middle' return ( <PaginationNumber key={`${page}-${index}`} href={createPageURL(page)} page={page} position={position} isActive={currentPage === page} /> ) })} </div> <PaginationArrow direction="right" href={createPageURL(currentPage + 1)} isDisabled={currentPage >= totalPages} /> </div> ) } function PaginationNumber({ page, href, isActive, position, }: { page: number | string href: string position?: 'first' | 'last' | 'middle' | 'single' isActive: boolean }) { const className = cn( 'flex h-10 w-10 items-center justify-center text-sm border', { 'rounded-l-md': position === 'first' || position === 'single', 'rounded-r-md': position === 'last' || position === 'single', 'z-10 bg-primary text-secondary': isActive, 'hover:bg-secondary': !isActive && position !== 'middle', 'text-gray-300': position === 'middle', } ) return isActive || position === 'middle' ? ( <div className={className}>{page}</div> ) : ( <Link href={href} className={className}> {page} </Link> ) } function PaginationArrow({ href, direction, isDisabled, }: { href: string direction: 'left' | 'right' isDisabled?: boolean }) { const className = cn( 'flex h-10 w-10 items-center justify-center rounded-md border', { 'pointer-events-none text-gray-300': isDisabled, 'hover:bg-secondary': !isDisabled, 'mr-2 md:mr-4': direction === 'left', 'ml-2 md:ml-4': direction === 'right', } ) const icon = direction === 'left' ? ( <ArrowLeftIcon className="w-4" /> ) : ( <ArrowRightIcon className="w-4" /> ) return isDisabled ? ( <div className={className}>{icon}</div> ) : ( <Link className={className} href={href}> {icon} </Link> ) } ``` 10. app/dashboard/invoices/page.tsx ```ts export const metadata: Metadata = { title: 'Invoices', } export default async function Page({ searchParams, }: { searchParams?: { query?: string page?: string } }) { const query = searchParams?.query || '' const currentPage = Number(searchParams?.page) || 1 const totalPages = await fetchInvoicesPages(query) return ( <div className="w-full"> <div className="flex w-full items-center justify-between"> <h1 className={`${lusitana.className} text-2xl`}>Invoices</h1> </div> <div className="mt-4 flex items-center justify-between gap-2 md:mt-8"> <Search placeholder="Search invoices..." /> <CreateInvoice /> </div> <Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />} > <Table query={query} currentPage={currentPage} /> </Suspense> <div className="mt-5 flex w-full justify-center"> <Pagination totalPages={totalPages} /> </div> </div> ) } ``` 11. app/dashboard/invoices/error.tsx ```ts 'use client' import { useEffect } from 'react' export default function Error({ error, reset, }: { error: Error & { digest?: string } reset: () => void }) { useEffect(() => { // Optionally log the error to an error reporting service console.error(error) }, [error]) return ( <main className="flex h-full flex-col items-center justify-center"> <h2 className="text-center">Something went wrong!</h2> <button className="mt-4 rounded-md bg-blue-500 px-4 py-2 text-sm text-white transition-colors hover:bg-blue-400" onClick={ // Attempt to recover by trying to re-render the invoices route () => reset() } > Try again </button> </main> ) } ``` ## 10. create or update invoices 1. types/index.ts ```ts // This file contains type definitions for your data. export type FormattedCustomersTable = { id: string name: string email: string image_url: string total_invoices: number total_pending: string total_paid: string } export type CustomerField = { id: string name: string } export type InvoiceForm = { id: string customer_id: string amount: number status: 'pending' | 'paid' } ``` 2. lib/actions/invoice.actions.ts ```ts const FormSchema = z.object({ id: z.string(), customerId: z.string({ invalid_type_error: 'Please select a customer.', }), amount: z.coerce .number() .gt(0, { message: 'Please enter an amount greater than $0.' }), status: z.enum(['pending', 'paid'], { invalid_type_error: 'Please select an invoice status.', }), date: z.string(), }) const CreateInvoice = FormSchema.omit({ id: true, date: true }) const UpdateInvoice = FormSchema.omit({ date: true, id: true }) export type State = { errors?: { customerId?: string[] amount?: string[] status?: string[] } message?: string | null } export async function createInvoice(prevState: State, formData: FormData) { // Validate form fields using Zod const validatedFields = CreateInvoice.safeParse({ customerId: formData.get('customerId'), amount: formData.get('amount'), status: formData.get('status'), }) // If form validation fails, return errors early. Otherwise, continue. if (!validatedFields.success) { return { errors: validatedFields.error.flatten().fieldErrors, message: 'Missing Fields. Failed to Create Invoice.', } } // Prepare data for insertion into the database const { customerId, amount, status } = validatedFields.data const amountInCents = amount * 100 const date = new Date().toISOString().split('T')[0] // Insert data into the database try { await db.insert(invoices).values({ customer_id: customerId, amount: amountInCents, status, date, }) } catch (error) { // If a database error occurs, return a more specific error. return { message: 'Database Error: Failed to Create Invoice.', } } // Revalidate the cache for the invoices page and redirect the user. revalidatePath('/dashboard/invoices') redirect('/dashboard/invoices') } export async function updateInvoice( id: string, prevState: State, formData: FormData ) { const validatedFields = UpdateInvoice.safeParse({ customerId: formData.get('customerId'), amount: formData.get('amount'), status: formData.get('status'), }) if (!validatedFields.success) { return { errors: validatedFields.error.flatten().fieldErrors, message: 'Missing Fields. Failed to Update Invoice.', } } const { customerId, amount, status } = validatedFields.data const amountInCents = amount * 100 try { await db .update(invoices) .set({ customer_id: customerId, amount: amountInCents, status, }) .where(eq(invoices.id, id)) } catch (error) { return { message: 'Database Error: Failed to Update Invoice.' } } revalidatePath('/dashboard/invoices') redirect('/dashboard/invoices') } ``` 3. components/shared/invoices/create-form.tsx ```ts 'use client' export default function Form({ customers }: { customers: CustomerField[] }) { const initialState: State = { message: null, errors: {} } const [state, formAction] = useActionState(createInvoice, initialState) return ( <form action={formAction}> <div className="rounded-md p-4 md:p-6"> {/* Customer Name */} <div className="mb-4"> <label htmlFor="customer" className="mb-2 block text-sm font-medium" > Choose customer </label> <div className="relative"> <select id="customer" name="customerId" className="peer block w-full cursor-pointer rounded-md border py-2 pl-10 text-sm outline-2 " defaultValue="" aria-describedby="customer-error" > <option value="" disabled> Select a customer </option> {customers.map((customer) => ( <option key={customer.id} value={customer.id}> {customer.name} </option> ))} </select> <UserCircleIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 " /> </div> <div id="customer-error" aria-live="polite" aria-atomic="true"> {state.errors?.customerId && state.errors.customerId.map((error: string) => ( <p className="mt-2 text-sm text-red-500" key={error}> {error} </p> ))} </div> </div> {/* Invoice Amount */} <div className="mb-4"> <label htmlFor="amount" className="mb-2 block text-sm font-medium"> Choose an amount </label> <div className="relative mt-2 rounded-md"> <div className="relative"> <input id="amount" name="amount" type="number" step="0.01" placeholder="Enter USD amount" className="peer block w-full rounded-md border py-2 pl-10 text-sm outline-2 " aria-describedby="amount-error" /> <DollarSign className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 " /> </div> </div> <div id="amount-error" aria-live="polite" aria-atomic="true"> {state.errors?.amount && state.errors.amount.map((error: string) => ( <p className="mt-2 text-sm text-red-500" key={error}> {error} </p> ))} </div> </div> {/* Invoice Status */} <fieldset> <legend className="mb-2 block text-sm font-medium"> Set the invoice status </legend> <div className="rounded-md border px-[14px] py-3"> <div className="flex gap-4"> <div className="flex items-center"> <input id="pending" name="status" type="radio" value="pending" className="text-white-600 h-4 w-4 cursor-pointer focus:ring-2" /> <label htmlFor="pending" className="ml-2 flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium " > Pending <ClockIcon className="h-4 w-4" /> </label> </div> <div className="flex items-center"> <input id="paid" name="status" type="radio" value="paid" className="h-4 w-4 cursor-pointer focus:ring-2" /> <label htmlFor="paid" className="ml-2 flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium " > Paid <CheckIcon className="h-4 w-4" /> </label> </div> </div> </div> <div id="status-error" aria-live="polite" aria-atomic="true"> {state.errors?.status && state.errors.status.map((error: string) => ( <p className="mt-2 text-sm text-red-500" key={error}> {error} </p> ))} </div> </fieldset> <div aria-live="polite" aria-atomic="true"> {state.message ? ( <p className="mt-2 text-sm text-red-500">{state.message}</p> ) : null} </div> </div> <div className="mt-6 flex justify-end gap-4"> <Button variant="outline" asChild> <Link href="/dashboard/invoices">Cancel</Link> </Button> <Button type="submit">Create Invoice</Button> </div> </form> ) } ``` 4. components/shared/invoices/breadcrumbs.tsx ```ts import Link from 'next/link' import { lusitana } from '@/components/shared/fonts' import { cn } from '@/lib/utils' interface Breadcrumb { label: string href: string active?: boolean } export default function Breadcrumbs({ breadcrumbs, }: { breadcrumbs: Breadcrumb[] }) { return ( <nav aria-label="Breadcrumb" className="mb-6 block"> <ol className={cn(lusitana.className, 'flex text-xl md:text-2xl')}> {breadcrumbs.map((breadcrumb, index) => ( <li key={breadcrumb.href} aria-current={breadcrumb.active}> <Link href={breadcrumb.href}>{breadcrumb.label}</Link> {index < breadcrumbs.length - 1 ? ( <span className="mx-3 inline-block">/</span> ) : null} </li> ))} </ol> </nav> ) } ``` 5. app/dashboard/invoices/create/page.tsx ```ts export const metadata: Metadata = { title: 'Create Invoice', } export default async function Page() { const customers = await fetchCustomers() return ( <main> <Breadcrumbs breadcrumbs={[ { label: 'Invoices', href: '/dashboard/invoices' }, { label: 'Create Invoice', href: '/dashboard/invoices/create', active: true, }, ]} /> <Form customers={customers} /> </main> ) } ``` 6. app/dashboard/invoices/[id]/edit/not-found.tsx ```ts import { Frown } from 'lucide-react' import Link from 'next/link' export default function NotFound() { return ( <main className="flex h-full flex-col items-center justify-center gap-2"> <Frown className="w-10 text-gray-400" /> <h2 className="text-xl font-semibold">404 Not Found</h2> <p>Could not find the requested invoice.</p> <Link href="/dashboard/invoices" className="mt-4 rounded-md bg-blue-500 px-4 py-2 text-sm text-white transition-colors hover:bg-blue-400" > Go Back </Link> </main> ) } ``` 7. lib/actions/invoice.actions.ts ```ts export async function fetchInvoiceById(id: string) { try { const data = await db .select({ id: invoices.id, customer_id: invoices.customer_id, amount: invoices.amount, status: invoices.status, date: invoices.date, }) .from(invoices) .where(eq(invoices.id, id)) const invoice = data.map((invoice) => ({ ...invoice, // Convert amount from cents to dollars status: invoice.status === 'paid' ? 'paid' : 'pending', amount: invoice.amount / 100, })) return invoice[0] as InvoiceForm } catch (error) { console.error('Database Error:', error) throw new Error('Failed to fetch invoice.') } } ``` 8. components/shared/invoices/edit-form.tsx ```ts export default function EditInvoiceForm({ invoice, customers, }: { invoice: InvoiceForm customers: CustomerField[] }) { const initialState: State = { message: null, errors: {} } const updateInvoiceWithId = updateInvoice.bind(null, invoice.id) const [state, formAction] = useActionState( updateInvoiceWithId, initialState ) return ( <form action={formAction}> <div className="rounded-md p-4 md:p-6"> {/* Customer Name */} <div className="mb-4"> <label htmlFor="customer" className="mb-2 block text-sm font-medium" > Choose customer </label> <div className="relative"> <select id="customer" name="customerId" className="peer block w-full cursor-pointer rounded-md border py-2 pl-10 text-sm outline-2 " defaultValue={invoice.customer_id} aria-describedby="customer-error" > <option value="" disabled> Select a customer </option> {customers.map((customer) => ( <option key={customer.id} value={customer.id}> {customer.name} </option> ))} </select> <UserCircleIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 " /> </div> <div id="customer-error" aria-live="polite" aria-atomic="true"> {state.errors?.customerId && state.errors.customerId.map((error: string) => ( <p className="mt-2 text-sm text-red-500" key={error}> {error} </p> ))} </div> </div> {/* Invoice Amount */} <div className="mb-4"> <label htmlFor="amount" className="mb-2 block text-sm font-medium"> Choose an amount </label> <div className="relative mt-2 rounded-md"> <div className="relative"> <input id="amount" name="amount" type="number" defaultValue={invoice.amount} step="0.01" placeholder="Enter USD amount" className="peer block w-full rounded-md border py-2 pl-10 text-sm outline-2 " aria-describedby="amount-error" /> <DollarSignIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 " /> </div> </div> <div id="amount-error" aria-live="polite" aria-atomic="true"> {state.errors?.amount && state.errors.amount.map((error: string) => ( <p className="mt-2 text-sm text-red-500" key={error}> {error} </p> ))} </div> </div> {/* Invoice Status */} <fieldset> <legend className="mb-2 block text-sm font-medium"> Set the invoice status </legend> <div className="rounded-md border px-[14px] py-3"> <div className="flex gap-4"> <div className="flex items-center"> <input id="pending" name="status" type="radio" value="pending" defaultChecked={invoice.status === 'pending'} className="h-4 w-4 focus:ring-2" /> <label htmlFor="pending" className="ml-2 flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium " > Pending <ClockIcon className="h-4 w-4" /> </label> </div> <div className="flex items-center"> <input id="paid" name="status" type="radio" value="paid" defaultChecked={invoice.status === 'paid'} className="h-4 w-4 focus:ring-2" /> <label htmlFor="paid" className="ml-2 flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium " > Paid <CheckIcon className="h-4 w-4" /> </label> </div> </div> </div> <div id="status-error" aria-live="polite" aria-atomic="true"> {state.errors?.status && state.errors.status.map((error: string) => ( <p className="mt-2 text-sm text-red-500" key={error}> {error} </p> ))} </div> </fieldset> <div aria-live="polite" aria-atomic="true"> {state.message ? ( <p className="my-2 text-sm text-red-500">{state.message}</p> ) : null} </div> </div> <div className="mt-6 flex justify-end gap-4"> <Button variant="ghost"> <Link href="/dashboard/invoices">Cancel</Link> </Button> <Button type="submit">Edit Invoice</Button> </div> </form> ) } ``` 9. app/dashboard/invoices/[id]/edit/page.tsx ```ts export const metadata: Metadata = { title: 'Edit Invoice', } export default async function Page({ params }: { params: { id: string } }) { const id = params.id const [invoice, customers] = await Promise.all([ fetchInvoiceById(id), fetchCustomers(), ]) if (!invoice) { notFound() } return ( <main> <Breadcrumbs breadcrumbs={[ { label: 'Invoices', href: '/dashboard/invoices' }, { label: 'Edit Invoice', href: `/dashboard/invoices/${id}/edit`, active: true, }, ]} /> <Form invoice={invoice} customers={customers} /> </main> ) } ``` ## 11. list customers 1. lib/actions/customers.actions.ts ```ts export async function fetchFilteredCustomers(query: string) { const data = await db .select({ id: customers.id, name: customers.name, email: customers.email, image_url: customers.image_url, total_invoices: sql<number>`count(${invoices.id})`, total_pending: sql<number>`SUM(CASE WHEN ${invoices.status} = 'pending' THEN ${invoices.amount} ELSE 0 END)`, total_paid: sql<number>`SUM(CASE WHEN ${invoices.status} = 'paid' THEN ${invoices.amount} ELSE 0 END)`, }) .from(customers) .leftJoin(invoices, eq(customers.id, invoices.customer_id)) .where( or( ilike(customers.name, sql`${`%${query}%`}`), ilike(customers.email, sql`${`%${query}%`}`) ) ) .groupBy( customers.id, customers.name, customers.email, customers.image_url ) .orderBy(asc(customers.id)) return data.map((row) => ({ ...row, total_invoices: row.total_invoices ?? 0, total_pending: formatCurrency(row.total_pending ?? 0), total_paid: formatCurrency(row.total_paid ?? 0), })) } ``` 2. components/shared/customers/table.tsx ```ts export default async function CustomersTable({ customers, }: { customers: FormattedCustomersTable[] }) { return ( <div className="w-full"> <h1 className={`${lusitana.className} mb-8 text-xl md:text-2xl`}> Customers </h1> <Search placeholder="Search customers..." /> <div className="mt-6 flow-root"> <div className="overflow-x-auto"> <div className="inline-block min-w-full align-middle"> <div className="overflow-hidden rounded-md p-2 md:pt-0"> <div className="md:hidden"> {customers?.map((customer) => ( <div key={customer.id} className="mb-2 w-full rounded-md p-4" > <div className="flex items-center justify-between border-b pb-4"> <div> <div className="mb-2 flex items-center"> <div className="flex items-center gap-3"> <Image src={customer.image_url} className="rounded-full" alt={`${customer.name}'s profile picture`} width={28} height={28} /> <p>{customer.name}</p> </div> </div> <p className="text-sm text-muted"> {customer.email} </p> </div> </div> <div className="flex w-full items-center justify-between border-b py-5"> <div className="flex w-1/2 flex-col"> <p className="text-xs">Pending</p> <p className="font-medium"> {customer.total_pending} </p> </div> <div className="flex w-1/2 flex-col"> <p className="text-xs">Paid</p> <p className="font-medium">{customer.total_paid}</p> </div> </div> <div className="pt-4 text-sm"> <p>{customer.total_invoices} invoices</p> </div> </div> ))} </div> <table className="hidden min-w-full rounded-md md:table"> <thead className="rounded-md text-left text-sm font-normal"> <tr> <th scope="col" className="px-4 py-5 font-medium sm:pl-6" > Name </th> <th scope="col" className="px-3 py-5 font-medium"> Email </th> <th scope="col" className="px-3 py-5 font-medium"> Total Invoices </th> <th scope="col" className="px-3 py-5 font-medium"> Total Pending </th> <th scope="col" className="px-4 py-5 font-medium"> Total Paid </th> </tr> </thead> <tbody className="divide-y "> {customers.map((customer) => ( <tr key={customer.id} className="group"> <td className="whitespace-nowrap py-5 pl-4 pr-3 text-sm group-first-of-type:rounded-md group-last-of-type:rounded-md sm:pl-6"> <div className="flex items-center gap-3"> <Image src={customer.image_url} className="rounded-full" alt={`${customer.name}'s profile picture`} width={28} height={28} /> <p>{customer.name}</p> </div> </td> <td className="whitespace-nowrap px-4 py-5 text-sm"> {customer.email} </td> <td className="whitespace-nowrap px-4 py-5 text-sm"> {customer.total_invoices} </td> <td className="whitespace-nowrap px-4 py-5 text-sm"> {customer.total_pending} </td> <td className="whitespace-nowrap px-4 py-5 text-sm group-first-of-type:rounded-md group-last-of-type:rounded-md"> {customer.total_paid} </td> </tr> ))} </tbody> </table> </div> </div> </div> </div> </div> ) } ``` 3. app/dashboard/customers/page.tsx ```ts export const metadata: Metadata = { title: 'Customers', } export default async function Page({ searchParams, }: { searchParams?: { query?: string page?: string } }) { const query = searchParams?.query || '' const customers = await fetchFilteredCustomers(query) return ( <main> <CustomersTable customers={customers} /> </main> ) } ``` ## 12. enable partial pre-rendering 1. next.config.mjs ```ts /** @type {import('next').NextConfig} */ const nextConfig = { experimental: { ppr: 'incremental', }, } export default nextConfig ``` 2. app/layout.tsx ```ts export const experimental_ppr = true ``` ## 13. deploy-on-vercel 1. create vercel account 2. connect github to vercel 3. create new app 4. select github repo 5. add env variables 6. deploy app
basir
1,926,165
How to Become an AI Prompt Engineer?
The Artificial Intelligence realm has witnessed massive growth in recent years. The immense...
0
2024-07-17T04:00:24
https://dev.to/georgiaweston/how-to-become-an-ai-prompt-engineer-2aeo
aiengineer, promptengineering, ai, tutorial
The Artificial Intelligence realm has witnessed massive growth in recent years. The immense popularity of AI has automatically boosted the field of prompt engineering. This is because prompt engineering lies at the very core of AI systems and improves their performance. In current times professionals are keen to develop in-demand AI prompt engineer skills that can help them navigate the AI arena. If you want to have a career in AI, your goal must be to become AI prompt engineer. Learn what you need to do to become a proficient AI prompt engineer. ## Simple steps to become an AI prompt engineer There are a number of steps that you must follow to become an AI prompt engineer. You must remember that there are no shortcuts in the path. By remaining focused, determined and resilient you can develop the necessary AI prompt engineer skills to excel in your career. Below are the basic steps that you must take to move ahead in your prompt engineer journey: ## - Know your career goals The fundamental step is to be aware of your career goals. Many professionals falter in the very first step as they fail to set clear goals. In order to become AI prompt engineer, having well-defined goals is a must. **- Fundamental comprehension of Artificial Intelligence ** If you wish to dive into prompt engineering, you need to have a basic knowledge of AI. It will serve as the foundation that will help you move ahead in your career. ## - Choose the best prompt engineering AI course One of the most important steps is to select the right prompt engineering AI course. You must ensure that the course perfectly aligns with your learning needs. The course will help you obtain the [prompt engineer certification](https://101blockchains.com/certification/certified-prompt-engineering-expert/) that can boost your career. ## - Work on necessary prompt engineering skills and competencies You must consistently work on developing top skills that are needed in an AI prompt engineer. A prompt engineering AI course will definitely help you, but you also need to put in effort. ## - Apply knowledge and skills in real-life setting After you have a prompt engineer certification, you must apply your skills and expertise in the practical setting. It will prove your capability, proficiency, and expertise as a professional. These simple steps will help you to make a transition and become AI prompt engineer. You must keep in mind that having a prompt engineer certification is key to validating your skills and prowess as a capable professional. It can give you a clear edge over your rivals and competitors in the AI setting. ## Bright future of prompt engineering The future of prompt engineering is full of promise and potential. As AI technology is continuously evolving it is also influencing the prompt engineering landscape. Due to the high growth of prompt engineering in recent times, the average AI prompt engineer salary is extremely lucrative. In the future the demand for AI prompt engineers may further increase which can further boost their earning potential. If you want to take advantage of the amazing opportunity in the prompt engineering environment, you should definitely become an AI prompt engineer. With a prompt engineer certification you can certainly capture the attention of potential employers. They will certainly choose to hire a certified AI prompt engineer to fill vacant positions in their company. Hence your possibility to land your dream role can increase. Moreover, you can use your skills, expertise and knowledge in the domain to earn an attractive AI prompt engineer salary. **Also Read**: [Certified AI Professional (CAIP): Is worth pursuing?](https://dev.to/georgiaweston/certified-ai-professional-caip-is-worth-pursuing-4lhl) ## Conclusion The future of prompt engineering is extremely promising. In order to exploit the opportunities that exist in the domain, you must become an AI prompt engineer. A prompt engineer certification will serve as the ultimate tool that will help you have a bright future as a professional. Hence it is really important to select the best prompt engineering AI course that will help you in your prompt engineering journey. The [Certified Prompt Engineering Expert (CPEE) certification](https://101blockchains.com/certification/certified-prompt-engineering-expert/) offered by 101 Blockchains can act as the ideal resource that can help you become a capable AI prompt engineer. You can certainly develop the necessary skills that will help you thrive in the competitive AI and prompt engineering domain.
georgiaweston
1,926,166
Supercharge Your Development Workflow with CloudBlast's Incredibly Affordable Hourly VPS
Hey fellow devs! 👋 Today, let's talk about a game-changer in the world of VPS hosting: CloudBlast....
0
2024-07-17T04:01:16
https://dev.to/cloudblast/supercharge-your-development-workflow-with-cloudblasts-incredibly-affordable-hourly-vps-ag8
cloud, serverless, aws, webdev
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tz0ciqy2fehl9ku0i56u.png) Hey fellow devs! 👋 Today, let's talk about a game-changer in the world of VPS hosting: CloudBlast. If you're tired of overpaying for resources you don't always need or struggling with inflexible deployment options, you're in for a treat. Especially when you see their pricing! Hourly Billing: Because Time is Money (And CloudBlast Saves You Both) CloudBlast has introduced an hourly billing model for their VPS offerings that's going to make your wallet very happy. Let's break it down: 2 CPU cores 3 GB RAM 10 Gbps network Price: 0.0042 EUR / hour Yes, you read that right. Less than half a cent per hour. Here's why this is a big deal for developers: Unbeatable Cost Optimization: Only pay for the compute time you actually use. Running a CI/CD pipeline that takes 2 hours? That's all you pay for. Ideal for Bursty Workloads: Perfect for those times when you need to scale up for load testing or handle a traffic spike for a limited time. Experiment Without Breaking the Bank: Try out different server configs or test that crazy idea without committing to any significant cost. **Let's put this into perspective:** ``` # Quick cost comparison cloudblast_hourly_rate = 0.0042 # €0.0042 per hour hours_in_month = 730 # Average hours in a month # If you ran the server 24/7 for a full month full_month_cost = cloudblast_hourly_rate * hours_in_month print(f"Full month 24/7 cost: €{full_month_cost:.2f}") # If you only need the server for 100 hours in a month part_time_cost = cloudblast_hourly_rate * 100 print(f"100 hours of use cost: €{part_time_cost:.2f}") # Output: # Full month 24/7 cost: €3.07 # 100 hours of use cost: €0.42 ``` These numbers are astounding. Even if you ran this VPS 24/7 for a full month, it would only cost you about €3.07. And for more typical dev use cases where you might need it for 100 hours? That's a mere €0.42! Flexible Deployment: Because One Size Doesn't Fit All CloudBlast doesn't just stop at innovative billing. They've built a platform that gives you the flexibility you crave: Multi-Region Deployment: Choose from data centers worldwide to reduce latency or comply with data regulations. Custom Images: Upload your own VM images or choose from a variety of pre-configured ones. ** Real-World Dev Scenarios** Let's look at how CloudBlast's incredibly affordable offering can be a game-changer in real development scenarios: Microservices Testing: Spin up multiple small VPS instances to test your microservices architecture. At this price, you can create a whole cluster for pennies. Database Performance Tuning: Quickly deploy different database configs on separate VPS instances to benchmark and optimize performance without worrying about costs. Temporary Dev Environments: Create disposable environments for short-lived feature branches or bug fixes. At €0.0042/hour, you can keep an environment running for a full 8-hour workday for just €0.0336. Scalable Web Apps: Use the API to automatically scale your web app based on traffic patterns, paying only for the extra resources when you need them. With this pricing, scaling up is no longer a financial concern. **The Tech Stack** For the curious minds, here's a peek at what you're getting for that incredible price: Virtualization: KVM for rock-solid performance Networking: 10 Gbps network for blazing fast connectivity Storage: High-performance SSD storage (specific amount not mentioned, but likely sufficient for most dev needs) API: RESTful API with language-specific SDKs available **Getting Started** Ready to give it a spin? Here's a quick guide: Sign up at cloudblast.com Choose your base configuration (2 CPU, 3 GB RAM, 10 Gbps network) Deploy your first VPS Start coding! **Wrapping Up** CloudBlast's hourly billing at €0.0042/hour for a 2 CPU, 3 GB RAM, 10 Gbps network VPS is nothing short of revolutionary in the hosting world. Whether you're a solo developer, part of a startup, or working in a large enterprise, having this level of performance at such a low cost can completely change how you approach development and testing. Have you ever seen pricing this competitive for a VPS with these specs? Drop your thoughts in the comments below. And if you have any questions about making the most of this incredibly affordable setup, let's discuss! Happy coding, and may your deploys be swift and your billing microscopic! 🚀💻
cloudblast