teleren/devto huggingface dataset:
aerich migration package for Tortoise ORM
Tags: python, aerich, orm, async
Published: 2020-08-08 11:18:35

---
published: true
title: aerich migration package for Tortoise ORM
tags:
- 'Python' 
- 'aerich'
- 'orm'
- 'async'
---

## Aerich a migration module for Tortoise ORM

> original post in https://skamalakannan.dev/posts/aerich-tortoise-migration/

Async programming is getting more popular with Python in recent years. From [Python 3.4](https://docs.python.org/3/whatsnew/3.4.html), we have native async support. Currently, there are not many ORMs (Object Relation Mappers) that support async. One such notable ORM is Tortoise ORM. But it does not support migration features.

[aerich](https://github.com/long2ice/aerich) package adds migrations support to [Tortoise ORM](https://github.com/tortoise/tortoise-orm).  It works well with MySQL. I am yet to test with SQLite and PostgreSQL, will check and post findings. 

> We need Tortoise ORM version > 16.2 or above for aerich.

### How it works

aerich maintains old_models.py file to which keeps tracks of last changes. Old models and current models compared, and if there are changes, respective SQL commands will be for upgrading and reverting. 

#### aerich can be installed through pip

```bash
pip install aerich
```

Configuring aerich in the application pretty easy.  we need to configure the TortoiseORM models.

* We need to add "aerich.models" in Tortoise ORM configuration dict. It will create a table called aerich to capture the history of migrations.    
```python
TORTOISE_ORM = {
        "connections": {
            "default": "mysql://user:test_pwd@localhost:3306/communication?charset=utf8mb4"
            },
        "apps": {
            "models": {
                "models": ["app.models", "aerich.models"],
                "default_connection": "default",
            },
        }
    }
```
* We can initiate aerich with the below command and it will initiate migrations for the application.
```bash
    aerich init -t settings.TORTOISE_ORM
```
    * *aerich.ini* -  config file maintains aerich configurations.
    * *migrations folder* - to capture all migrations. 

* To create initial migration files, the below creates initial migrations if not exists. 
```bash
   aerich init-db
```
    * It creates JSON file with timestamp with initial SQL commands and 
    * old_models.py - keeps tracks last applied changes. 

The module provides the following commands.

* ***migrate*** - compares the current models with old models and creates SQL query commands.
* ***upgrade*** - applies all unapplied migrations to the database.
* ***downgrade*** - reverts the last applied migrations. 
* ***history*** - lists all applied migrations. 
* ***heads*** - list unapplied migrations


to clear all migrations, 

* truncate the aerich table
* remove models folder under migrations.

aerich is a promising module for tortoise ORM.
Postwoman is changing name 🛸
Tags: webdev, javascript, watercooler
Published: 2020-08-08 11:15:22

### **Hey all :wave:**
**Postwoman is changing name.**
Our new identity aligns with our new focus — to provide the [best open source testing suite in web](https://github.com/hoppscotch/hoppscotch).

Towards that goal, we are thrilled to announce that `v2` will have a new name and domain.

{% comment 13ak9 %}

---

**Update: 16th August 2020**

### **Postwoman is now Hoppscotch 🎉**

{% cta https://github.com/hoppscotch/hoppscotch %} GitHub → {% endcta %} {% cta https://hoppscotch.io/ %} Web app → {% endcta %}

Special thanks to @ben (co-founder DEV.to) for suggesting this name 👏.

{% comment 13apm %}

{% comment 13apo %}
Launch EC2 instance in AWS
Tags: aws
Published: 2020-08-06 15:39:55

1: Login in to AWS console
2: Search for EC2(Virtual servers in the cloud) click on EC2
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/a6er1l8gz9i5qkoyd5gx.png)

3: Click on Launch instance.
4: To launch EC2 Instance in AWS its 7 steps work flow.
Step 1: Choose an Amazon Machine Image (AMI)
Let say we want to use Amazon Linux 2 AMI 64 bit.Click on Select.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lyfpstk2ky53vd4wzuog.png)

Step 2: Choose an Instance Type
By default it will be on General Purpose (free tier eligible), you can choose others as well but they all are chargeable.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tjcc3jlcoc3n74vz5a0l.png)

Step 3: Configure Instance Details
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ucyuljxcw9h5kvui602a.png)

Step 4: Add Storage 
Your instance will be launched with the following storage device settings. You can attach additional EBS volumes and instance store volumes to your instance, or edit the settings of the root volume. You can also attach additional EBS volumes after launching an instance, but not instance store volumes.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tf5uk9dp9ecd3onwv4vd.png)

Step 5: Add Tags
A tag consists of a case-sensitive key-value pair. For example, you could define a tag with key = Name and value = Webserver.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0xrwqq9ns4iapk4vqyq7.png)

Step 6: Configure Security Group
A security group is a set of firewall rules that control the traffic for your instance. On this page, you can add rules to allow specific traffic to reach your instance.
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xjnngriovi6ozguqve66.png)

Step 7: Review Instance Launch
Please review your instance launch details. You can go back to edit changes for each section. Click Launch to assign a key pair to your instance and complete the launch process. Click on Launch.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2lalcw0ams78vls3j1n9.png)

Select > Create a new key pair > Type key pair name > Download key pair > Launch Instance

 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j608j7btg0zetexz9z3x.png)
Custom Rating in Android+Kotlin
Tags: tutorial, android, kotlin
Published: 2020-08-08 10:46:44

###Hey! this tutorial will help you to incorporate rating screen in your app.

https://medium.com/@rithvik2994/custom-rating-system-android-3185b4f94596?source=friends_link&sk=c45418d5f1588ba29885067a07f79128
Building portfolio for a backend dev
Tags: discuss, backend
Published: 2020-08-08 10:32:35

---
title: Building portfolio for a backend dev
published: true
description: 
tags: #discuss, #backend
//cover_image: https://direct_url_to_image.jpg
---

Developers working on ETL,Data engineering or as a backend dev for web applications how do you build a portfolio or show your open source work.
e (Euler's number) explanation, and applications
Tags: math, statistics
Published: 2020-08-08 10:24:43

It is quite well explained here -- https://betterexplained.com/articles/demystifying-the-natural-logarithm-ln/

Although, I don't truly understand, I see it as an attempt to calculate the [compound interest curve](https://en.wikipedia.org/wiki/E_(mathematical_constant)#Compound_interest); and natural logarithms as reverse calculating it.

Feel that this website is about right -- https://betterexplained.com/archives/ (and there are **computer science problems**, too.)

Though, another approach is to start from [problems](https://bookdown.org/roback/bookdown-bysh/ch-distthry.html#additional-resources) (thought or real).

BTW, [my favorite in computer thingy](https://en.wikipedia.org/wiki/Fast_inverse_square_root) might be,

```c
float Q_rsqrt( float number )
{
	long i;
	float x2, y;
	const float threehalfs = 1.5F;

	x2 = number * 0.5F;
	y  = number;
	i  = * ( long * ) &y;                       // evil floating point bit level hacking
	i  = 0x5f3759df - ( i >> 1 );               // what the fuck? 
	y  = * ( float * ) &i;
	y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//	y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

	return y;
}
```
Weather App with React & TypeScript
Tags: showdev, react, typescript, javascript
Published: 2020-08-08 10:23:21

A weather application built with React that shows the weather forecast for any city or place around the world by consuming OpenWeatherMap API.

![Screenshot](https://user-images.githubusercontent.com/25284536/89673475-ac759780-d8fb-11ea-93af-b557088c945b.png)

Back in April I made the application mockup in Adobe XD but didn't have the time and motivation to actually develop the app until a few weeks ago that I decided since this can be a good project for my portfolio, I have to make this and I started working on it.
Today I am so excited to say that I finished developing this app and making it live, obviously, some polishments need to be done but for now, I wanted to share it with you.

As always let me know what you think about it I am glad to hear from you, also consider giving the project a star on GitHub.

####💎 Features
* Weather forecast for any city or place
* Extended 7 days forecast
* Find user location weather by utilizing GeolocationAPI
* One-click Celcius to Fahrenheit conversion and vice versa
* Dark Mode

#### 💻 Tech Stack:
* React
* Redux
* Typescript
* StyledComponents

🌐 App:
https://esnz-reactweather.netlify.app

👩‍💻 Github Repo:
https://github.com/esnz/react-weather-app
Tribute Page - Dr.  A.P.J. Abdul Kalam
Tags: codepen, html, css, beginners
Published: 2020-08-08 10:22:24

<p>This is the tribute page for our Missile Man of The India -<strong> Dr. A.P.J. Abdul Kalam</strong> .  He was also known as People's President.<br>
This shows the journey of Small boy to the President of the India and also one of the most loved man in India. We should follow his steps to become successful in life and do something for our nation.<br>There are many quotes given by Sir Kalam that are life-changing. I like to mention one of them :-<br> <i> 'It Is Very Easy To Defeat Someone, But It Is Very Hard To Win Someone'</i></p>
{% codepen https://codepen.io/roughking/pen/QWyoLZw %}

<a href="https://dev.to/roughking">Rough-King
  <img src="https://d2fltix0v2e0sb.cloudfront.net/dev-badge.svg" alt="Rough-king's DEV Profile" height="30" width="30">
</a>
Two Bold Rules to get meetings right before they even start
Tags: management, agile
Published: 2020-08-08 10:13:59

There aren’t many teams where meetings don’t become a contentious subject at some point or another. Regardless of the topic and even before any meeting takes place, the way a team manages meetings says a lot about how they operate and how invested in self-organisation they are.

The main contention I see is around attendance: often people feel they’re invited to too many meetings, or that they’ve been excluded from the important ones. Regardless, the responsibility of getting this balance right tends to fall in the hands of one or few team members, and it’s just too easy to get it wrong and create frustrations.

A way to make this situation a lot better is to embrace two bold and simple rules: **Meetings are open to the whole team**, and **Meetings are always optional**.

By saying that Meetings are open to the whole team, there’s no longer a risk of excluding interested people. It also opens the space for people who otherwise wouldn’t be present to show up and contribute.

Open meetings also incentivise better invitations (goals, agenda etc) upfront. With those in place, team members will be able to judge if they’ll be able to learn and contribute, and also propose changes to scope or time in case key people can’t attend. It also moves the responsibility of coming up with the attendance list from individuals to the whole team, who’s now empowered to make the best decision possible.

This flexibility only works if Meetings are always optional. This rule creates the safety for people to skip attendance when they judge appropriate, and even apply the **Law of Two Feet** (“it’s ok to leave a meeting if you’re no longer learning or contributing”) when needed. The result is meetings with higher engagement.

Those two rules are inspired by Open Space Technology and widely applied at conferences, and require a leap of faith. You have to trust that meetings will count with the right people and produce the best outcome possible in each context. And above all, that you trust the team to help each other for that to happen.

If you believe this could be of benefit to your team, I suggest the following three next steps:

1. Share and discuss this article with your team.
2. Commit to applying to the *Two Bold Rules* for 2–4 weeks as an experiment.
3. Reflect as a team on the impact, and if possible, share the results with other people who could benefit from it.

*Image credit: [@bantersnaps](https://unsplash.com/@bantersnaps)*
Logstalgia till your console freezes over
Tags: csharp, productivity, unity3d
Published: 2020-08-08 10:02:42

A year back, published a(n ill-named) package ([Prolog](https://github.com/active-logic/prolog)) to rid the day of tedious `Console.Write`/`Debug.Log` cycles. Powered by Mono.Cecil, took upon itself to log every function call.

If memory serves, did/does work pretty well.

So why are we here? Reasons - TLDR old habits die. harder. So here is an article about logging in C# for debugging purposes. The bread and lobster. 

And how I am fixing it.

## Wait, logging is broken in C#?

PowerShell got brogging rights -

```
# Say 'Hi'
"Hi"
```

From here, all downhill. Be it .net or Unity3D, an assortment of `Console.Write` / `Debug.Log` / `[insert pompous paraphernalia]`. 

What logs in VS does not log in a console app does not log in Unity so, if you are going "cross platform", steam the logster yourself.

Can we fix this? What?

A *casual* logging API (re: PowerShell) should be concise and readable. We do ✨not✨ want a `using` dep for the sake of debugging. 

90% of the time we are going to remove these traces; the remaining 10% of the time use a dedicated logger (so we know not to delete user traces).

Ergo logging via system/engine level scoped (namespaced) APIs, this: 

**A DISTRACTION™️**

## Pure C# solution

Tried variants around...

```cs
++ log / $"message";  // (++/--) for severity?
```

⚠️ The above does not constitute a well formed C# statement. Unless willing to eat your shirt (we are getting there), go with 🌊

```cs
public static class Log{

    public static void Message(object arg) 
    => Console.WriteLine(arg);

}
```

Which you may use without `using`, like so: 

```
Log.Message("(\´ ∀ \`*)");  # print (´ ∀ `*)
```

## Eat your shirt

So. Was looking into this while reviewing log traces in Howl, the symbolic notation for C# -

More about this later - question: what would be an idiom that shines 〜 usability, easy mapping to C# (bidi conversions with) and all

{% twitter 1292016260285263872 %}

Howl imp:

```
⊐̥ System.Console;

‒ ○ log{

    ‒̥ ㄹ message { ╰ → WriteLine(value); }
    ‒̥ ㄹ warning { ╰ → WriteLine(value); }
    ‒̥ ㄹ error   { ╰ → WriteLine(value); }

}
```

We map chicks to lobsters internally.

```
// ... Howl internals
("🐤", "log.warning =", alt: "[chick]"),
// ... Have your chick and eat it too.
```

Next: preparing a small article about begin/end pattern annoyances and (pure C#) ways to kiss the beast 🖖🏼
🔥 How to Switch From Manual to Automation Testing?
Tags: testing, tutorial, webdev, beginners
Published: 2020-08-08 09:55:39

In this video, Pramod Dutta(TheTestingAcademy) and Chandan mishara from TestAutomasi, Share their experience about How they are switched and How you can tool Switch from Manual to Automation Testing.

{% youtube uet-bQjA22I %}


Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")
How to use setInterval in React hooks
Published: 2020-08-08 09:55:08

**Problem:** Any code/function called inside setInterval does not show updated state (where state is created using useState hook). The reason is any function passed in setInterval is a [closure](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures#:~:text=A%20closure%20is%20the%20combination,state%20(the%20lexical%20environment).&text=In%20JavaScript%2C%20closures%20are%20created,created%2C%20at%20function%20creation%20time.) and values of all its arguments or variables accessables inside it (variables defined in outer functions) become static and take the snapshot of data at the time of the interval creation and does not look back at the original variables again. 
**Solution**
One better solution, a custom hook, to use setInterval with React hooks is provided by Dan Abramov's at his personal blog (article linked below). The is as below:
```
import React, { useState, useEffect, useRef } from 'react';

function useInterval(callback, delay) {
  const savedCallback = useRef();

  // Remember the latest callback.
  useEffect(() => {
    savedCallback.current = callback;
  }, [callback]);

  // Set up the interval.
  useEffect(() => {
    function tick() {
      savedCallback.current();
    }
    if (delay !== null) {
      let id = setInterval(tick, delay);
      return () => clearInterval(id);
    }
  }, [delay]);
}
```

[Here is the how to use it in your code demo](https://codesandbox.io/s/105x531vkq?file=/src/index.js:218-234)

**Reference**
[Original article at Dan Abramov blog](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)
balalaika IT newsletter #7
Tags: react, node, java, webdev
Published: 2020-08-08 07:58:08

---
title: balalaika IT newsletter #7
published: true
description: Curated IT newsletter. From Russia with love. Issue #6.
tags: #react #node #java #webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/7dwkz927sf2ausnqygq3.jpg
canonical_url: https://blog.balalaikait.com/balalaika-it-newsletter-7
---

# Frontend
- [A short, yet insightful post](https://engineering.fb.com/web/facebook-com-accessibility/) about enhanced A11Y at Facebook. You might think it is easy and not a big deal until you have to re-write your whole application to meet the [AIRA guidelines](https://www.w3.org/TR/wai-aria-practices-1.2/).

# Node.js
- What do you know about the speculative compilation in JavaScript? [This lengthy read](https://webkit.org/blog/10308/speculation-in-javascriptcore/) goes in-depth of how modern JS VMs make your code run faster.
- There is a certain learning curve related with contributions to the native side of Node.js core. Luckily this great [tips and tricks post](https://joyeecheung.github.io/blog/2018/12/31/tips-and-tricks-node-core/) from Joyee Cheung is there to help you.

# Java
- It is not a big secret that GC may introduce latency spikes. Such spikes are especially harmful in case of stream processing engine, like Hazelcast Jet or Apache Spark Streaming. Read [this blog post series](https://jet-start.sh/blog/2020/06/09/jdk-gc-benchmarks-part1) from Jet team to see results of various experiments with modern Java garbage collectors.
- Did you know that there is a Java Engineering Group in Microsoft? Moreover, these guys wrote a [nice JEP](https://github.com/microsoft/openjdk-proposals/blob/master/stack_allocation/Stack_Allocation_JEP.md) on Stack Allocation support in HotSpot C2 to eliminate non-escaping heap allocations where applicable.

# General
- Distributed systems are much more than the AP/CP choice implied by the so called CAP theorem. Conflict-free replicated data types (CRDT) assume eventual consistency, scale really well, and provide math-based way to resolve inconsistencies between replicas. In [this talk](https://youtu.be/x7drE24geUw) Martin Kleppmann goes beyond the introductory material on CRDTs.
- API seems to be so natural term that we assume it was there since the beginning of computer era. But that is not true. If you want to learn when and how the concept of API was invented, watch [this talk](https://youtu.be/LzMp6uQbmns) from Joshua Bloch.
- Dropbox migrated from Nginx to Envoy. [In this blogpost](https://dropbox.tech/infrastructure/how-we-migrated-dropbox-from-nginx-to-envoy) Alexey Ivanov  and Oleg Guba talk about the old Nginx-based traffic infrastructure, its pain points, and the benefits we gained by migrating to Envoy.
Node.js (Express) with TypeScript, Eslint, Jest, Prettier and Husky - Part 2
Tags: eslint, prettier, husky, node
Published: 2020-08-08 09:53:35

On this part we are going to configure ESLint, Pettier and Husky.

Head over to Medium to read the blog post:
https://medium.com/@oxodesign/node-js-express-with-typescript-eslint-jest-prettier-and-husky-part-2-f129188ce404
#100DaysOfCode | Day 14
Tags: 100daysofcode, challenge, python, beginners
Published: 2020-08-08 09:42:05

Hey everyone, Today is my 14th day!
I'm so happy that it's two weeks from my last decision about to make a new habit!
Today I'm still working on my new  post for you about making __Snake-Game__ and working to complete project, but at the same time I'm writing about it here, I'll share the way I learned to make game with __Turtle__ and I promise it could be so amazing and cool for beginners.
Keep it up ;)


Keep Moving Forward __ツ__

Enjoy Your Journey 👊

Code with __💛__

__🅑🅐🅝🅙🅘__
How to compile C++ software with Qt for Windows/Linux/OSX
Tags: qt, linux, cpp
Published: 2020-09-25 10:17:21

---
title: How to compile C++ software with Qt for Windows/Linux/OSX
published: true
date: 2020-08-08 09:33:38 UTC
tags: qt,Linux,cpp
canonical_url: https://daniele.tech/2020/08/how-to-compile-c-software-with-qt-for-windows-linux-osx/
---

Months ago I started and finished a project, GBAATM-Rebirth. This tool is a GameBoy Advance rom patcher with a GUI written in C++ using QT frameworks. The issue for me was to compile and generate a compiled version for Windows and OSX other and Linux automatically. So I started a discussion on Reddit to get [...]

[Read More...](https://daniele.tech/2020/08/how-to-compile-c-software-with-qt-for-windows-linux-osx/)

The post [How to compile C++ software with Qt for Windows/Linux/OSX](https://daniele.tech/2020/08/how-to-compile-c-software-with-qt-for-windows-linux-osx/) appeared first on [Daniele Mte90 Scasciafratte](https://daniele.tech/eng).
Understanding Virtualization in Operating Systems
Tags: productivity, os, virtualisation
Published: 2020-08-08 09:19:05

![XKCD](https://dev-to-uploads.s3.amazonaws.com/i/0dcc35imouugba5p1t1d.png)
Virtualisation is the process of creating a virtual version of a physical object.

Virtualisation is of three types primarily:
1. Hardware Virtualisation - Based on simulating real hardware. This can be used to run a complete operating system. This can be further subdivided into full and paravirtualisation.

2. Desktop Virtualisation - It is the concept of separating the logical desktop from the physical machine.

3. Operating system level virtualisation (also called as containerisation) - It is the operating system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances are called containers. Containerisation was introduced as a Linux Kernel feature in 2010. It started gaining momentum with the introduction of Docker.


#### Hardware Virtualisation


Some terminologies associated with Virtualisation:

1. Virtual Machine: It is a virtual representation of a physical machine.

2. Hypervisor: It is a software that manages and monitors running virtual machines.

3. Host machine: The physical machine that a virtual machine is running on.

4. Guest machine: The virtual machine running on the host machine.


The following block diagram shows the position of each component mentioned above:

![Virtual Machine Diagram](https://dev-to-uploads.s3.amazonaws.com/i/6sl9vl8orsd887e2g0hh.png)

#### Hypervisors


There are two main types of hypervisors:


1. Native: They run directly on the host machine and share out resources between guest machines.


2. Hosted: They run as an application inside the operating system and support virtual machines running as individual processes.
Eg. VirutalBox,Parallel Desktop


![Hypervisor Types](https://dev-to-uploads.s3.amazonaws.com/i/z612664k72yl837ucu6g.png)