teleren/devto huggingface dataset:
Sorting Algorithms
Tags: computerscience
Published: 2023-01-26 16:31:40

## Sorting Algorithm

is an algorithm used for rearranging a given array or list in a specific manner according to a comparison operators on the elements. The comparison operator is used to decide the new order of elements in the perspective data structure. 

Some of the most well-known sorting algorithms are: 

- Bubble Sort

- Selection Sort

- Insertion Sort 

- Merge Sort 

- Quick Sort 

- Heap Sort 

## Bubble Sort 
is one of the simplest sorting algorithms. Bubble sort works by repeatdly swapping the adjacent elements if they are in the wrong order. This algorithm is not advised for a large data sets, because of it's **high** time complexity. 

![Bubble Sort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ho9pmkmrcd3lzuvjhrb.gif)

## Selection Sort
Considering we're sorting a list/array in ascending order, selection sort sorts a list by repeatdly finding the minimum element from the unsorted part and shifting it to the beginning of the array. 
![Selection Sort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aw5vctf8w65j1m77h3jp.gif)

## Insertion Sort 
Just like Bubble Sort, insertion sort is one the simplest sorting algorithms. The array of list is split into two parts. Sorted and unsorted part. The values from the unsorted are separated picked and placed at the correct position in the sorted part. 
![Insertion Sort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rd32sipr180qowxjsyi.gif)

## Merge Sort 
A sorting algorithm that works by dividing an array into smaller subarrays. The subarrays are then sorted, and then merging the sorted subarrays back together to form the final sorted array. This process is repeated until the entire array/list is sorted. One of the main advantages of merge sort is the time complexity of O(n log n), which means it can sort large set of arrays relatively quickly and efficient.
![Merge Sort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e861ki1ykjn8y7p6hnum.gif) 

## Quick Sort 
Like merge sort, quick sort picks picks an element as a pivot and partitions the given array around the picked pivot. It partitions an array and calls itself recursively twice to solve the two resulting subarrays. Quick Sort is highly efficient for large sets of data with a time complexity of O(n2).
![Quick Sort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ancsv2em0pc5m43r4bp.gif)

## Heap Sort 
Similar to selection sort where we find the minimum element and place the minimum element at the beginning. This process is repeated until the entire array/list is sorted. Heap Sort is not very efficient sorting algorithm when working with highly complex data. It is also unstable, and might rearrange the relative order. 
![Heap Sort](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21hcx3lqrmqiaobr9a4r.gif)

## Conclusion 
Sorting Algorithm is a set of instructions that take an array or list as an input and arrange an item into a particular order. The sorts mostly in numerical or alphabetical order, and can be in ascending or descending order. 


Thank you! 
[Jonny](linkedin.com/in/jonnytilahun)
Create a Morse Encoder
Tags: opensource, tutorial, startup, luos
Published: 2023-01-26 16:30:00

🤔 Want to learn about Luos main API? Check out our tutorial on how to create a Morse encoder project! 

📹 [Follow along](https://www.youtube.com/watch?v=g9y6-SioMI4) as Viktoria shows you how to send a character through a serial interface of a Nucleo STM32F072RB board

📗 Read the [full tutorial](https://www.luos.io/tutorials/morse)
A little challenge in JavaScript (will be glad to read your solutions)
Tags: javascript, webdev, programming, productivity
Published: 2023-01-26 16:27:45

**Let's do a little challenge in JavaScript**
Write a function that takes two parameters 
-a string 
-a phrase
 and returns how many times this passed string occurred in the phrase 

`function occurences(str,phrase){
//returns how many times str occured in phrase (number)
}`

**answer in the comments i'll be reading each one of them**
String Type and String Literals in Solidity
Tags: solidity, ethereum, blockchain, web3
Published: 2023-01-26 16:20:13

Solidity supports both double quotation (") and single quote (') when referencing a string literal. It makes it possible to declare a variable of type String by providing the data type string.

```
pragma solidity ^0.5.0;

contract SolidityTest {
   string data = "test";
} 
```

In the above example, the string literal "test" is represented by the string variable data. Because string operations use more gas than byte operations, it is preferable to employ byte types rather than String operations wherever possible instead of String operations. Solidity includes built-in conversion between bytes and strings, as well as the other way around. In Solidity, we can quickly and efficiently assign a String literal to a byte32 type variable. Solidity treats it as if it were a byte32 literal.

```
pragma solidity ^0.5.0;

contract SolidityTest {
   bytes32 data = "test";
} 
```

Additionally, string literals also support the following escape characters:

- \<newline> (escapes an actual newline)

- \\ (backslash)

- \' (single quote)

- \" (double quote)

- \n (newline)

- \r (carriage return)

- \t (tab)

- \xNN (hex escape)

- \uNNNN (Unicode escape)


For more content, follow me on - https://linktr.ee/shlokkumar2303
What is ChatGPT?
Tags: tutorial, programming, openai
Published: 2023-01-26 15:56:19

Hello everyone, today we want know about new technology open ai ChatGPT.




**1.What is ChatGPT?**
ChatGPT (Chat Generative Pre-trained Transformer) is a chatbot launched by OpenAI in November 2022 which interacts in a conversational way.ChatGPT is a sibling model to InstructGPT, which is trained to follow an instruction in a prompt and provide a detailed response.


**2.What does ChatGPT chat do?**
ChatGPT's AI can program and write code, solve math equations, and generally generate any type of text-based resource. In this section, some of the most important and effective uses and applications of ChatGPT have been discussed.

- Solving programming problems
- Writing blog posts
- Information search
- Applicability of Chat GPT regarding all text


**3.Who Built ChatGPT?**
ChatGPT was created by San Francisco-based artificial intelligence company OpenAI.The CEO is Sam Altman, who previously was president of Y Combinator.


**4.Is ChatGPT free?**
Yes,currently


**5.How to use ChatGPT?**
To start using Chat GPT, we need to go to the OpenAI website and the ChatGPT [+] page and click on the "Try ChatGPT" option.

**6.What are the advantages of Chat GPT?**
Chatbot or Chat GPT conversation bot provides the possibility of conversation with artificial intelligence in a perfect and natural way.

**7.What are the disadvantages of ChatGPT?**
If you use ChatGPT a lot, you will notice certain patterns and terms that are repeated in the text. This may result in duplicate content or content that is structurally repetitive.




Thank you for reading this post.
please :   Like ❤️ , comment , subscribe 

[Reference1](https://blog.faradars.org/chatgpt-چیست/#مزایا_و_معایب_ChatGPT_چیست_؟)
[Reference2](https://www.searchenginejournal.com/what-is-chatgpt/473664/)
waec time table for 2023
Published: 2023-01-26 16:07:12

[https://multischolar.com/waec-timetable/](https://multischolar.com/waec-timetable/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle)
https://plaza.rakuten.co.jp/chenlee/diary/202301260000/
https://www.provenexpert.com/waec-f/
https://www.producthunt.com/@waecf1
https://www.divephotoguide.com/user/waecf/
https://wakelet.com/@waecf482
https://vocal.media/authors/waecf
https://www.lifeofpix.com/photographers/waecf/
https://seedandspark.com/user/waecf
https://rosalind.info/users/waecf/
http://phillipsservices.net/UserProfile/tabid/43/userId/195917/Default.aspx
https://app.roll20.net/users/11555461/waecf
https://speakerdeck.com/waecf
https://social.msdn.microsoft.com/Profile/waecf
https://camp-fire.jp/profile/waecf
https://plazapublica.cdmx.gob.mx/profiles/waecf/activity
https://www.metal-archives.com/users/waecf
https://storium.com/user/waecf
https://trabajo.merca20.com/author/waecf/
https://www.intensedebate.com/people/waecf
https://www.mifare.net/support/forum/users/waecf/
https://pinshape.com/users/2561771-waecf
http://foxsheets.com/UserProfile/tabid/57/userId/119010/Default.aspx
https://www.kompasiana.com/waecf
https://www.credly.com/users/waec-time-table-for-2023/badges
https://www.myminifactory.com/users/waecf
https://www.sqlservercentral.com/forums/user/waecf
https://www.longisland.com/profile/waecf
https://leanin.org/circles/waec-time-table-for-2023
https://guides.co/a/waec-time-table-fo/
https://myanimelist.net/profile/waecf
https://www.iheart.com/podcast/269-waec-time-table-for-2023-107872277/
Dockerizing a Django Application | Python.
Published: 2023-02-02 17:24:06

---
title: Dockerizing a Django Application | Python.
published: true
date: 2023-01-26 16:06:23 UTC
tags: 
canonical_url: https://carlosmv.hashnode.dev/dockerizing-a-django-application-python
---

In this article, we will build a container for a Django Application with Sqlite3 as a database using Docker. We are not going to build a Django Application from scratch. We will use a sample for this article.

You can clone the Django app from [this repository](https://github.com/carlosm27/django_authentication).

### Requirements

- Docker installed

- Git installed.

### Dockerfile

```
FROM python:3.11

RUN mkdir /code
WORKDIR /code
RUN pip install --upgrade pip
COPY requirements.txt /code/

RUN pip install -r requirements.txt
COPY . /code/

EXPOSE 8000

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

```

Here we write the instructions Docker needs to build our image.

### Building the image.

In the directory where is located the dockerfile, we run this command in our terminal.

```
docker build -t django-authentication .

```

The `docker build` command uses the Dockerfile to create a new container image.

As the Docker documentation says, the `-t` flag tags your image. Since we named the image `django-authentication`, we can refer to that image when we run a container.

The `.` at the end of the `docker build` command tells Docker that it should look for the `Dockerfile` in the current directory.

### Running the container

```
docker run -dp 8000:8000 django-authentication

```

We use the `-d` flag to run the new container in detached mode (in the background). We also use the `-p` flag to create a mapping between the hosts port 8000 to the containers port 8000. Without the port mapping, you wouldnt be able to access the application

After a few seconds, we will be able to go to `localhost:8000/home/` and see this page:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674495562396/ebe443f6-1d1c-4be7-8016-d37142c64b8e.png)

### Conclusion

First time I dockerize a Django application. It wasn't hard, the docker documentation offers helpful samples to use. This application uses Sqlite3 as a database, so using a container was enough. But if we want to use Postgres as a database, we have to use Compose, because we have to build a container for Postgres, and Compose is used for building and running multi-containers docker applications.

Thank you for taking the time to read this article.

If you have any recommendations about other packages, architectures, how to improve my code, my English, or anything; please leave a comment or contact me through [**Twitter**](https://twitter.com/Carlos_marcv), or [**LinkedIn**](https://www.linkedin.com/in/carlos-marcano-a2135a134/).

### References

- [Containerize an application](https://docs.docker.com/get-started/02_our_app/)

- [Django samples](https://docs.docker.com/samples/django/)
How to mock a decorator in Python
Tags: python, testing, programming
Published: 2023-01-26 15:58:31

**Programming is the art of adding bugs to an empty text file.**

Mastering `unittest.mock` capabilities of Python to prevent these bugs, is another art of its own. And one of the trickiest move of them all is how to mock a decorator, such as it doesn't go in the way of the function you want to test.

Let's consider the following function to test:


```python
### module api.service
from utils.decorators import decorator_in_the_way

@decorator_in_the_way
def function_to_be_tested(*args, **kwargs):
    # do something
    ...
```

The problem here is to write a unit test for `function_to_be_tested` without invoking the decorator (which would make your test fail)

Problem: it's not possible to `@patch` the decorator above the test function, as it is too late: in Python functions are decorated at module-loading time. So this:

```python
### file service_test.py

from unittest.mock import patch
from .service import function_to_be_tested

def mock_decorator = ...


@patch("api.service.decorator_in_the_way", mock_decorator)
def test_function_to_be_tested():
    result = function_to_be_tested()
    assert ...
```

... simply does not work. The patched decorator will simply be ignored, as the function to be tested already has been instrumented with the original one.

Fortunately, there is a workaround. The idea is to patch the decorator **before** the module to test is loaded. Of course the requirement is that the decorator and the function to test **don't belong to the same module**

The following example will work:

```python
### file service_test.py
from unittest.mock import patch
from functools import wraps

def mock_decorator(*args, **kwargs):
    """Decorate by doing nothing."""
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            return f(*args, **kwargs)
        return decorated_function
    return decorator

# PATCH THE DECORATOR HERE
patch('utils.decorators.decorator_in_the_way', mock_decorator).start()

# THEN LOAD THE SERVICE MODULE
from .service import function_to_be_tested

# ALL TESTS OF THE TEST SESSION WILL USE THE PATCHED DECORATOR 

def test_function_to_be_tested():
    result = function_to_be_tested() # uses the mock decorator
    assert ...

```

Hope this helps !


I’m Matthieu, data engineer at Stack Labs.
If you want to [join an enthousiast Data Engineering or Cloud Developer team](https://www.welcometothejungle.com/fr/companies/stack-labs), please contact us.
Will ChatGPT replace software engineers anytime soon?
Tags: chatgpt, ai, search, programming
Published: 2023-01-26 15:53:05

In the [previous article](https://www.centdam.com.ng/blog/post/what-is-chatgpt-how-it-work-and-its-limitations/), we discussed ChatGPT, how it works and its limitations. The methodology behind ChatGPT has been described in detail. Now, the question is: Will ChatGPT replace software engineers?

First, let's look at the potential applications and limitations; then we will be able to answer the questions above.

ChatGPT potentials
There are many possible uses for ChatGPT. Here are a few instances:

Writing Code:
Syntactically sound code can be produced by ChatGPT, which may even be able to resolve a particular issue. The time spent writing boilerplate code or creating code snippets might be reduced as a result.

Creating Chatbots:
Chatbots that can have natural conversations with users can be made using ChatGPT. Various contexts, like customer service or online education, may find this useful.

Content generation:
Text can be generated using ChatGPT for a variety of uses, including news articles, social media posts, and advertising.

 

ChatGPT limitations
Despite its impressive capabilities and accuracy training, the model has not yet received enough training because this is a brand-new technology. As a result, the AI chatbot might give false information. As a result, StackOverflow banned ChatGPT, stating that "posting answers generated by ChatGPT is substantially harmful to our site and to users who ask for or search for correct answers" because of the low average rate of correct answers from ChatGPT.

 

Why Chatgpt will not replace software engineers
Having seen the capabilities and limitations of ChatGPT, you will understand that it lacks some important factors that are essential in software engineering. This factor includes:

Limitation in creativity:
ChatGPT can only use the knowledge and information that it has been taught and it is unable to generate new ideas or engage in creative thinking.

Understanding:
The meaning of the words it generates and the context in which they are used cannot be understood by ChatGPT. This means that instead of comprehending the underlying concepts, it is restricted to producing text based on patterns it has discovered from its training data.

Constraints in the real world
Budgets, deadlines, and technical limitations are all examples of real-world restrictions that ChatGPT is unaware of and is unable to take into account when generating text or code.

So, will ChatGPT eliminate the need for software developers?
NO.

ChatGPT can produce code that is syntactically sound and may even be able to resolve a specific issue, but it is unable to comprehend the limitations of software development in the real world. The expertise and knowledge that a human software engineer brings to the table cannot be replaced by ChatGPT.
Visit www.centdam.com.ng/blog for more
SuperJSONatural -> Faster & binary serialization!
Tags: javascript, opensource, algorithms, performance
Published: 2023-01-26 15:34:03

## Truly one of the world faster serializer/parser in JS and within < 10 kB only!

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

> The great advantage is its ease of use while it supports all JS TypedArrays! And this is great for canvas' imageData and so on...

It was annoying to us, JSON doesn't support parsing TypedArray such as data of canvas' imagedata... It doesn't...

```JavaScript
import SuperJSONatural from "superjsonatural"; // In node.js
/* OR */
var SuperJSONatural = window.SuperJSONatural; // Use the minified version for browser

var data = {
    name: "Prof. Bernice Champlin Jr.",
    male: true,
    female: false,
    timestamp: Date.now(),
    items: Uint8Array.of(0, 55, 77, 65, 9, 1, 1, 1, 1, 200, 44, 22, 9, 0),
    email: "stevie.conn@luettgen.com",
    phone: 3476774277,
    description: "Et voluptatem incidunt repellat. Qui laboriosam quis accusamus optio sed. Non qui qui quasi aliquid.",
	other: {
		ANARRAY: ["lol", 99],
		prop: 992,
		str: "str",
		items: Uint32Array.of(999, 97219)
	}
};

// It will be a string when encoded, always
var encoded = SuperJSONatural().stringify(data);
var decoded = SuperJSONatural().parse(encoded);
console.log(data, encoded, decoded)

// NEW!!! It will be a Uint8Array (Like a bytes using an array buffer)
var encoded = SuperJSONatural().pack(data);
var decoded = SuperJSONatural().unpack(encoded);
console.log(data, encoded, decoded)

```

Links: [DEMO/BENCHMARK](https://codepen.io/vipertechofficial/pen/jOpyNZy), [NPM package](https://www.npmjs.com/package/superjsonatural)

## How it works?

### Stringify/Parse

It will simply convert your typed array to [base64](https://en.wikipedia.org/wiki/Base64) and prefix the resulting string with: "$TA_xx_B64$" where "xx" are a simple id to know to which kind of typed array the bytes encoded into base64 will be parsed.

### Pack/Unpack

This one is a bit more complex, it encode everything as JSON just as usual and encode this stringified object into a Uint8Array (AKA: a bytes array or a buffer) with the first two bytes being the length of the encoded JSON after the first two bytes, ...

This is because (and yes there is a little change that occurs before stringifying the object), **when it encounter a TypedArray**, it stores which kind of typed array it is, and both the **start and stop offset** of the buffer that will contains all TypedArray's bytes concatenated. This second part is appended to the JSON encoded into bytes and that's it, we also achieve to decode it quite fast, on some realistic tests, we're as up as twice faster than [CBOR-X](https://github.com/kriszyp/cbor-x) the fastest (I think) robust engine of its kind on the web, until our hybrid model was born.

Other modules: https://www.npmjs.com/~asaitama
PulsarAdmin CLI to GUI,Help developers quickly operate pulsar cluster.
Tags: pulsar, java, idea
Published: 2023-01-26 15:29:15

## Features:

- multiple clusters support
- pulsar-admin brokers
- pulsar-admin broker-stats
- pulsar-admin bookies
- pulsar-admin clusters
- pulsar-admin namespaces
- pulsar-admin ns-isolation-policy
- pulsar-admin tenants
- pulsar-admin topics
- pulsar-admin resourcegroups
- pulsar-admin resource-quotas
- pulsar-admin proxy-stats

## Download:

- You can download <a href="https://plugins.jetbrains.com/plugin/20887-pulsaride">Pulsaride</a>at the plugin marketplace of JetBrains

![Pulsaride](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ihojauz9huumpguk75m.png)
Kafka CLI to GUI,Help developers quickly operate Kafka cluster
Tags: kafka, idea, java
Published: 2023-01-26 15:23:56

## Features:

- multiple clusters support
- brokers management
- kafka-acls
- kafka-configs
- kafka-console-consumer
- kafka-console-producer
- kafka-consumer-groups
- kafka-leader-election
- kafka-reassign-partition
- kafka-topics

## Download:

- You can download <a href='https://plugins.jetbrains.com/plugin/20111-kafkaide'>Kafkaide</a> at the plugin marketplace of JetBrains

![Kafkaide](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dexxitwfmnew1o1z12qv.png)
How to Solve REVERSING A STRING JavaScript (SOLVED) | Coding Challenge - Solution For Beginners
Tags: algorithms, javascript, tutorial, beginners
Published: 2023-01-26 15:23:54

Hi,
I have put together a well detailed tutorial video on **How to reverse a string in JavaScript (especially for beginners)**

In this video I will be breaking concepts down for **easier understanding.** I ensured to not just solve it but teach you in a way you’ll never forget it. My teachings are sound enough to discourage anyone from memorizing codes. For certain, you will definitely understand what I teach and know it for life.
[https://youtu.be/U1ucX30TcBo](You can View this video tutorial here https://youtu.be/U1ucX30TcBo)