teleren/devto huggingface dataset:
TDD doesn't mean you know everything upfront
Published: 2024-02-03 08:04:59

---
title: TDD doesn't mean you know everything upfront
published: true
date: 2024-01-30 00:00:00 UTC
tags: 
canonical_url: https://www.oliverdavies.uk/archive/2024/01/30/tdd-doesnt-mean-you-know-everything-upfront
---

I'm in the final phase of a Drupal development project for a customer.

It has some custom modules and code I wrote with automated tests and test-driven development.

Today, the client reported a bug.

But, instead of something working incorrectly, this was a use case I hadn't considered.

The tests were passing, but there wasn't one for this.

I wrote the code for the use cases I was aware of when I started, and now I'm aware of another, I can add a test for it and ensure it's tested and working.

To do test-driven development, you don't need to know all the use cases and functionality upfront.

Write for what you know at the time, then expand and iterate in the future.

 P.S. If you're creating a new Drupal module, try my [free Drupal module template](https://github.com/opdavies/drupal-module-template).
Task: try or no try
Published: 2024-01-29 23:57:41

In the ContentView I have this modifier added to fetch data:
`.task {
    await viewModel.fetchData()
}`

It works great! But if I accidentally added a `try` before `await`, Xcode will complain about `Invalid conversion from throwing function of type '@Sendable () async throws -> ()' to non-throwing function type '@Sendable () async -> Void'`

Don't `try` if it is **NOT** needed.
The importance of companies in building values and having a positive impact on society in a sustainable way 🌸
Tags: techforgood, globaldevelopment
Published: 2024-01-29 23:55:01

Technology companies have a fundamental role to play in building a better world. They have the resources and influence to promote positive change on issues such as hunger, poverty, health and the environment.

The Bill and Melinda Gates Foundation is an inspiring example of how companies can use their resources to make a difference in the world. The foundation invests in projects that are working to solve global problems such as hunger, health, climate change and poverty. The foundation has invested more than US$50 billion in projects around the world.
Gates Foundation projects have a significant positive impact on the lives of millions of people. For example, the foundation has helped eradicate polio in many countries and is working to develop new vaccines for diseases such as malaria and tuberculosis.

Amazon is another technology company that is committed to using its resources to make a difference in the world. The company has a goal of being carbon neutral by 2040 and is investing in projects and infrastructure to help achieve this goal. Amazon is also investing in social projects, such as donating to organizations that work to combat hunger and poverty.

Other technology companies should also be inspired by these companies and make a difference in the world. By acting responsibly and ethically, technology companies can help build a more just, sustainable and prosperous world.
Decoding Error
Published: 2024-01-29 23:53:00

A great read to show better decoding error!
Link: [https://stackoverflow.com/a/53231548]

When debugging, never use localizedDescription in Decodable catch blocks.
                                                                          In the simple form just `print(error)`
                                                                       It shows the full error including the crucial information debugDescription and context.Decodable errors are very comprehensive.

                                                                          While developing code you could catch each Decodable error separately, for example

```
} catch let DecodingError.dataCorrupted(context) {
  print(context)
} catch let DecodingError.keyNotFound(key, context) {
  print("Key '\(key)' not found:", context.debugDescription)
  print("codingPath:", context.codingPath)
} catch let DecodingError.valueNotFound(value, context) {
  print("Value '\(value)' not found:", context.debugDescription)
  print("codingPath:", context.codingPath)
} catch let DecodingError.typeMismatch(type, context)  {
  print("Type '\(type)' mismatch:", context.debugDescription)
  print("codingPath:", context.codingPath)
} catch {
  print("error: ", error)
}

```
It shows only the most significant information.
High Quality 1 OZ APMEX Bar Bullion Gold
Tags: coinbase, silver, gold
Published: 2024-01-29 23:40:45

High Quality 1 OZ APMEX Bar Bullion Gold

[](https://coinusmint.com/products/high-quality-1-oz-apmex-bar-bullion-gold)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2pj9jnvc9z7g67szfymk.jpg)
UUID, or not UUID?
Published: 2024-01-29 23:38:35

I have my own JSON file hosted on Github page 

Basically, it contains two value pairs: `name` (string) and `elements` (array of Element)

`{"name": "Marathon Training Phase",
    "elements": [
      {
        "title": "Base Building",
        "headline": "Always lay the foundation first.",
        "image": "base"
      },]
}`

I want to load and decode the data from it by using an APIService like this:

`do {
      let url = URL(string: baseURL)!
      let (data, _) = try await session.data(from: url)
      return try JSONDecoder().decode([Marathon].self, from: data)
    } catch {
fatalError("Failed to load data: \(error.localizedDescription))
}`

Clearly in the JSON file there is no UUID, just `name` and `elements`. That's it. There really is no need to add `var id = UUID()` to the struct model, or conform to Identifiable protocol when create the struct. And for me I happened to add it and then got problems when decoding that JSON because there is no value of id to be decoded, and Xcode will complain loudly.
Chat With Your PDFs: Part 2 - Frontend - An End to End LangChain Tutorial. Build A RAG with OpenAI.
Tags: ai, webdev, tutorial, react
Published: 2024-01-29 23:35:58

{% embed https://www.youtube.com/watch?v=xFWllDS6ZRw %}

In this video we are going to dive into part two of building and deploying a fully custom RAG with @LangChain and   @OpenAI. In this tutorial, code with me, video we will take the LangServe pipeline we developed in Part 1 and build out a fully functioning React & Typescript frontend using TailwindCSS.

The video did end up getting pretty long so we will deploy the app to  @digitalocean_staff  and to  @LangChain in Part 3!

----
Just to remember what happened so far:

In Part One You will Learned:
- Create a new app using @LangChain's LangServe
- ingestion of PDFs using @unstructuredio
- Chunking of documents via @LangChain's SemanticChunker
- Embedding chunks using @OpenAI's embeddings API
- Storing embedded chunks into a PGVector a vector database
- Build a LCEL Chain for LangServe that uses PGVector as a retriever
- Use the LangServe playground as a way to test our RAG
- Stream output including document sources to a future front end.

In Part 2 we will focus on:
- Creating a front end with Typescript, React, and Tailwind
- Display sources of information along with the LLM output
- Stream to the frontend with Server Sent Events

In Part 3 we will focus on:
- Deploying the Backend application to @DigitalOcean &   @LangChain's LangServe hosted platform to compare
- Add LangSmith Integrations
- Deploying the frontend to @digitalocean_staff's App Platform
- Use a managed Postgres Database

In Part 4 we will focus on:
- Adding Memory to the @LangChain Chain with PostgreSQL
- Add Multiquery to the chain for better breadth of search
- Add sessions to the Chat History

Github repo
---
https://github.com/focused-labs/pdf_rag
I Create The Best Text To Speech Converter APP (human-like voice) Using Python
Tags: python, api, programming, coding
Published: 2024-01-29 23:15:00

Hi 🙂🖐
Welcome to a new post. In this post, I will share with you my recent project. This project is one of the best projects I have made on this channel. It is a simple text-to-speech app. I have created this project before, but this time I made it better than ever. As you can hear, the speech is very clear and more human-like. This is thanks to the ElevenLabs API. It is the best and most amazing API you have ever used. You can generate human-like voices, voice cloning, and more features.
{% embed https://youtu.be/tlnTldwvxcw %}

**Code :** https://github.com/amr2018/Text-To-Speech-Converter-APP-In-Python-Using-Flet-Elevenlabs-API

**Support Us:**
https://ko-fi.com/freepythoncode
Discover The Canada Sync API
Tags: programming, canada, api, dakidarts
Published: 2024-01-29 23:10:32

Welcome to the Canada Sync API – your gateway to a wealth of data for seamless integration and dynamic experiences across Canada! 🍁

## Key Features

- **Facility Fetching:** Retrieve information about facilities across Canada.
- **Distance Calculations:** Calculate distances between two locations.
- **Reverse Distances:** Obtain reverse distance calculations for enhanced mapping.
- **Detailed Directions:** Access precise directions to navigate effortlessly.
- **Address Details:** Retrieve comprehensive details based on an address.
- **Phone Number Validation:** Verify Canadian phone numbers for accuracy.
- **Air Quality Checks:** Stay informed about the air quality in specific areas.
- **Weather Condition Reports:** Real-time updates on weather conditions
- **Marine Weather Reports:** Real-time updates on marine weather conditions.
- **Hydrometric Insights:** Stay weather-savvy with hydrometric reports.
- **Hydrometric Stations:** Discover and explore the network of hydrometric stations.

## Getting Started

Visit the [Canada Sync API on RapidAPI](https://rapidapi.com/kidddevs/api/canada-sync-api) to subscribe and start using the API. Integrate seamlessly with your projects and applications for a comprehensive Canadian experience.

## Issue Support

If you encounter any issues or have questions, feel free to [open an issue](https://github.com/dakidarts/canada-sync-api/issues).

## Usage

Integrate the Canada Sync API into your projects by visiting the [API on RapidAPI](https://rapidapi.com/kidddevs/api/canada-sync-api).

## Contribution

Let's go! Feel free to open issues, submit pull requests, or join the community discussions. Let's build together!

---

Elevate your projects with the Canada Sync API – where innovation meets Canadian data richness! 🌐✨
Save The Potato Game
Tags: gamedev, opensource, flutter, programming
Published: 2024-01-29 22:51:24

#### Check Out Our Game Trailer
{% embed https://www.youtube.com/embed/IuXIr0qrsvM?si=SxK4o9g5MOZrlzJA %}

### Discover "Save The Potato" - A New Mobile Gaming Sensation

🚀 We're thrilled to launch "Save The Potato," a captivating mobile game developed with #Flutter and #FlameEngine. It's a perfect blend of strategy, speed, and fun, designed for gamers of all ages.

🥔 **Ready to play?** Download "Save The Potato" now and join the adventure!

👉 [Download Here](http://savethepotato.com)
Amazon Lex and Connect Overview
Tags: ai, cloud, aws, nlp
Published: 2024-01-29 20:38:00

## Amazon Lex
Amazon Lex is the same technology that powers the **Alexa** devices by Amazon.

And if you don't know Alexa, Alexa is like a little device that you have in your home and you say "Alexa, what's the weather like tomorrow?", and it will reply "The weather is good, it'll be 22 degrees and it'll be sunny."

So, the idea is that with Amazon Lex, you get **automatic speech recognition** (ASR), that allows you to convert speech (spoken words) into text.

There's also a very good thing because Lex understands the intent of text by doing natural language understanding and understands sentences.

And Amazon Lex is a technology that will help you build chatbots or call center bots. and talking about call centers, how do we build a call center?
We have **Amazon Connect**.

## Amazon Connect
So Amazon Connect is a visual contact center that allows you to receive calls, create contact flows, and it's all cloud-based.
It can integrate with other customer relationship system, management systems (CRMs) or AWS services.

The cool thing about Amazon Connect versus traditional offering is that there is no upfront payment.
It's about **80% cheaper than traditional contact center solutions**.

So the whole flow of building a smart contact center is that you will have, for example, a phone call to schedule an appointment that is made into a number that is defined by Amazon Connect.

So they call Amazon Connect, Lex is streaming all the information from this call and understand the intent of the phone call, and therefore, it will invoke the right Lambda function, and that Lambda function, for example, can be very smart and say, "Hey, someone has said to schedule a meeting tomorrow with Ayad at 9:00 PM", Okay, I will go into my CRM and schedule that meeting by writing some code.

So this is the whole idea behind Lex and Connect.
So remember Lex is for ASR and Connect is for contact centers.


[GitHub](https://github.com/a00ayad00)
[LinkedIn](https://www.linkedin.com/in/a00ayad00)
[Facebook](https://m.facebook.com/a00ayad00)
[Medium](https://a00ayad00.medium.com/)
Workshop Series - Building a Multi-tenant Kubernetes Platform
Tags: kubernetes, opensource, devops
Published: 2024-01-29 22:32:23

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qgc7jmob3ck3krd69xzc.png)
3-part educational workshops hosted by Loft Labs in collaboration with Learnk8s.io
• Theory and practice on multi-tenancy in Kubernetes
• Scripts and code you can customize to build your demo
• Tools and techniques to plan and build a multi-tenant Kubernetes platform
https://www.vcluster.com/building-a-multi-tenant-kubernetes-platform/
Learning Ruby: Control Flow in Ruby
Published: 2024-01-29 22:29:14

IF: basically a true or false expression. When you're done you have to put END.

Else: Modify's the IF. The alternate answer to the IF statement. It shows another value.

Elseif: If you want more than 2 options

EXAMPLE:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d94hjkuv9pmhvu9a6p87.png)

Unless: Let's you check if something is false.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13zghxvm2zso6wp5ac4o.png)

Equal or not: To check if two things are equal you use ( == ). It is a comparator (relational operator). It means is equal to
!= lets you see if two values are not equal

You can also use logical or boolean operators. Ruby has three: and (&&), or (||), and not (!). Boolean operators result in boolean values: true or false.

The boolean operator and, &&, only results in true when both expressions on either side of && are true. Here’s how && works:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fosuf6j7ndxw9vou4fw2.png)

OR: ( || ) is called an inclusive OR because it evaluates to true when one, or the other, or both expressions are true

NOT: boolean operator not (!). ! makes true values false, and vice-versa.
I built a chrome extension that can cross-publish Notion page to other blogging platforms
Tags: buildinpublic, saas, startup, writing
Published: 2024-01-29 21:39:51

I love writing tech articles but I am too lazy to publish it all of my blogging platforms. 

Because, each platform comes with its own unique markdown requirements, image uploading processes, tag settings, and more. Also, simple copy-pasting doesn't work effectively due to the varying ways editors render content.

Yeah.. you guessed it right👉, I am too lazy for 15 minutes of dedicated work so I spent 5-6 month to build [this chrome extension](https://onepubli.sh)🫠

![one publish](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3ce440dsa1yc407ns0j.gif)

Anyway.. I always use Notion to manage my content and other personal goals. Then I thought… why not organising all my content on Notion and publish the page directly from there?

After hitting the wall too many times, I came up with concluded solution. Well, of course it’s not purely dependent on me because each platform has its own API and some of them are still need improvements. But I tired my best to use all of features that API’s provide.

Is that all? No. I am planning to add more platforms there based on feedback (adding reddit might be good🤔). So, I would love to hear your feedback on extension and how it performs and what other platforms I can integrate.

Because it’s newly published, anyone from my connections can reach me out from DM and ask for few extra credits for free. I always appreciate supportive community and fellow devs out there.🫡

[OnePubli.sh](https://onepubli.sh)

{% twitter https://twitter.com/thedevtimeline/status/1752049887238103296 %}
How to send in-app notifications with Next.js
Tags: nextjs, react, javascript, realtime
Published: 2024-01-29 21:34:47


[Next.js](https://nextjs.org/) continues to be one of the most widely-used frameworks to build full-stack web applications. In version 13, Next.js introduced the [App Router](https://nextjs.org/docs/app/building-your-application/routing), a new routing paradigm built on top of [React Server Components](https://nextjs.org/docs/app/building-your-application/routing) that works alongside the existing Pages Router. These changes offer developers a lot of benefits around data fetching and reduced bundle size, but also present a fundamental change to how you work in Next.js.

In this guide you'll learn how to:

- create a notification workflow with an in-app feed step in Knock
- identify users and trigger workflows with the Knock Node.js SDK and Server Actions
- integrate the `KnockFeedProvider` with React Server Components
- secure your application for production

Typically, real-time notification feeds are time-intensive features to create. First, you need to manage the infrastructure for WebSockets and Publish/Subscribe messaging patterns. Second, you need to deal with user preferences, user presence detection, storage and logging. And finally, you need to build out the frontend UI and underlying APIs to display the notifications. Luckily, Knock comes with all of that out of the box.

The [in-app feed](https://knock.app/features/in-app-notifications) channel in Knock manages all of the backend infrastructure for you. The `@knocklabs/react-notification-feed` library is [highly customizable](https://docs.knock.app/in-app-ui/react/feed#common-recipes), with advanced features like experimental cross-browser feed synchronization. If you need a higher level of control, the `@knocklabs/client` library is a low-level JavaScript SDK that you can use to build your [own custom client-side experience](https://docs.knock.app/in-app-ui/javascript/quick-start).

## Video walkthrough
{% embed https://www.youtube.com/embed/yN0A_wjaWmc %}

## Resources

- [React in-app feed UI](https://docs.knock.app/in-app-ui/react/feed)
- [Knock Node.js SDK](https://github.com/knocklabs/knock-node)
- [Knock in-app feed channel details](https://docs.knock.app/integrations/in-app/knock)

If you want to try out Knock to power your notifications, you can [sign up for free here](https://dashboard.knock.app/signup).
Can you do it more dificulty?
Tags: php, webdev, beginners, programming
Published: 2024-01-29 21:06:25



```
Wrong ❌
if ($a == 1) {
    return true;
}

return false;

```


```
Correct ✅
switch ($a) {
  case 1:
    return true;
    break;
  default:
    return false;
    break;
}

```
Understanding Go: part 1 – Variable
Tags: go, tutorial, beginners
Published: 2024-01-29 21:01:43

---
title: Understanding Go: part 1 – Variable
published: true
description: Serie of sketchnotes about Go. Explaining in a visual way Go/Golang concepts.
tags: Go, Golang, Tutorial, beginners
series: Understanding Go in sketchnotes
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugpq3vnxw9srcvjdukea.jpg
---

Even if you can create your first application in Go in a few minutes, understanding a new programming language is not easy and can be time-consuming.

After writing the blog series [Learning Go by examples](https://dev.to/aurelievache/learning-go-by-examples-introduction-448n), let's discover all the concepts of Go in a visual way, in sketchnotes.

I start this series of sketchnotes about Go with one useful and basic concept: Variable.

![Go visual way variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugpq3vnxw9srcvjdukea.jpg)
![Go visual way variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qpx47su1soj7va2ygdh.jpg)
![Go visual way variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhdh4eqa0e0n850x2ygq.jpg)
![Go visual way variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c2b74mtmkvn4e7t041r.jpg)
![Go visual way variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7unl1do52542mkwu25q.jpg)
![Go visual way variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60cba9rne03u785j3olw.jpg)

This is the first blog post of this serie so if you liked it, you can follow me, and tell me what do you think ❤️. If it interest, I will publish others sketches shortly :-).
 
Moreover, if you are interested about this way to explain visually technologies, I published an entire illustrated book about Kubernetes, available in paperback on [Amazon](https://www.amazon.fr/dp/B0BB619188/ref=cm_cr_arp_d_product_top?ie=UTF8) and in digital version on GumRoad: ["Understanding Kubernetes in a visual way"](https://gumroad.com/aurelievache#uCxcr).
And an illustrated book about Docker, available in paperback on [Amazon](https://www.amazon.fr/Understanding-Docker-visual-way-sketchnotes/dp/B0BT6ZXR1W/) and in digital version on GumRoad: ["Understanding Docker in a visual way"](https://gumroad.com/aurelievache#uCxcr).
Why Typescript over Javascript
Tags: typescript, javascript, webdev, programming
Published: 2024-01-29 21:00:12


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qii7pm5pe31er2blsc11.jpeg)

If you are a beginner, than You can consider Typescript as a superset of a javascript.. more specifically it can be considered as a typed superset of javascript. An example below shows basic representation of difference between Js and Ts.

**Syntax Difference in JS and TS
// javascript

`var x = 10;
let y = “Hello”;
const z = true;
`
// typescript

`let x: number = 10;
let y: string = “Hello”;
const z: boolean = true;`

As the name suggests, Typescript is a statically typed programming lanaguage whereas Javascript is a dynamically typed programming language.

**_Reasons to use Typescript over Javascript_**
**Static Typing** : TypeScript introduces static typing, allowing you to define types for variables, function parameters, and return values. This helps catch potential errors at compile-time rather than runtime, making the code more robust and less error-prone.

**Code Readability and Maintainability** : Typescript allows developers to write readable , run-time error prone , code for large code bases and projects.

**Early Error Detection**: TypeScript’s static type checking helps identify potential issues early in the development process. This can lead to more stable code and reduce the likelihood of bugs making it to production.

**Interfaces and Enums**: TypeScript supports the use of interfaces and enums, providing a way to define clear contracts for the structure of objects and representing sets of related values. This can contribute to better code organization and understanding.

Overall, it totally depends on the project requirement and the length of the project . If the project size is too large then consider going with Typescript :)