teleren/devto huggingface dataset:
Using SQLite with Ecto in a Phoenix App
Tags: elixir, phoenix, sqlite, beginners
Published: 2023-01-26 06:57:37

---
title: Using SQLite with Ecto in a Phoenix App
published: true
description: Phoenix (or Ecto) defaults PostgreSQL as their database of choice. What if you want something simple like SQLite?
tags: Elixir, Phoenix, SQLite, Beginner
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-01-26 04:05 +0000
---

Phoenix (or Ecto) defaults PostgreSQL as their database of choice. What if you just want to do something simple or just start learning Phoenix and too lazy to set up a Postgres server (like me)?

After setting up your Erlang and Elixir in your machine, you need to install `hex`. If you haven't had it installed, run this: 
```Shell
mix local.hex
```
Then you need to install Phoenix application generator:
```Shell
mix archive.install hex phx_new
```
To kick start your Phoenix project, run this line:
```Shell
mix phx.new sqlite_app --database sqlite3
```
Now you're ready to develop your next awesome Phoenix project with SQLite.


## What Happened?
The `--database` flag tells the generator that we want to use SQLite in our project and added `ecto_sqlite3` as a dependency so we can use it with `Ecto`.

Actually, Phoenix is well documented (and from what I heard, Elixir projects are generally well documented). You can find most of what you want to do when kickstarting your Phoenix project in [this hexdocs page](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html).

Now run:
```shell
mix ecto.create
```
to create your SQLite database file in your project direcory.

I hope this helps and hope you have some fun times ahead!
Data Science: %%timeit in python
Tags: python, beginners, datascience, jupyter
Published: 2023-01-26 06:30:00

## Youtube Short
{% youtube DCSzxDiteIc %}

In Python, the `%%timeit` magic command is a handy tool for measuring the execution time of small bits of code. It can be used in interactive environments like Jupyter notebooks.

To use `%%timeit`, you simply place it at the beginning of a cell in a Jupyter notebook, followed by the code you want to measure the execution time of. `%%timeit` will then run the code multiple times and return the fastest run time among all the runs.

![timeit code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rybkkmpu6bwn0et2wjy0.png)

The output shows the time it took to run the code in microseconds, as well as the mean and standard deviation of the run times across multiple runs.

![cell output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lq5hbjxe7vtl3x41ady5.png)

The number of runs and loops can be adjusted by passing arguments to `%%timeit`.

![timeit with arguments](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dtbs9lc6wf69voyill6u.png)



In this example, `%%timeit` will run the code 10 times and do 100 loops per run.

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



`%%timeit` is a useful tool for identifying performance bottlenecks in your code and optimizing the most heavily used sections. It can be especially helpful for comparing the performance of different algorithms or implementations.
Draw Vertical Line Flutter
Tags: flutter, dart, mobile, webdev
Published: 2023-01-26 06:28:26

Sometimes we need vertical and [horizontal lines](https://ammarjaved.com/horizontal-line-flutter) to have separate sections in our app.
We can draw vertical line using the below code 
`VerticalDivider(
    indent: 10,
    thickness: 1,
    width: 5,
    color: Colors.yellow,
    endIndent: 10,
),`
In the above example, we set the color of the line to yellow, the thickness is 1, etc for drawing the vertical line.
C++ O'rganamiz 4-dars
Tags: programming, tutorial, cpp
Published: 2023-01-26 05:54:14

## Salom biz bugungi darsimizda char o'zgaruvchisi va sonlarni % bo'lishi o'rganamiz.
Har doimgidek [replit.com](url) dan foydalanamiz

> Char o'zgaruvchisi

**Char o'zgaruvchisi o'zida bitta belgi saqlaydi** u belgi raqam,harf, ?!/\{" belgilari bo'lishi mumkin.

```cpp
char => character = bitta belgi saqlash uchun.
```
Char o'zgaruvchisi ichiga belgilarni bittali qo'sh tirnoq ichida saqlash kerak 

```cpp

int main() {
char belgi  = 'D';
  //char ning ichiga faqat bitta belgi yozasiz
}
```
Char va Int o'zgaruvchilari bir biri bilan bog'liq.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2lsif8nad9nlj3e7dl6g.png
)
Int ning ichiga 'A' harfini yozib char ning ichiga 65 ni yozganimizda ularning joyi almashib qoldi, char va int o'zgaruvchilarining o'z ro'yxati bor.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtk4jq1mzggyi3tf53ii.png)
Ro'yxatda 65 raqami katta A harfini anglatar ekan shuninig uchun char ga raqam yozganimixda unda ro'yxatdagi o'sha raqamni bildiradigan harf chiqadi int ga esa xarf yozsak ro'yxatdagi raqam chiqadi.
Endi biz % o'rganamiz % belgisi qodlash tilida qoldiqni qorsatada butub sonni esa uchirib tashlaydi masalan

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o9vnhbfbbmixmoa3o44x.png)
Birinchi qatorda 10 ni 3 ga bo'lganimizda qoldiqni olib tashlab 3 chiqardi, 2 qatorda 10 % 3 qilganimizda qoldiq 1 ni qorsatdi yani . dan keyingi sonni bundan foydalanip biz sonlardan eng ohirgi, o'rtadagi, birinchi, raqamlarni o'zini console ga chiqarshimiz mumkin 

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

> Etibor uchun raxmat
 @dawroun
Multi-process vs Multi-threading
Published: 2023-01-26 05:43:50

Multi-process refers to the execution of multiple processes at the same time, where each process has its own memory space and runs independently of the others. This allows for true parallelism and can be useful for tasks that are computationally intensive or need to run concurrently for other reasons. However, communication between processes can be more difficult and resource-intensive.

Multi-threading, on the other hand, refers to the execution of multiple threads within a single process. These threads share the same memory space and can easily communicate with each other. This makes inter-thread communication more efficient and can be useful for tasks that are more IO-bound. However, true parallelism may not be achieved as multiple threads may not be executed simultaneously on different cores.

In terms of design, SQL databases are often used for transactional data where ACID (Atomicity, Consistency, Isolation, Durability) properties are required. SQL databases are well suited for complex queries and reporting. NoSQL databases, on the other hand, are more suited for storing large amounts of unstructured or semi-structured data, scalability and performance under high loads.

In terms of use case, SQL databases are often used in enterprise applications, online transaction processing systems and data warehousing applications. NoSQL databases are often used in real-time big data applications, content management systems, and other web-scale applications.

| Multi-process   | Multi-thread |
|------------|----------|
| Each process has its own memory space and resources	        | Threads share the same memory space and resources
      |
| Inter-process communication can be more complex and slower	      | Inter-thread communication is faster and simpler
    |
| Can take advantage of multiple CPUs or cores      | Limited by the number of cores available    |
| Can handle multiple tasks with different priorities more effectively     | Prioritization of threads may be more difficult  |
| More memory overhead    | Less memory overhead  |
| Better isolation and protection against errors or crashes     | Error or crash in one thread can affect other threads  |
Create icons from png/jpg/webp files online
Published: 2023-01-26 05:25:03

To create an icon from a PNG, JPG, or WEBP image, you can use an image editing software such as Adobe Photoshop or GIMP. The process typically involves the following steps:

Open the image in the software.
Resize the image to the desired size for the icon.
Save the image in an appropriate format, such as ICO for Windows icons or ICNS for Mac icons.
Optionally, you can also add multiple sizes of the icon for different devices.
You can also use online tool like [https://toolsincloud.com/ico-converter](https://toolsincloud.com/ico-converter) which convert your image to ico, icns, gif, jpg, png, bmp, tiff, webp.

Alternatively, you can also use a specialized icon creation software, such as IcoFX or Axialis IconWorkshop, which are specifically designed for creating icons.
SQL vs NoSQL
Tags: database, mongodb, mysql, scalability
Published: 2023-01-26 05:36:31

SQL databases, also known as relational databases, use a structured query language (SQL) for defining and manipulating the data. The data is organized into tables, with each table consisting of rows and columns. SQL databases are best suited for situations where the data has a clear structure and relationships between tables need to be defined. Examples of SQL databases include MySQL, PostgreSQL, and Microsoft SQL Server.

NoSQL databases, on the other hand, do not use SQL and do not have a fixed schema. Instead, they use a variety of data models such as key-value, document, columnar, and graph. NoSQL databases are often used in situations where the data structure is not clear or may change frequently, such as in big data and real-time applications. Examples of NoSQL databases include MongoDB, Cassandra, and Redis.

The main advantage of SQL databases is their ability to handle complex queries and transactions. They also provide a high level of data consistency and are suitable for applications that require strict data integrity. On the other hand, NoSQL databases are more flexible and can handle a larger volume of unstructured data. They also provide better scalability and are suitable for applications that require high performance and availability.

In general, SQL databases are used for transactional systems, while NoSQL databases are used for data warehousing and big data analytics. SQL databases are also used in applications where data consistency is important, while NoSQL databases are used in applications where performance and scalability are more important.
Python Global Interpreter Lock (GIL)
Published: 2023-01-26 05:32:44

The Global Interpreter Lock (GIL) is a mechanism used in the CPython implementation of the Python programming language to ensure that only one thread executes Python bytecode at a time. This lock is necessary because CPython, the reference implementation of Python, is not thread-safe, meaning that multiple threads can potentially interfere with each other and compromise the integrity of an application.

The GIL has both pros and cons. One of the main advantages of the GIL is that it simplifies memory management and object lifetime, making it easier for developers to write correct and stable Python code. Additionally, the GIL can also improve performance for single-threaded programs or programs that spend most of their time performing I/O operations.

On the other hand, the GIL can also have a significant negative impact on the performance of multi-threaded Python programs, particularly those that perform CPU-bound operations. Because only one thread can execute Python bytecode at a time, multiple threads may spend a lot of time waiting for the GIL to be released, leading to decreased performance and increased CPU utilization.

Here is an example of how the GIL can affect the performance of a multi-threaded Python program:

```
import threading

def count():
    x = 0
    for i in range(1000000):
        x += 1

threads = []
for i in range(10):
    thread = threading.Thread(target=count)
    thread.start()
    threads.append(thread)

for thread in threads:
    thread.join()

print("Done.")

```

In this example, the `count` function is called by 10 different threads, each of which increments a shared variable `x` 1 million times. Due to the GIL, only one thread can execute the function at a time, which may lead to decreased performance and increased CPU utilization.

In conclusion, the Global Interpreter Lock (GIL) is a mechanism used in the CPython implementation of Python to ensure that only one thread executes Python bytecode at a time. While it can simplify memory management and improve performance for single-threaded programs or programs that spend most of their time performing I/O operations, it can also have a significant negative impact on the performance of multi-threaded Python programs, particularly those that perform CPU-bound operations.
How To Add AJAX Loader In jQuery
Tags: javascript, jquery, ajax, loader
Published: 2023-01-26 05:30:00

In this article, we will see how to add an ajax loader in jquery. Here, we will learn to add a loading spinner before submitting the ajax call in jquery. 

In ajax call when you can submit the data or form at that time we need to display the progress of submitting data so the user can easily understand.

In the loading spinner, you can use font awesome, spinning GIF, image, or custom spinner design as per your theme.

So, let's see jquery add a loading spinner in ajax call, jquery ajax loading spinner example, show loader on form submit jquery, how to add loader in ajax call.
Make a Finals Calculator
Published: 2023-01-26 05:23:50

## Before you read

This article is to take notes and to use them in the future when writing about my life to go to college and high school.

If you are interested about a boring teenager's life, read on.

Or you could just leave.

## Inspiration and App

For about a few pages, I will be talking about my app's inspiration and how it came to be.

Web App: https://finalscalcu.web.app
Play Store App: https://play.google.com/store/apps/details?id=app.web.finalscalcu.twa

## 🤔 **Inspiration - Problem**

A few months back, in December, it was the Finals term and a lot of my Middle School friends were struggling.

Not everybody is perfect, so many of the students get a few points taken away from their projects as well as their midterms.

Few of my friends were very curious how much they needed to get in their finals to get at least A or sometimes B.

## 💡 **Inspiration - Ideas**

They asked people very good at math, including me, to calculate their scores.

One of my classmates and I calculated all of my friends score, but while doing so, I realized the process could be automated.

So, I decided to make an app in Svelte the following day to help my friends.

## 👍 **Reactions**

A lot of my friends complimented on my app.

They said it was useful, less stressful to study, fast, and easy to use.

## 👤 **Users**
 
This app is actually my most successful one so far (by users) though it is far the simplest to create.

During finals term, there were over 200 people per day.

Though the app is used once a year because the finals happen once a year.

## Theory

My theory, before making the app was the following:

1. The way you calculate the lowest score to get A is by making sure the overall score was higher than or equal to 89.5%
2. The app will ask for inputs of midterm, the percentage of midterm and finals respectively, and the projects score
3. Then, it will display a panel that shows how much score is need to get at least A, B, C, e.t.c.

## Analytics

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

As seen above, the most popular time was the Korean Middle School Finals Exam Week.

The little surge after the Exam Week was after posting this Dev.to post and making the play store app.

## Links

[My GitHub](https://github.com/HyunseungLee-Travis)
[Repo](https://github.com/HyunseungLee-Travis/FinalsCalcualtor)
Producing dash streming using ffmpeg and bento4
Tags: ffmpeg, hls, dash, tutorial
Published: 2023-01-26 05:21:04

Dash is the open-source equivalent of Apple's HLS technology, used for the same purpose: to deliver live videos or on-demand videos over the web, dynamically changing the quality based on the internet connection of the ﬁnal user.

Following formula will produce a multi-bit-rate version of our master with h264 constrained encoding

```bash
ffmpeg -i input.mp4 -c:v h264 -crf 22 -tune film -profile:v main -level:v 4.0 -maxrate 5000k -bufsize 10000k -r 25 -keyint_min 25 -g 50 -sc_threshold 0 -c:a aac -ar 44100 -b:a 128k -ac 2 -pix_fmt yuv420p -movflags +faststart 1080.mp4 -s 1280x720 -c:v h264 -crf 24 -tune film -profile:v main -level:v 4.0 -maxrate 2500k -bufsize 5000k -r 25 -keyint_min 25 -g 50 -sc_threshold 0 -c:a aac -ar 44100 -b:a 128k -ac 2 -pix_fmt yuv420p -movflags +faststart 720.mp4 -s 854x480 -c:v h264 -crf 30 -tune film -profile:v main -level:v 4.0 -maxrate 1250k -bufsize 2500k -r 25 -keyint_min 25 -g 50 -sc_threshold 0 -c:a aac -ar 44100 -b:a 96k -ac 2 -pix_fmt yuv420p -movflags +faststart 480.mp4 -s 640x360 -c:v h264 -crf 33 -tune film -profile:v main -level:v 4.0 -maxrate 900k -bufsize 1800k -r 25 -keyint_min 25 -g 50 -sc_threshold 0 -c:a aac -ar 44100 -b:a 96k -ac 2 -pix_fmt yuv420p -movflags +faststart 360.mp4 -s 320x24 -c:v h264 -crf 36 -tune film -profile:v main -level:v 4.0 -maxrate 625k -bufsize 1250k -r 25 -keyint_min 25 -g 50 -sc_threshold 0 -c:a aac -ar 22050 -b:a 64k -ac 1 -pix_fmt yuv420p -movflags +faststart 240.mp4
```
> All tags described in my previous blog

#### Create multi-bitrate DASH playlist with Bento4 
In order to create a multi-bitrate `DASH` playlist with `Bent04`, we need to perform 2 separate action. 
* First one dedicated at the fragmentation of each file(version) of our master video, `mp4fragment` command will responsible for this task

> Sample command:
> ```bash 
mp4fragment 1080.mp4 1080-f.mp4
```
> `mp4fragment`: this will launch Bento4's Mp4 Fragment tool
> `1080.mp4`: this is the input ﬁle to be fragmented
> `1080-f.mp4`: this is an example output's ﬁlename

Now we have to repeat this command for each version of our master video

```bash
mp4fragment 1080.mp4 1080-f.mp4&&mp4fragment 720.mp4 720-f.mp4&&mp4fragment 480.mp4 480-f-.mp4&&mp4fragment 360.mp4 360-f.mp4&&mp4fragment 240.mp4 240-f.mp4
```
#### Generate DASH playlist 
In order to generate a DASH playlist with our segmented mp4s, we will use another tool from Bento4 called `mp4dash` using following command:

```bash
mp4dash 240-f.mp4 360-f.mp4 480-f.mp4 720-f.mp4 1080-f.mp4
```
This will generate a folder titled "output" which will
contain 2 separate folders: one called "audio" dedicated for the audio streaming and another called "video" containing the segments of each of the 5 variations of our master video. And finally we will find the "stream.mpd" file which is the DASH playlist itself.
How to pass an app review and start selling what you created? [video course]
Tags: javascript, tutorial, beginners, react
Published: 2023-01-26 05:00:37

### Hi!👋 Today, we're posting the last episode of our course. 

Let's say you responded to some of our [app requests](https://developers.livechat.com/app-ideas/?utm_source=dev.to&utm_medium=referral), created and deployed your app – the last thing you need to do is to get your app through app review. How to do it successfully?

From the movie below, **you'll learn the details of the app review process in the LiveChat Developer Program.** With this knowledge, you'll not only be able to pass the review seamlessly, but also, you'll know how to make your app the best of the best and thrill your future customers with the quality of your work.

Check it out!

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

Check out the previous episodes of our course!

[Lesson 1: Plan out the app development](https://www.youtube.com/watch?v=ncKVOy2OSbw)

[Lesson 2: LiveChat API in practice](https://www.youtube.com/watch?v=HDto0LYLYSg)

[Lesson 3: Deploying your app](https://www.youtube.com/watch?v=lGPQkIF34NY)
Differences and Benefits of Using 'px' vs 'em' in CSS Styling
Tags: css, webdev, html, beginners
Published: 2023-01-26 04:24:54

In CSS, "px" (pixels) and "em" (ems) are both units of measurement used to specify the size of text, images, and other elements on a web page. The main difference between the two is that "px" is an absolute unit of measurement, while "em" is a relative unit of measurement.

When using "px", the size of an element is fixed and will not change based on the user's device or browser settings. For example, if an element is set to have a font size of 16px, it will always be displayed at 16 pixels on the user's screen, regardless of the user's device or browser settings.

On the other hand, when using "em", the size of an element is relative to the size of the parent element's font. For example, if an element is set to have a font size of 1em, it will be displayed at the same size as the parent element's font. So if the parent element's font is 16px, the child element will also be displayed at 16px. This can be useful if you want to create a responsive design that adapts to the user's device or browser settings.

Here is an example of using "px" and "em" in CSS:

```css
/* Using "px" */
h1 {
  font-size: 36px;
}

/* Using "em" */
h2 {
  font-size: 2em;
}
```
In general, "px" is a better choice for designs that require precise control over the size of elements. "px" is also the preferred choice for elements that need to be a specific size, such as images or buttons. On the other hand, "em" is a better choice for designs that need to be responsive and adapt to the user's device or browser settings.

###Conclusion
In summary, "px" is a better choice for designs that require precise control over the size of elements, and "em" is a better choice for designs that need to be responsive and adapt to the user's device or browser settings.
Para que servem testes e quais são seus principais tipos?
Published: 2023-01-26 03:41:18

Os testes de software são uma parte importante do desenvolvimento de software, eles ajudam a garantir que o software esteja funcionando corretamente.

Existem vários tipos de testes de software, porem 3 tipos se destacam, sendo eles:

- Testes de integração
- Testes unitários
- Testes funcionais

**Testes de Integração** 
Testes de integração são usados para testar como diferentes módulos ou componentes de um sistema se comunicam entre si. 
Eles são geralmente realizados após os testes unitários para garantir que todos os componentes estejam trabalhando corretamente juntos. Um exemplo de teste de integração seria testar se uma aplicação web está corretamente acessando uma base de dados.

**Testes Unitários**
Testes unitários são usados para testar cada componente individualmente, garantindo que ele esteja funcionando corretamente. Eles são realizados antes de os testes de integração para garantir que todos os componentes individuais estejam funcionando corretamente antes de serem testados juntos. Um exemplo de teste unitário seria testar se uma função matemática específica está calculando corretamente.

**Testes Funcionais**
Testes funcionais são usados para testar se o software está realizando as tarefas para as quais foi projetado. Eles geralmente são realizados após os testes de integração e testes unitários para garantir que o software esteja funcionando corretamente. Um exemplo de teste funcional seria testar se uma aplicação web está permitindo que os usuários efetuem login corretamente.

Em resumo, os testes de integração testam a comunicação entre módulos ou componentes, os testes unitários testam cada componente individualmente e os testes funcionais testam se o software está realizando as tarefas para as quais foi projetado. É importante realizar todos os três tipos de testes para garantir que o software esteja funcionando corretamente.