teleren/devto huggingface dataset:
Why I'm giving Python and Django another chance
Tags: python, django, journey, progress
Published: 2020-09-20 15:38:34

---
title: Why I'm giving Python and Django another chance
published: true
description: I've decided that I'm going to learn something new and give something a chance which is Python and Django.
tags: python, django, journey, progress
//cover_image: https://direct_url_to_image.jpg
---
I work mostly with PHP and Laravel at work and in my own projects. I love PHP and Laravel, they both get a lot of criticism from the wider developer community at times, but I feel like I want to learn something new and give another language and framework a chance. By no means am I downing tools with PHP and Laravel, I will still very much use them.

Whilst studying at University, I wrote some Python. However, this was only to implement Algorithms and Data Structures and to be honest I think this put me off Python. At the time I just didn't enjoy writing the code that I was required to and subconsciously I think I developed some sort of dislike towards Python and I started to develop this bias that I would dislike any Python frameworks too. Now that I have completed my course at University I've decided that giving Python another chance and diving into Django might be the challenge I'm looking for.

So, where do I start? Well, I already have a grasp of the basics of Python and I know that really I need to use something like virtualenv when developing projects. But, I don't really have any knowledge of Django and how it handles things such as databases, routing, and views. 

Sometimes I think I dwell too much on what I should learn next, but in this scenario I think I have an idea of what path I will take. 
Firstly, I'm going to spend a bit of time brushing up on my Python basics and learning some more advanced Python core features such as how Python handles object oriented development and using tools like virtualenv. 
Secondly, I think I'm going to move onto getting a basic grasp of Django and getting a simple Django project up and running locally, maybe even using Docker if I can. 
Finally, I'll probably look into building some sort of functional app with Django and seeing how I can deploy it to AWS Lambda, maybe using a tool like Apex Up or Zappa.

Thank you for reading, I hope you enjoyed. Catch you later!
Learn a little bit about of ʎ function in C++ 💎
Tags: cpp
Published: 2020-09-20 15:28:51

### in c++ lambda function is quite popular. And it makes code more readable with tons of functionality. So let's start learning about it 👀.

When we talking about the syntax of lambda function in c++ it quite different.

We don't follow complex code on the learning path, we always try to make things simpler.

`[ captures ] ( params ) -> return_type { body_statements }`

#### First, we try to understand about captures. When we need variables that defined in outside of function then we use captures to making a clone of a variable.

```cpp
[ ] { }	     // no captures
[=] { }	     // everything by copy(not recommended)
[&] { }	     // everything by reference(not recommended)
[x] { }	     // x by copy
[&x] { }     // x by reference
[&, x] { }   // x by copy, everything else by reference
[=, &x] { }  // x by reference, everything else by copy
```
> If we capture by copy that's make the clone of the variable only, they don't affect actual variables. But when we capture by reference we able to change the value of the variable inside that function. 

- Try to understand lambda function with Hello World program.

```cpp
auto say_hello = [] {
    cout << "Hello World!";
};
```
- use a variable that defines outside the function.

```cpp
// init varible with value
int a = 10;
// lambda function
auto print_a = [a] ( ) {
    cout << a;
};
print_a(); \\ output is 10
```
- change the value of a variable that defines outside the function.
```cpp
// init varible with value
int a = 10;
// lambda function
auto print_a = [a] ( ) {
     a = 12;
     cout << a;
};
print_a(); \\ output is 12

```

Now I think the concept of captures is pretty clear.

#### Now we move forward to params, params are nothing but the only short name of parameters. I think you all familiar with this concept 🥱. but still, I want to give a short example of parameters in lambda function.

```cpp
auto sum = [](int a, int b) {
        return a + b;
}
cout << sum(10,4); // Output is 14
```

#### Now last is return_type, After c++ 20 return type is optional. We don't need to specify the return type of lambda function.

> But still we may specify return type with using -> sign.

```cpp
auto sum = [](int a, int b) -> int {
        return a + b;
};
```

🎉✨✨🎉🎊🎊🎉🎉✨✨🎉🎊🎊🎉
Congratulation you learn c++ lambda function in few minutes with dvlpr_roshan ( Roshan Kumar ).

Still, who wants to learn lambda function a little bit more with advance features.

- actually real syntax of the lambda function in c++ is:
`[ captures ] <tparams> ( params ) specifiers exception attr -> return_type {body_statements}`

Following links can helpful for learning more about the concept of the lambda function in c++.

- https://en.cppreference.com/w/cpp/language/lambda
- https://docs.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp?view=vs-2019
Tools for work and project!
Tags: management, devops
Published: 2020-09-20 15:05:48

What kind of tools are you using for development?
I am using these ones. and you ?
What is more effective and convenient?
Let's share our environment, and improve our productivity here.

# Documentation
notion, asana
# Wireframing
balsamiq
# UI/UX Design
Figma, Photoshop
# communication
slack
# editor
VScode, vim
# Version control
sourcetree
# screenshot sharing & highlighting
cloudapp
# screen recording
Snagit
# Browsers
Chrome, Firefox
# Chrome Extensions
lighthouse, Windows Resizer, Pesticide
understanding React Hooks and Effects
Published: 2020-09-20 14:41:40

---
title: understanding React Hooks and Effects
published: true
description: 
tags: 
cover_image: https://www.cronj.com/blog/wp-content/uploads/React-Hook.png
---

```js
import React, { useState, useEffect } from 'react';

function Example() {
  const [count, setCount] = useState(0);

  // Similar to componentDidMount and componentDidUpdate:
  useEffect(() => {
    // Update the document title using the browser API
    document.title = `You clicked ${count} times`;
  });

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
```


React Effects are normally triggered by React after each RENDER of the component.

An effect can contain also a cleanup method by returning it from the callback function like this

```js
useEffect(() => {
  AppAPI.subscribeToNameChange(nameChanged);

  document.title = "name is ${name}"

  return () => {
    AppAPI.unsubscribeToNameChange(nameChanged);
  }
});
```


Multiple hooks can be used to separate concerns:

```js
function FriendStatusWithCounter(props) {
  const [count, setCount] = useState(0);
  useEffect(() => {
    document.title = `You clicked ${count} times`;
  });

  const [isOnline, setIsOnline] = useState(null);
  useEffect(() => {
    function handleStatusChange(status) {
      setIsOnline(status.isOnline);
    }

    ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
    return () => {
      ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);
    };
  });
  // ...
}
```

# useEffect lifecycle

**An important thing** to note is the effect callbacks are applied at both lifecycles of init/destroy and after each render.
It is helpful because each state change should produce a consistent refresh of the component's UI. 
This feature is provided out of the box, while for class based React components this needs to be addressed manually via componentDidUpdate.
Also any listeners bound during the effect's execution are likely to be linked to the current state of the component. So if the state changes, these listeners should be rebound:

```js
function FriendStatus(props) {
  // ...
  useEffect(() => {
    // ...
    ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
    return () => {
      ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);
    };
  });
```

However this is prone to performance issues if the callback execution is expensive.
To help with that, React provides a dirty check feature, by providing an extra param to useEffect:

```js
useEffect(() => {
  function handleStatusChange(status) {
    setIsOnline(status.isOnline);
  }

  ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
  return () => {
    ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);
  };
}, [props.friend.id]); // Only re-subscribe if props.friend.id changes
```

Source: https://reactjs.org/docs/hooks-effect.html
How to CI your project like a champ in 2 minutes
Tags: cicd, devops, metroline
Published: 2020-09-20 14:39:27

Today I'll be showing you how to setup CI for your project in less than 2 minutes with [Metroline](https://github/metroline/metroline), an open source, self hosted CI. I'll be using Gitea for this tutorial but you could use Gitlab or Github.

## Install Metroline (1 minute)

Create a Gitea OAuth app and copy your **Client ID** and **Client Secret**

![create-gitea-app.mp4](https://dev-to-uploads.s3.amazonaws.com/i/cl5sd5f3fl0qo3xs34qw.gif) 

Copy [this](https://gist.github.com/gempain/16df50e686c9aeffd8bccfbb1ae697b9) `docker-compose.yml` and:
    - set `METROLINE_GITEA_CLIENT_ID` to your Gitea client ID
    - set `METROLINE_GITEA_CLIENT_SECRET` to your Gitea client secret
    - set `METROLINE_GITEA_URL` to the URL of your Gitea server
    - change `192.168.43.36` with your IP
    - set `METROLINE_JWT_SECRET` with a random secret obtained from `openssl rand 32 -hex`
    - set `METROLINE_RUNNER_SECRET` with a random secret obtained from `openssl rand 32 -hex`

Now, run `docker-compose up -d` and browse to `http://<your-ip>:3000`. Click **Sign in**. You'll see the list of your repos. Click **Setup** on your favorite project, and you're all set !

![setup-repo.mp4](https://dev-to-uploads.s3.amazonaws.com/i/4r1jjuoiltx5l5tucv31.gif) 

## Add CI config file and run first pipeline (30 seconds)

At the root of your project, add a `.metroline.yml` file with this content:

```yml
version: '1'
image: node:12-alpine
jobs:
  install:
    script:
      - npm ci
  test:
    script:
      - npm test
    dependencies:
      - install
```

Commit, push, and you Metroline starts building your commit immediately.

![pipeline.mp4](https://dev-to-uploads.s3.amazonaws.com/i/iksvcipkjxtqghuferj9.gif) 

Pipeline statuses are reported to Gitea as they change. You'll be able to see it next to the commit, and clicking the commit status will open the pipeline in Metroline.

![commit-status](https://dev-to-uploads.s3.amazonaws.com/i/7upspext1057ucwqfh4c.png) 

## Conclusion

I've demonstrated the very basics here, but you can configure parallel jobs, secrets, conditionally execute jobs based on the branch or status of upstream jobs, you can also define pipeline environment, and [more](https://github.com/metroline/metroline#features).

Also remember that this will work with Github and Gitlab, so I recommend you checkout the [installation instructions](https://docs.metroline.io/core/installation) for your favorite Git server.

Hope you find this useful !

Follow us on Twitter [@metrolineio](twitter.com/metrolineio) to stay tuned, and share [Metroline](https://github.com/metroline/metroline) around you so we can grow our community !
#2 DBMS ( FOR INTERVIEW PURPOSES )
Tags: database, career, computerscience
Published: 2020-09-20 14:35:53

In this series of blogs, we will study all the database management ( DBMS ) topics for interview purposes. this blog gives you only the insights and working explanation of each topic, we will not go in-depth of the topic

In the previous blog, we studied about Data structures and DBMS. So, now move on #2 topic

# **2) Difference Between Database and Database Management System?**

## Database :

Database is a collection of well-organized data. In the database, data is stored in the form of tables and views, and these sets of data elements designed to store and manipulate data in the future.

- **Two type of Database**
    - **Online transaction processing (OLTP)**

        stores current data & used for transaction purpose ( stored in megabyte or gigabyte)

    - **Online analysis processing (OLAP)**

        stores historical data & used for analysis purpose ( stored in terabyte or petabyte )

In a relational database, the structure of the table also known as **schema**

## DBMS:

DBMS is system software that is used to creating, managing, and retrieving data from the database as per the user requirement. it acts as an intermediator between user and database

for more information about DBMS you can read the previous blog :
Link :
[DBMS ( FOR INTERVIEW PURPOSES)](https://dev.to/ranjitkshah/dbms-for-interview-purposes-2c0j)

Examples of DBMS are MySQL, Oracle, PostgreSQL, etc.

#### *Let's understand difference via example*

Excel is a database which can store your data but to extract the data you have to dig row by row manually

similar to excel we have an oracle, MySQL that offers commands by which users can fetch any data as per the requirements.

#### MAIN MEMORY VS SECONDARY MEMORY

1. Main memory is the primary memory or internal memory of the computer while secondary memory is the backup or auxiliary memory of the computer.
2. Types of Main memory & Secondary memory


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


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


3. Main memory is directly accessed by the processing unit whereas secondary memory cannot be. 
4. Main memory is both volatile & non-volatile whereas secondary memory is always non-volatile.
5. Main memory holds the currently using data while secondary memory stores the substantial amount of data & information ( from 256gb to 1 terabyte ) 
6. Main Memory can be accessed by data buses while secondary memory is accessed by I/O channels

Thank you for reading : )
Real-time financial data streaming using WebSockets
Tags: python, datascience, tutorial
Published: 2020-09-20 14:28:11

This short article was written to cover the lack of any tutorial of how to simply begin receiving stocks, forex, and crypto quotes in under 5 minutes. We will mainly focus on Python implementation, however, the same logic can be easily extended to other languages.

WebSockets might be a crucial part of the apps which rely on accurate real-time data, such as chart application, portfolio management, and algorithmic trading systems.

## Preparation
We will be using the service [Twelve Data](https://twelvedata.com). Make sure to have your API Key upgraded to be eligible for the [usage](https://twelvedata.com/prime) of WebSockets.

For python users, install the library `pip install twelvedata` - [GitHub](https://github.com/twelvedata/twelvedata-python).

## Python
First things first, define the function which will be used when new data is received.
```python
def on_event(e):
    print(e)
```
This function should perform any consecutive actions according to your logic: update the price, update a record, display the changes, etc.

> Remember that all data received is in `json` format or to be more precise a `dict` object.



The main block should initialize the `TDClient` object and perform the consecutive connection to the server.
```python
from twelvedata import TDClient

td = TDClient('your_api_key')

ws = td.websocket(symbols=['BTC/USD', 'AAPL', 'EUR/USD'], on_event=on_event)
ws.connect()
ws.keep_alive()
```

WebSocket supports the following methods:
`subscribe` - new symbols to be included.
`unsubscribe` - remove old symbols from the subscription.
`reset` - unsubscribe from all symbols.
`connect` - open a new connection with the server.
`disconnect` - close existing connection with the server.
`keep_alive` - run an infinite loop to receive all the data.

#### Response
In response, you will be getting an object with basic meta-information, tick price, and daily volume. E.g:
```python
{'event': 'price', 'symbol': 'BTC/USD', 'currency_base': 'Bitcoin', 'currency_quote': 'US Dollar', 'exchange': 'Binance', 'type': 'Digital Currency', 'timestamp': 1600595462, 'price': 10964.8, 'day_volume': 38279}
```

> Do not forget about market open hours, for instance over the weekends only crypto markets are opened.

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

The average latency is about ~150ms, which makes the data reliable and applicable to any usage. Moreover, the single format allows flexibility in streaming data from across different types of assets.
Now you can easily use it for your application, e.g. charting.
Get notified via telegram when pull request is raised
Published: 2020-09-20 13:33:56

Telegram is cool messaging platform with lot of developer friendly capabilities. I wondered if i could get a notification whenever a pull request is raised to my GitHub public repository.

# Leveraging git hub actions

[GitHub Actions](https://github.com/features/actions) can be used to do all sorts of automation on your GitHub repositories.

Quickly doing some google search found an action which I can use to send telegram notifications when ever a pull request is raised.

## Create new a GitHub workflow

* Under your repository home page, create a new workflow
* Select the simple workflow later we can modify this accordingly

![New GitHub Workflow](https://dev-to-uploads.s3.amazonaws.com/i/mv01afkgumc2yd4e137k.png)

```
# This is a basic workflow to help you get started with Actions

name: Telegram notification

# Controls when the action will run. Triggers the workflow on pull request
on:
  pull_request:
    branches: [ develop ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs the telegram notify action to send a notification
      - name: Telegram Notify
        uses: appleboy/telegram-action@master
        with:
          to: ${{ secrets.TELEGRAM_TO }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          format: markdown
          message: |
            A new PR is raised [View all PR's](https://github.com/<user>/<repo>/pulls)
```

## Getting the telegram bot token and group unique id

* Use [Telegram Bot Father](https://core.telegram.org/bots#6-botfather) to create a new bot.
* When a bot is created it returns token, save it.
* Create a telegram group and add this bot to the group.
* Add a test message to this group.
* To get a unique id of the group.

`https://api.telegram.org/bot<token>/getUpdates`

* Find the group unique id under `chat.id`

## Create the necessary secrets required for the workflow

* Go to settings under repository
* Under `secrets`
* Create a new secret called `TELEGRAM_TOKEN` with the token value from above.
* Create a new secret called `TELEGRAM_TO` with unique id of the group.

Yipeyy!! When a pull request is raised a notification is sent to the group.

{% github appleboy/telegram-action no-readme %}
Simple todo system to keep you organized
Tags: productivity, devlive
Published: 2020-09-20 13:26:28

I was never able to follow any kind of TODO/GTD system. All these systems have great ideas, it's awesome to read about them and when I tried to follow them I always fail. Maybe I do not have that many things to do so that keeping a complex system is more overhead than I need. Maybe those systems are complex just to be complex. I do not now. But I would love to know if somebody follows GTD or any other system to the point. 

When I decided I need to do my system I downloaded a lot of TODO apps. And tried to figure out what is the best one for me. I do not need most of the complex features as again there is more complexity than what I need. I do not want to pay for the app. I need a way to track more complex tasks. I need a system that can combine my personal and work life. I tested most of the apps and I did not like most of them. 

What I ended up doing was in my opinion a unique system, that is very flexible and customizable. I have two components, lets name them **backlog** and **daily**. 

## Backlog
I created a private GitHub repo. In this repo I have bunch of markdown files. There is an index file called TODO.md. Here you can document yout long term todos. It can be one line, or link to another file. It's up to you how to organize this. I choose to use [Foam for VSCode](https://foambubble.github.io/foam/). VS Code has awesome markdown editor, plugins and is avalible on Windows, Linux and OsX. You can choose whatever platform/technology works for you. Point of the backlog is not edit/referenence more than few times a week.  

## Daily
Each mornign as part of my morning routine I will compile my daily list. I do this on paper. I write down the date and go over a few places to compile the task list. 

![daily sheet](https://www.dropbox.com/s/fato0vaff9076zz/IMG_20200920_150423.jpg?raw=1)

Places to check
- previous day and move non completed items to the current day
- email (personal and work one) and notes tasks
- calendar and note my meetings
- backlog, only if I feel like my list at this point is a bit empty

I get creative when adding the tasks. I can nest them. Have multiple checks if it's a repetitive task. I write down time when needed. But do not overdo it. It take me around 5 to 10 minutes to compile each morning. 

I go by my day and tick tasks as they aretest completed. I am adding tasks as I discover new ones. Can be from a meeting, new email, etc.. If I know I need to do this later, it's more complex, etc.. I can mark it as such on a paper or add it to backlog at the moment. Either way when I open backlog to add stuff I will check my paper if everything there is possible and if not I move it to the backlog. 

---

You can follow me on [Twitter](https://twitter.com/pavel_polivka) to get more tips like this.
Distributed In Memory Processing And Streaming With Hazelcast - Episode 150
Published: 2020-09-20 13:24:47

<p>In memory computing provides significant performance benefits, but brings along challenges for managing failures and scaling up. Hazelcast is a platform for managing stateful in-memory storage and computation across a distributed cluster of commodity hardware. On top of this foundation, the Hazelcast team has also built a streaming platform for reliable high throughput data transmission. In this episode Dale Kim shares how Hazelcast is implemented, the use cases that it enables, and how it complements on-disk data management systems.</p><p><a href='https://www.dataengineeringpodcast.com/hazelcast-in-memory-processing-episode-150/'>Listen Now!</a></p>
Simplified Data Extraction And Analysis For Current Events With Newspaper
Published: 2020-09-20 13:23:39

<p>News media is an important source of information for understanding the context of the world. To make it easier to access and process the contents of news sites Lucas Ou-Yang built the Newspaper library that aids in automatic retrieval of articles and prepare it for analysis. In this episode he shares how the project got started, how it is implemented, and how you can get started with it today. He also discusses how recent improvements in the utility and ease of use of deep learning libraries open new possibilities for future iterations of the project.</p><p><a href='https://www.pythonpodcast.com/newspaper-data-extraction-episode-280/'>Listen Now!</a></p>