teleren/devto huggingface dataset:
if __name__ == __main__:
Tags: python, beginners
Published: 2020-04-12 17:55:45

```py
if __name__ == __main__:
  # some code
```
The above code is something you'll see a lot when seeing other peoples' code in Flask. But what does this mean and why do people use it?

To start, let's create a new Python program and write this line of code in it:
```py
# first_module.py

print(f"First module's name: {__name__}")

```

What you will get in your console after running `python first_module.py` is:

```
First module's name: __main__
```
So wtf is happening here? 

Before Python runs any code it creates a few special variables. `__name__` is one of those special variables. It then sets the `__name__` variable equal to `__main__`. It does this because we ran a Python file directly to first_module.py when we entered `python first_module.py`.

Now, let's import `first_module.py` into a new module called `second_module.py`. Your first module should look exactly the same. In `second_module.py` just enter:

```py
import first_module

print(f"Second module's name: {__name__}")
```

Now, if you run `python second_module.py` you get the following in return:
```
First module's name: first_module
Second module's name: __main__
```
The first module's `__name__` is now set to `first_module` and the second module's `__name__` is now set to `__main__`.

Are you picking up what I'm putting down here? 

Whatever file we decide to run like `python whatever.py`, `__name__` will be set to `__main__` in whatever.py because that's where we ran the file directly! 

```py
if __name__ == __main__:
  # some code
```
The reason why you see this line of code often is because it's checking to see if the current file was being run directly by Python or to another file. Sometimes you want code to only run when it's the main file.
A Brand New 🔥 AUDIO PLAYER plugin for the commuity 😎
Tags: webdev, javascript, opensource
Published: 2020-04-12 17:27:38

I was free today so made (almost complete) a brand new AUDIO PLAYER PLUGIN named `SharPlayer` FOR the community.

>UPDATED ON 13-04-2020, I've added a feature of clicking on the track duration bar to seek.

## Here is how it looks

![SharPlayer](https://dev-to-uploads.s3.amazonaws.com/i/aayubvm9p4s01ml3w6hy.png)
### [LIVE DEMO](https://sharadcodes.github.io/Shar-Player/examples/first/index.html)
## How can you use it ?

It's dead simple to use in any of your website.

Just grab these css links and put them in the head
```html
 <link
      href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet"
 />
 <link
      rel="stylesheet"
      href="https://sharadcodes.github.io/Shar-Player/src/css/sharplayer.css"
    />
<link
      href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet"
/>
```

Put this where you want to display the player
```html
 <div class="sharplayer" id="myplayer"></div>
<!-- 
 go ahead pick any id you like just make sure of sharplayer class  
-->
```

Not put at the end of closing body tag
```html
 <script src="https://sharadcodes.github.io/Shar-Player/src/js/sharplayer.js"></script>
```

Now you are ready to feed audio files in the plugin ..... so here we go

```html
<script>
      window.onload = function () {
        const song_list = [
          "audio_files/Faded.mp3",
          "audio_files/on_and_on.mp3",
          "audio_files/Cartoon_Howling.mp3",
          "audio_files/bensound-anewbeginning.mp3",
        ];
        //   make new object of SharPlayer class
// first argument is the id of the element where you wanna show the player
// second takes an object with 3 required keys:
// tracks (an array of audio file urls
// title (a boolean, this has to be false for now since i am thinking to give the feature to add titles to the audio tracks so leave it false)
// artwork (a boolean, leave it false for now as well ... those black squares that you see will hold the images. Since the plugin is in development you can leave it as it is.
        new SharPlayer("player", { 
          tracks: song_list,
          titles: false, 
          artwork: false,
        })
          .initPlayer() // call this function it's required
          .show(); //call this function it's required
      };
    </script>
```

---

That's it Awesome !!!!! right  🤓🤓🤓🤓🤓🤓

## All The links are here:
Github repo: https://github.com/sharadcodes/Shar-Player
Live Demo: https://sharadcodes.github.io/Shar-Player/examples/first/index.html
Example code: https://github.com/sharadcodes/Shar-Player/tree/master/examples/first

# Thank you
Web Development Blog by X of Y 
Tags: xofy, webdev, blog
Published: 2020-04-12 17:17:53

---
title: Web Development Blog by X of Y 
published: true
description: Follow the web development blog brought to you by X of Y. Read on articles about Django, VueJS, and web development.
tags: X of Y, web development, blog
---
You can now start reading the [web development blog by X of Y](https://xofytech.com/blog).

The blog will mainly tackle about web development, Django Web Framework, VueJS, and SEO.
X of Y relaunched its website!
Tags: xofy
Published: 2020-04-12 17:09:39

---
title: X of Y relaunched its website!
published: true
description: X of Y relaunched its website. With updated contents related to web development
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/7frprb8h9yl6hudxj8dw.png
tags: x of y
---

This is to announce the relaunching of xofytech.com, the official website of [X of Y](https://xofytech.com) Business and IT Services.

X of Y Business and IT Services is branded as "X of Y".

X of Y is the registered business name of Hanz Tura who is a freelance web developer for hire.

X of Y offers services like Web Application Development, Website Development, Search Engine Optimization (SEO), Implementation Services.

X of Y also offers the following software products:
[HRSalesPipes](https://github.com/hanztura/hrsalespipes) - an open-source applicant tracking system in the cloud. HRSalesPipes can help you manage core operations of a Recruitment Agency.
Accounting Software for Small Business.

You can [contact X of Y here](https://xofytech.com/#contact).
Share Your Conway's Game Of Life
Tags: watercooler, showdev
Published: 2020-04-12 17:02:37

Sadly, [John Horton Conway](https://en.wikipedia.org/wiki/John_Horton_Conway) has [passed away](https://www.i-programmer.info/news/82-heritage/13614-john-conway-dies-from-coronavirus.html).  While Conway's contributions to computational mathematics over the years are numerous and eclectic, many aspiring coders are introduced to his work via [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life), a cellular automaton that's relatively simple to implement.

In the Game of Life, you provide an initial state, or seed, to a square grid of cells.  Each cell is either "on" or "off", and the next state of the grid is calculated via these rules, as stated on Wikipedia:

1. Any live cell with two or three live neighbors survives.
1. Any dead cell with three live neighbors becomes a live cell.
1. All other live cells die in the next generation. Similarly, all other dead cells stay dead.

As this is relatively simple to write logic for, many programmers take a stab at implementing such a program early in their careers.  Here's [mine on GitHub](https://github.com/deciduously/conway), from July 2017, as one of my first Rust programs - but not terribly interesting to look it as it just renders world states in text to the terminal.  However, it does demonstrate how trivial the core logic is to write:

```rust

//tick_cell takes a Coord and a World and returns the next state of the cell
fn tick_cell(c: &Coord, w: &World) -> bool {
    let s = moore_sum(c, w);
    if get_cell(c, w) {
        match s {
            2 | 3 => true, //ALIVE
            _ => false, //overcrowded or starved
        }
    } else {
        match s {
            3 => true, //3 gives birth
            _ => false, //barren
        }
    }
}
```

Do you have a Game of Life to show us?  Bonus points for an implementation we can play with - my entry must be downloaded and compiled, but I'm sure some of you web-dev-y types have something more interactive!

What are some of your favorite seeds?  Are there other cellular automata that interest you?

Alternatively, what other John Conway work has inspired you?  According to [this redditor](https://www.reddit.com/r/programming/comments/fzjg0q/rip_john_conway/fn4on9i?utm_source=share&utm_medium=web2x), Conway was frustrated that the Game of Life was his most well-known contribution.  What else do you remember him for?

*Image: [wikimedia commons](https://en.wikipedia.org/wiki/File:Game_of_life_glider_gun.svg)*
#100DaysOfCode, 100 dias de que?
Tags: 100daysofcode, python, erlang, ui
Published: 2020-04-12 17:00:10

Enquanto escuto o album "Pra ouvir tomando uma" do Murilo Huff (Jesus tá vendo você me julgar 😑) pensei por que não escrever um pouco sobre esse desafio que estou fazendo? 🤔 E é isso que vou fazer.

Inclusive bom dia até porque a gente não dormiu junto 😆, então vamos lá o que é o desafio 100DaysOfCode é um desafio em que você se propõe a manter uma rotina diária de estudar e programar e ter um repositório para commitar o que você tem feito (colocar o código no GitHub ou algo parecido) e postar no Twitter sobre o que fez no dia.

Beleza parece legal, mas, porque fazer isso? O lance é seja você alguém mais experiente ou iniciante ter algum objetivo durante esses dias, seja aprender uma nova linguagem, adquirir o hábito de programar, ou aprofundar seus conhecimentos sobre uma área específica isso vai fazer com que pessoas que tem o mesmo objetivo, ou algum conhecimento sobre vejam o que você anda fazendo movimentando a comunidade de desenvolvedores como um todo.

Então caso esteja curioso meus objetivos são aprender Erlang, estudar Design, experiência de usuário e frontend em geral, vou falar um pouquinho de cada objetivo e porque estou interessado sobre esses assuntos, inclusive vou deixar os livros que estou estudando como base na parte de baixo dos tópicos.😄

##Erlang
Essa é uma linguagem de programação que tem um apelo de concorrência e programação paralela muito forte e por esse motivo que estou aprendendo ela.

Hoje em dia a maioria das aplicações sejam sites, apps de celular todas tem uma preocupação em fazer com que sejam rápidas e principalmente sejam tolerantes a falhas e trabalhem bem em ambientes que sejam muito requisitados afinal ninguém quer usar um app que fica caindo a cada 5 minutos ou lento quando tem muitas pessoas usando.

_Livro:  Programming Erlang 3nd edition do Joe Armstrong que é quem criou a linguagem livro muito foda._

##Design e experiência de usuário

Quem não gosta de usar um app bonito e em que as funções façam sentido, as vezes nós como programadores ficamos presos somente em programar e esquecemos do usuário em como ele vai usar, se a experiência que ele teve com o app foi boa ou achou ao menos o app bonito.
_Livro: Refactoring UI do Adam Wathan e Steve Schoger_

##Frontend

Pode parecer um pouco generalista demais mas é basicamente 3 coisas que quero estudar bastante CSS, JavaScript puro saber como funciona realmente (node também  estou falando de você) e depois disso voltar ao React que é uma ferramenta que gosto muito.

_Livro: Eloquent JavaScript do Marijin Haverbake_

##Fé no pai que o cluster não caí

Espero que tenham se interessado pelo desafio, depois do desafio espero ler isso aqui e saber que consegui e falar como foi a experiência.
Flw meus consagrados e consagradas até mais 🤟
100daysofcode Flutter
Tags: 100daysofcode, flutter
Published: 2020-04-12 16:30:49

day 34/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Today implements constructor, mapping data, make list , some logic
https://github.com/triyono777/100-days-of-code/blob/master/log.md
What tools do you use to build your resume? 
Tags: discuss, resume
Published: 2020-04-12 16:14:41

---
title: What tools do you use to build your resume? 
published: true
description: 
tags: #discuss #resume
---

In these times a lot of devs find ourselves updating our resume, either by necessity or "just in case". So I was curious about what is people using in this time to build their resumes, maybe a good old plain doc? Or some fancy illustrator template? 

What is your prefered way to build a resume in 2020?
Use Google docs for Journaling
Tags: productivity, writing
Published: 2020-04-12 16:11:35

There are a ton of articles which speak about the benefit of journaling, here i am going to write about how you can use google doc script feature to use google docs for journaling. 

Step 1: Login to your google account and create a google doc sheet. Lets name it Journal and save it

Step 2: On the toolbar goto Tools  -> Script editor 

replace the function with the function below 

```

function onOpen() {  
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var date = Utilities.formatDate(new Date(), "IST", "dd-MMM-yyyy hh:mm:ss");    
  doc.getBody().appendParagraph('Date: ' + date);
  var paragraph = doc.getBody().appendParagraph('');
  var position = doc.newPosition(paragraph, 0);
  doc.setCursor(position);
}

```

name the project as DateOnOpenDoc and save it

Step 3: Now click on run icon on the tool bar, google will ask you for permission to run the app. Click allow on the set of pages you get ahead.

Now if you see in the google doc sheet, you can see current date and time printed on the sheet

That's it guys. You have created a simple journaling app for yourself. Totally free of cost

From now on every time you open the google doc you will see current date and time printed on the sheet. This will help you track your daily thoughts and organise your life
Learning ReactJs
Tags: react
Published: 2020-04-12 16:08:08

React is a popular framework of javascript developed by the facebook. React is one of the most demanding framework in 2020. Like others vue and angular react is also most top-rated and powerful tool for frontend as well as server side uses.

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

Learning React is one of my dream that i Use to see. Now in this holiday due to covid-19 (lockdown) I tried to learn something new at home. So I follow my dream and start learning React Js. Previously I have work with vuejs and laravel. So due to some basic knowledge of vuejs understanding react was quite helpful. I have gone through the office documentation fo react js (reactjs.org).Not only the documentation I have gone questioning with my seniors and with all those I came to know the most important part of react are:
1.props
2.state
3.component
We need to understand what they are and how they works. 
Simply props are the passed values from one component to other.
state is a object of a set of observable properties that control the behavior of the component.
Components are the building blocks of any React app and a typical React app will have many of these.
Not only the documentation I have gone through videos. But i have never continue the same thing what they did.  
I have practise with the latest style of coding using functional component and react hook. (useState & useEffect).

One of the major problem what I suffer from is what should I do to learn more. What kind of Project I go through. 



So firstly I choose them:
-> todo
-> github finder
->covid-19 data collector using api from rapid api 
-> eventmanager with redux 

So What Redux ?
Redux is an open-source JavaScript library for managing application state. It is most commonly used with libraries such as React or Angular for building user interfaces.
I will cover redux with next post.

happy Coding...
A question during my interview for a Front End Developer Position and my solution
Tags: javascript, algorithms, sorting, interview
Published: 2020-04-12 16:07:35

Hello dear friends!

So! Recently, I have been looking for new job opportunities and applying through LinkedIn, and then a company reached me and provide a test on Hackerrank which consists of 4 different questions. 2 of them are related HTML/CSS and dom manipulation, and the other 2 are about algorithmic thinking with programming language of your choice.(It would be obvious advantage to choose Javascript, I guess.( duh? ))

Enough with chit-chat and gibberish talking, I am now going to trying to demonstrate and explain a bit my simplistic naive solution.

Essentially, the question asks to sort an array based on both its values and number of occurrences of the elements.

For example;

```javascript  
//If the array is like this:
[4,5,6,5,4,3]
//You need to return something like this:
[3,6,4,4,5,5]
```

Firstly, I was thinking that I would be creating an object to hold the numbers as keys and their occurrences as values. 

```javascript
//To hold the frequency info for each element within items
let frequency = {};

 items.forEach((value) => { 
        if ( value in frequency ){
            //Once you run into the number again, 
            //increment the respective elements' value of the frequency object
            frequency[value] = frequency[value] + 1;
       }
        else{
            //If you run into number for the first time
            frequency[value] = 1;
       }
    });
```

After that, I tried checking each entry of the frequency object and then sort the elements based on the number of occurrences.

```javascript
//Create a 2D array based on 
//the number of occurrences of the elements, e.g. make the object iterable

  const sortedValues = Object.entries(frequency).sort((a,b)=>{
      return a[1]-b[1]
  })
```

Yes, but right now I have one weird looking two dimensional array, in which, each element is also an array that holds the again the information about frequency. So, I just created another array which is going to be filled based on the numbers' occurrences.

```javascript
// Here, for each element of our 'sortedValues' 2D array,
// I populate the element as many as of its number of occurences,
//then creating a flattened array at the end(the part with reduce and concat)
const sortedArr = sortedValues.map(sortedValue => 
[...Array(sortedValue[1]).fill(sortedValue[0])]).reduce((a, b) => a.concat(b), [])
```

So, the resulting array that I acquire after this step is the expected result.

Solution link: https://repl.it/@TahsinYazkan/Sort-an-array-by-frequency-and-value

If you bear with my writing up until this point to finish reading my post with a minimum about of eye-rollings and yikes, thanks a lot!

It really means a lot for me, because this is my first public post on this planet :D and I am talking about some technical subjects for the first time in my life and English is obviously not my mother tongue.

If you have any questions and any problems, shout at me through private message or in the comments.
Javascript FAQ
Tags: javascript
Published: 2020-04-12 15:20:11



#### 创建自定义事件

> [CustomEvent](https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent)

```javascript
let customEvent = new CustomEvent('custom-evt', {
  detail: { someKey: 'value..' }
});

document.dispatchEvent(customEvent);

// 捕获事件
document.addEventListener('custom-evt', function(e) {
  console.log(e.detail);
});
```

#### Node.textContent 属性可以表示一个节点及其后代节点的文本内容

```javascript
var text = element.textContent;
element.textContent = 'this is some sample text';

// 给定如下HTML:
//   <div id="divA">This is <span>some</span> text</div>

// 获得文本内容:
var text = document.getElementById('divA').textContent;
// |text| is set to "This is some text".

// 设置文本内容:
document.getElementById('divA').textContent = 'This is some text';
// divA的HTML现在是这样的:
// <div id="divA">This is some text</div>
```

#### 什么是弱类型的

Loose typing means that variables are declared without a type.
弱类型指的是在申明变量的时候不指定变量的类型

```JavaScript
/*JavaScript Example(loose typing)*/
var a=13;// Number declaration
var b="thirteen";// String declaration
```

```java
/*Java Example(Strong typing)*/
int a=13; // int declaration
string b="thirteen"; // String declaration
```

#### 什么叫纯函数

一个函数的返回结果只依赖于它的参数，并且在执行过程里面没有副作用，我们就把这个函数叫做纯函数。

#### 什么叫 shim

shim 垫片的意思，指把一个库引入另一个旧的浏览器，然后用旧的 API 来实现一些新的 API 功能。

#### 常见 DOM 的操作

```javascript
  // DOM查找
  let ul = document.querySelector('ul');
  let firstChild = document.querySelector('ul li:first-child');

  // DOM创建 Element
  // element = document.createElement(tagName[, options]);
  let newLi = document.createElement('li');
  newLi.textContent = '5 ipsum amet.';

  // DOM 创建 textNode
  let textNode = document.createTextNode('pu guohong');
  document.body.appendChild(textNode);

  // DOM 添加
  // element.appendChild(aChild);
  ul.appendChild(newLi);

  // DOM 替换
  // 返回的是被移除的DOM
  // replacedNode = parentNode.replaceChild(newChild, oldChild);
  let r = ul.replaceChild(newLi, firstChild);
  console.log(r);

  // DOM 移除
  // 移除第二个li
  // oldChild = node.removeChild(child);
  // or node.removeChild(child);
  ul.removeChild(ul.children[1]);

  // 插入
  // insertedNode = parentNode.insertBefore(newNode, referenceNode);
  ul.insertBefore(newLi, ul.lastElementChild);

  // dupNode = node.cloneNode([deep]);
  // deep=true|false
  let cloneUl = ul.cloneNode(true);
  document.body.appendChild(cloneUl);
```
Hello dev.to :)
Tags: python, datascience, c, machinelearning
Published: 2020-04-12 16:01:39

I am interested in python programming, datascience, machinelearning, datavisualizaton and c programming. I am a blogger for programming experince share other people. After this blog a share. You can follow me medium and github. Goodbye

https://github.com/blalyasar/
https://medium.com/@blalyasar
Docker Cheat Sheet
Tags: docker, linux, devops, productivity
Published: 2020-04-12 16:00:22

### CONTAINERS
- Start a running container from an image
 `docker run -ti ubuntu bash`

- List running containers
 `docker ps`

- List all containers (running + stopped)
`docker ps -a`

- List last container 
`docker -l`

- Delete a container after it finishes
`docker run -ti --rm ubuntu bash`

- Commit a container and create a new image from it. First find the container id or its name then run the following command. Lets say 1234 is container id and my_container is the name
`docker commit 1234 new_image_name`
OR
`docker commit my_container new_image_name`

- Attach an existing running container
`docker attach name_of_container`
- Now leaving container wihtout exiting it
`press and hold ctrl + p, ctrl + q`

- docker exec creates a new process in the existing container. Although it will die automatically if you close the original process

- docker logs will print the logs of the container
`docker logs container_name`

- docker kill will kill the running container
`docker kill container_name`

- Removing containers
`docker rm container_name`

- If the outside ports are not assigned then it will choose any available port. To see which port it choose, run the following command
`docker port container_name`

### NETWORKS
- For displaying list of already existing networks.
`docker network ls`

- For creating a new network
`docker network create new_network_name`

- for starting a container within a network
`docker run -ti --net my_network_name --name my_container_name ubuntu bash`


### VOLUMES
 - 2 main varieties of volumes
	**Persistent** --> they will still exist when the contaner is stopped 
 	**Ephemeral** --> they will be gone when no one (container) is using them

- Sharing a volume with the host (Persistant)

          `docker run -ti -v /full/path/to/folder:/shared_folder ubuntu bash`

- Sharing a volume b/w containers using volume-from (Ephemeral)
`docker run -ti -v /shared-data ubuntu bash`
	 - In above command Im creating a shared volume on the container that is not shared with the host
	 - Now create another container and shared the above volume with the new continer

              `docker run -ti --volume-from above_container_name ubuntu bash`
	 - Now important note: The above volume will be available as long as atleast one container is still using it. when no container is active that volume will disappear

Git Repo: https://github.com/hasanmehmood/docker-cheat-sheet