teleren/devto huggingface dataset:
Predicate Pushdown - Understanding Practically With An Example
Tags: spark, optimisation, sql, interview
Published: 2024-04-17 19:42:28

What is predicate pushdown?

The immediate theoretical answer that we get on searching is
> Predicate pushdown is a query optimisation technique used in database technologies

Okay, I got to know that it is an optimisation technique. But I still did not understand...
1. How is the optimisation happening? 🤨
2. What is predicate? 🤔
3. What exactly is the meaning of pushed down here? 🤷‍♂️

I'm sure since you are also reading this article, even you have these questions in mind!


Now, lets explore this interesting topic practically in **_PySpark_** using `explain()`
(Similar phenomenon could be observed in relational databases as well)

1] Reading a csv file containing employee information.
```py
emp = spark.read.format('csv')\
                .option('header', True)\
                .load('data/employee.csv')
emp.show()
```


![df.show](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ppxfeaejoac8noucyd86.png)

```py
emp.explain(mode="formatted")
```

![pyspark explain read df](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg2ushs3wglcaltw18wk.png)

Here, step (1) is related to read csv file

2] Lets do a group by and get number of employees on each department

```py
df = emp.groupBy('deptID').count()
df.show()
```

![emp group by](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqawodk4tq9qwuy14eu5.png)

```py
df.explain(mode="formatted")
```

![df explain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jehpma6xwkaybwow9kby.png)

Here, step (2) is related to `group by`

3] Lets filter data for only dept number 10
```py
dept_10 = df.filter(df.deptID == 10)
dept_10.show()
```

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

```py
dept_10.explain(mode="formatted")
```



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

Here, we can see that step (2) is filtering and step (3) is grouping. 

Now here is the catch, 
Ideally if we go by the sequence of operations, grouping should be done first and then filtering. 

However, the optimiser does filtering first and then grouping, because grouping is an expensive operation and it is optimal to filter first and then group data.


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

In the physical plan we see that filtering (`predicate`) is pushed down with respect to grouping. That is why it is called `push down` !
CourseBot - Coze AI Bot Challenge
Tags: cozechallenge, devchallenge, ai, machinelearning
Published: 2024-04-17 19:42:21

*This is a submission for the [Coze AI Bot Challenge](https://dev.to/devteam/join-us-for-the-coze-ai-bot-challenge-3000-in-prizes-4dp7): Bot Innovator.*

## What I Built
I present CourseBot, a skillful course recommender designed to find the most recent and popular free courses on various topics. CourseBot utilizes online platforms such as YouTube and Open edX to curate a selection of high-quality courses tailored to the user's interests.

## Demo

You can experience CourseBot in action at the [Coze Bot Store](https://www.coze.com/store/bot/7358913583692120069). Below are some screenshots showcasing CourseBot's chat interface:

![Sample](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phkf8h4c916w6f2tdqdp.png)


## Your Configuration

Here's a glimpse of CourseBot's configuration, showcasing its prompts and skills:


![Plugins](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iav8r9m6iq8tffpqash0.png)

![Persona](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kj6avg5dnam8d7of5ii.png)

## Journey

My journey crafting this chatbot began with ensuring a clear understanding of user needs and preferences. With a well-defined thought and utility in hand, I defined the persona.

Process of customising and launching the bot was made very easy by the Coze AI Bot Store, whose intuitive interface streamlined the creation and deployment process. Their platform was very user-friendly and enabled me to convert the idea into bot quickly. Its array of plugins and tools provided a seamless experience, allowing us to focus on perfecting our bot's functionality and prompt.

Thank you for considering CourseBot for the Coze AI Bot Challenge!
Create a collage with AWS Information Technology symbols and logos
Tags: aws, ai, beginners
Published: 2024-04-17 19:35:43

Creating a collage with AWS Information Technology symbols and logos can be done through various software tools like Photoshop, Illustrator, or online tools like Canva or Fotor. Here is a simplified step-by-step guide using an online tool:
Collect Images: The first step is to collect the AWS Information Technology symbols and logos that you wish to include in your collage. Ensure that you have the right permissions to use these images.
Choose a Collage Maker: Decide on which software or online tool you will be using to create your collage. Some popular online tools are Canva, Fotor, and BeFunky.
Choose a Layout: These platforms provide various templates. Choose a layout that suits your vision best.
Upload and Arrange Images: Import the collected images into the software and then drag them into your chosen layout. You can resize, rotate, and rearrange images as needed.
Add Text and Extras: If necessary, you can add text or other extras like filters or graphics for a personalized touch.
Preview and Save: Once your images are arranged exactly how you want them, preview the collage and save or download your work.
Outputting data without using a loop
Tags: vba, resize
Published: 2024-04-17 19:00:19

---
title: Outputting data without using a loop
published: true
description: This article covers how to use a single line of code to output multiple data without looping statements.
tags: VBA, Resize
cover_image: https://velog.velcdn.com/images/jimsjoo/post/96bd32b2-9206-4636-a074-60619e6e84c2/image.png
# Use a ratio of 100:42 for best results.
# published_at: 2024-04-17 18:53 +0000
---

If you are creating a table in a worksheet, you can use a template sheet with pre-made column names, or sometimes the column names are generated dynamically.
![Image](https://velog.velcdn.com/images/jimsjoo/post/7ee42c00-0dad-436f-96f3-c180a13cdf5d/image.png)
If you want to print the column names in VBA code, you can either print the column names for each cell individually, or you can smartly put them in an array and loop through them if there is too much code.

The following examples show how to output multiple values in a range of cells without using a loop, including outputting a single value, using a VBA array, using an Excel array literal, mixing two arrays, and using worksheet functions TODAY() and NOW().
![Image](https://velog.velcdn.com/images/jimsjoo/post/96bd32b2-9206-4636-a074-60619e6e84c2/image.png)
```
Sub demoResize()
  Dim myStr As String
  
  myStr = "a string from vba"
  With Sheet1.Range("A1")
    .Offset(0, 1).Resize(1, 2) = "A value"
    .Offset(1, 1).Resize(1, 2) = Array("Price", "Delta")
    .Offset(2, 1).Resize(3, 2) = [{"Zip", "22150";"City", "Springfield"; "State", "VA"}]
    .Offset(5, 1).Resize(1, 3) = Array([Today()], [Now()], myStr)
  End With
End Sub
```
If you are working on a repetitive and complex M&A valuation, you can use the Rezise function as follows. The code below is very simple to demonstrate the use of the function, but if you are working on a real-world scenario, you will want to create more complex code.
```
Sub demoResize2()

    With Sheet1.Range("A10")
        .Offset(0, 1) = "RETURN ON EQUITY (ROE)"
        .Offset(1, 1).Resize(1, 7) = Array("Year", 0, 1, 2, 3, 4, 5)
        .Offset(2, 1).Resize(1, 7) = Array("Profit after tax (net profit)", 0, 190, 266, 354, 457, 578)
        .Offset(3, 1).Resize(1, 7) = Array("Equity", 1100, 1290, 1556, 1910, 2367, 2945)
        .Offset(4, 1).Resize(1, 7) = Array("Return on equity", 0, 16, 19, 20, 21, 22)
    End With
End Sub
```

![Image](https://velog.velcdn.com/images/jimsjoo/post/dcbe5c8d-edde-4409-84a7-bad1593ca919/image.png)
Is Javascript's import syntax semantically wrong?
Tags: javascript
Published: 2024-04-17 18:50:07

In JS, if when import a file as a whole, the syntax is 
`import XXX from './xxx'`

But I think this is semantically wrong, because the word `from` indicates that the thing you are importing is a part of the file, not the file itself.

For example, if A takes a candy **from** B, then the candy is just a part of B's belongings, not B himself.

So it should be just `import './xxx'`, and it is like this in other languages such as Java.

If we need to give it an alias, it is `import './xxx' as xxx`.

If it is like this, then when importing parts from a file, we can omit the dereference curly brackets, so it is `import XXX from './xxx'` instead of `import { XXX } from './xxx'`. 

In the latter, `{}` and `from` are redundant and confusing.
📚Storybook not picking up tailwindcss
Tags: webdev, react
Published: 2024-04-17 18:40:53

## Description
1. You have a Next.js setup pre-configured by default.
2. You integrated Storybook with tailwindcss and next.js
3. When you run `yarn dev` or `npm run dev`, you can see `tailwindcss` is applied to your app.
4. However, when you `yarn storybook` or `npm run storybook`, you see `tailwindcss` is not applied to the stories.

If you went through all the things, maybe this post might give you some workaround.

## Workaround

1. Run the following command:

    ```
    yarn add autoprefixer --dev
    ```

2. Create `postcss.config.js` in your project root directory and type this in the file:

    ```js
    // esmodule config is not supported by Storybook

    module.exports = {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      },
    };
    ```

3. Helpful Information
  - Storybook picks up `tailwindcss` in these cases.
      1. There is only `postcss.config.js` in your project
      2. There are both `postcss.config.mjs` and `postcss.config.js` in your project
  - Storybook doesn't pick up `tailwindcss` in this cases.
      1. There is only `postcss.config.mjs` in your project

## Related GitHub Issues and Articles
[[Bug]: Configuration with TailwindCss](https://github.com/storybookjs/storybook/issues/25177)
[Next.js using Tailwind with Storybook](https://dev.to/lico/nextjs-using-tailwind-with-storybook-5aie)

## I reported the issue!

If you are interested, check this out: [https://github.com/storybookjs/storybook/issues/26869](https://github.com/storybookjs/storybook/issues/26869)
Why <img> exceeds its parent <div>'s size?
Tags: html
Published: 2024-04-17 18:26:05

https://codepen.io/powerseed/pen/poBxEeM

I guess this is some default setting of HTML, but it is really weird and counter-intuitive.

The `div` is like a box, `img` is an item inside the box, how is that possible that the item inside a box is bigger than the box, like a ball is bigger than its packing box?

It is against ppl's life experience.

I wonder what is the rationale behind this setting? 
In other words, what downs will happen if it is not like this?

Thanks.
Dynamic Serializers in Django
Tags: django, webdev, programmers, developers
Published: 2024-04-17 18:24:08

Dynamic serializers are extremely useful to make flexible APIs.
 

**Why do we need dynamic serializers**

**Flexibility**: It provides flexibility. We often run into issues, where we need a serializer but not all the fields from that serializer. In that case dynamic serializers are especially useful to use subsets of data. 

 

**Code Reusability**: No need to write multiple serializers anymore, a single dynamic serializer can achieve various needs. 

 

**Performance**: If we only pick the fields we need, it will immensely improve the overall performance. 

 

While it has good advantages, it comes with few complexities as well. It can make debugging a little difficult and we can come across with errors if we do not follow good practices and test all kind of edge cases. 

 

 

 

**Implementation**: 

```
class DynamicSerializer(ModelSerializer): 
    
    """
    A ModelSerializer that takes an additional 'fields' 
    argument that controls which fields should be displayed. 
    """
    

    def __init__(self, *args, **kwargs): 

        fields = kwargs.pop('fields', None) 

        # Instantiate the superclass normally 

        super(DynamicFieldsModelSerializer, self).__init__(*args, **kwargs) 

        if fields is not None: 

            # Drop any fields that are not specified in the `fields` argument. 

            allowed = set(fields) 
            existing = set(self.fields.keys()) 
            for field_name in existing - allowed: 
                self.fields.pop(field_name)


# Example usage in a view 
class UserSerializer(DynamicFieldsModelSerializer): 
    class Meta: 
        model = User 
        fields = '__all__' `

  
# In your view 
serializer = UserSerializer(user, fields=('id', 'username', 'email')) 

```
 

 

 

 

 

Conclusion: 

Dynamic serializer is powerful tool in Django, especially for large and complex projects.  

Proper implementation and thorough testing are important to achieve good and optimised results.
Introducción a TypeScript para Desarrolladores Principiantes: Conceptos, Ventajas y Más
Tags: typescript, beginners, frontend, javascript
Published: 2024-04-17 18:21:39

¡Hola!👋

En el vertiginoso mundo del desarrollo web, es crucial mantenerse al día con las últimas tecnologías. Si eres nuevo en el desarrollo web o simplemente estás buscando ampliar tu conjunto de habilidades, este post está diseñado para ti. 
Vamos a sumergirnos en los conceptos básicos de TypeScript, explorar su importancia y ventajas, compararlo con JavaScript puro y, por supuesto, aplicarlo en un ejemplo sencillo pero poderoso. 

**¿Qué es TypeScript?**
TypeScript es un superconjunto tipado de JavaScript que agrega tipos estáticos a tu código. Esto significa que puedes definir el tipo de tus variables, parámetros de funciones y más, lo que hace que tu código sea más predecible y menos propenso a errores.

**Importancia y ventajas:**

1. **Mayor robustez:** brinda una capa adicional de seguridad y robustez a tu código, especialmente en proyectos grandes y complejos.

2. **Mejor mantenibilidad:** los tipos explícitos hacen que tu código sea más legible y comprensible, lo que facilita el mantenimiento y la colaboración en equipo.

3. **Productividad mejorada:** obtienes un desarrollo más rápido al detectar errores en tiempo de compilación y al proporcionar autocompletado inteligente en tu editor de código.


**Versus JavaScript puro:**

1. **Tipado estático vs. Tipado dinámico:** Mientras que JavaScript es dinámicamente tipado, lo que significa que los tipos de variables se resuelven en tiempo de ejecución, TypeScript ofrece tipado estático, lo que permite detectar errores antes de la ejecución del código.

2. **Escritura de código más segura:** TypeScript te ayuda a evitar errores comunes, como la manipulación inadvertida de tipos de datos, lo que puede ser una preocupación en JavaScript puro.


**Aplicación práctica con un ejemplo:**

¡Es hora de poner manos a la obra! Imagina que quieres crear una función simple para sumar dos números en TypeScript:

```
function sumar(a: number, b: number): number {
    return a + b;
}

console.log(sumar(5, 3)); // Output: 8
```

**En tu editor de codigo**
El plugin "Pretty TypeScript Errors" para Visual Studio Code, el cual mejora la visualización de los errores y advertencias del compilador de TypeScript en el editor. Proporciona una presentación más legible y detallada de los mensajes de error, lo que facilita la identificación y resolución de problemas en el código TypeScript. 


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


¡Felicidades, has dado tus primeros pasos en el emocionante mundo de TypeScript! Espero que este post te haya ayudado a comprender los conceptos básicos de TypeScript, su importancia y ventajas sobre JavaScript puro, y cómo aplicarlo en un ejemplo práctico. Ya sea que estés desarrollando una pequeña aplicación o un proyecto a gran escala, TypeScript puede ser tu mejor aliado para escribir código más seguro y mantenible. ¡Sigue explorando y nunca dejes de aprender!

¡Nos vemos en el próximo post!😊
Ai Searching algorithm
Published: 2024-04-17 18:20:44


ใน Post นี้เราจะมาแนะนำหนึ่งในการหาตัวข้อมูลหรือคำตอบของ Ai โดยผ่าน AI algorithm ที่ชื่อว่า Breadth First Search 

- BFS หรืออีกคำนึงคือหลักการ FIFO First in Last out ในการหาโหนดข้อมูลที่จะหาใน Tree นั้นๆที่อยากจะหาแต่ในที่นี้เราจะ Algorithm นี้ในการหาคำตอบของเกม 8 Puzzle หลักการในการหาคำตอบจะใช้ตัวของ Level เป็นตัวหลักในการ Search หาคำตอบนั้นเอง


![BFS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svyz3wma4ijnymnftzyk.jpg)




![Example ของเกม](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bnkp5x1qu77sdl7bbhc2.png)

ในการหาคำตอบของ Puzzle อันนี้เราจะใช้ Ai ในการเลื่อนช่องของตัวเลขไปในช่องว่างเพื่อเรียงตัวเลขให้ได้เหมือนกับคำตอบที่เซ็ตไว้

เริ่มจากการ Import Library เพื่อสร้าง 8 puzzle มา



![CreatePuzzle1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrrvdnw0fjqofd2pd9sz.png)


![CreatePuzzle2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjria0u8fn61qeyw9a74.png)

เราสามารถที่จะเลื่อนตัวเลขโดยใช้คำสั่งในรูปด้านล่าง


![Move Pieces](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8aodzvjkyhyc97mdj70m.png)

การที่จะทำให้ตัวเลขไม่เกินขอบออกไปเราจะใช้คำสั่งดังนี้

![Blocking](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5ffm4jswbi1kxp2tj58.png)

แล้วทำการเช็คว่าถึง Goal หรือยัง

![GoalCheck](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exlp95327jnncofxe1d3.png)

ใช้ฟังชั่นนี้ในการสร้างเป็นตารางออกมา

![BuildMatrix](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdvfbt8eybnxyomutukk.png)

เราสามารถสร้างตัว Path หรือ Move ของ Ai ได้จากคำสั่งด้านบ่างว่า Ai นั้นเดินอย่างไร


![PathAi](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ujwqwex9pgswf4wexnrw.png)

การที่ Ai จะรู้ได้ว่าช่องไหนเป็นช่องว่าให้ใช้คำสั่งด้านล่างนี้


![Blank Check](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t96nmufxaoco3s1jmr87.png)

ต่อไปเราจะสร้างตัว Puzzle ขึ้นมาจากการใช้ Code ด้านบนโดยทำให้ Ai ใช้ระบบ ฺBFS ในการหาคำตอบนั้นเอง


![CreatePuzzle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zh5nwy8xjqhwt74xyhts.png)


![Create Puzzle2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8u55lnf2gotfhi7l4zc7.png)

เราสามารถเซ็ต Starting และ Goal ผ่านโคดด้านล่างนี้

![SetGoal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smntlvup4u8i8rhv6obp.png)

เราสามารถเริ่มให้ Ai เล่นเกมได้ผ่านโคดด้านล่าง

![RunCode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o0lgjkq1zqpqcbub0u5.png)

จะได้เป็นคำตอบด้านล่างนี้


![Result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bm2tzmupkfapsr22wux0.png)


จากการหาคำตอบด้านต้นจะสามารถสรุปได้ว่า BFS สามารถหาคำตอบได้จริงๆ แต่อาจจะใช้เวลาในการหานานขึ้นอยู่กับระดับความสามารถในการประมวณผลของระบบแต่ละคน ซึ่งต่างจะ DFS ที่จะออกแนว 50 50 ในการหาคำตอบแล้วมีสิทธิ์ที่จะหาคำตอบไม่ได้นั้นเองถ้าเลือกผิดทาง
Mold inspection, Hollywood Florida
Published: 2024-04-17 18:19:09

Methods of Black Mold Testing

Several methods are commonly used for black mold testing, each offering unique advantages and limitations. The choice of method depends on various factors, including the suspected extent of mold contamination, budget constraints, and the expertise of the testing personnel. The following are some commonly employed black mold testing methods:

Visual Inspection: Visual inspection is the initial step in identifying potential mold growth. Trained professionals visually examine indoor spaces for visible signs of mold, such as discoloration, musty odors, and water stains. While visual inspection can detect obvious mold infestations, it may not uncover hidden mold growth.

Air Sampling: Air sampling involves collecting air samples from indoor environments to measure the concentration of mold spores present in the air. This method can detect airborne mold spores, providing valuable information about the extent of mold contamination and the types of molds present. Air sampling techniques include impaction, agar plate, and spore trap methods.

Surface Sampling: Surface sampling entails collecting samples from suspected mold-infested surfaces using swabs, tape lifts, or bulk sampling methods. These samples are then analyzed in a laboratory to identify the presence of mold species and determine their concentration. Surface sampling helps pinpoint the exact locations of mold growth and assess the severity of contamination.

http://royalmoldfl.com/water-damage
Announcing Minder Cloud: A fully managed software security platform for open source communities
Published: 2024-04-17 18:16:24

When we launched the open source platform Minder back in November 2023, our goal was to make it easier for open source developers and communities to use community security tools to continuously secure their projects, and provide proof of that security to their downstream consumers. That goal hasn’t changed, but now we’re making it even easier for them to adopt Minder, by launching a fully managed version with an easy-to-use UI.

Have a read more on our blog: https://stacklok.com/blog/announcing-minder-cloud-a-fully-managed-software-security-platform-for-open-source-communities
One Thing For Each Next Lacks
Published: 2024-04-17 18:14:09

---
title: One Thing For Each Next Lacks
published: true
description: This post discusses the inconvenience of not having a Step in For Each Next when iterating over a Range in a Worksheet, and how to use Do Loop and Offset to iterate over a range of cells instead of a Step. It also points out possible errors when comparing between Range variables.
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-04-17 18:06 +0000
---

One of the interesting things about the For~Next Loop in VBA is the Step.
```
For counter [ As datatype ] = start To end [ Step step ]
    [ statements ]
    [ Continue For ]
    [ statements ]
    [ Exit For ]
    [ statements ]
Next [ counter ]
```
Step defaults to 1, but Step 2 will cause the loop to run while incrementing the counter variable by 2, and Step -1 will cause the loop to run in reverse, decrementing by 1. 
```
For index As Integer = 1 To 5
    Debug.Write(index.ToString & " ")
Next
Debug.WriteLine("")
' Output: 1 2 3 4 5

For number As Double = 2 To 0 Step -0.25
    Debug.Write(number.ToString & " ")
Next
Debug.WriteLine("")
' Output: 2 1.75 1.5 1.25 1 0.75 0.5 0.25 0
```
However, For Each~Next, which iterates over the objects in a collection, does not have a Step. For example, you can't iterate over the range of cells A1:A100, skipping even or odd rows. However, you can create such a loop with the Do Loop and Offset methods instead of For Each. The following loop iterates between A6 and A22, taking only the addresses of the even rows.
```
  Set rngBegin = Sheet1.Range("A6")
  Set rngEnd = Sheet1.Range("A22")
  Set rng = rngBegin
  
  Debug.Print rngBegin.Address
  Debug.Print rngEnd.Address
  step = 2
  Do
    Debug.Print rng.Address
    Set rng = rng.Offset(step, 0)
    If rng.Address = rngEnd.Address Then Exit Do
  Loop
```
This is off topic, but I should have written "If rng Is rngEnd Then Exit Do" instead of "If rng.Address = rngEnd.Address Then Exit Do".  There is no runtime error when executed, but it does not exit at rngEnd, i.e. A22, as expected.
The cell addresses of rng and rngEnd in the last iteration are both 'A22', but they are not actually the same object variable.  When declaring the object variables, we did the following
```
  Dim rng As Range
  Dim rngEnd As Range
```
These two variables are on the stack, but they will have different memory addresses. Therefore, although they may have the same cell address, 'A22', they will have different addresses, so they cannot be the same object.