teleren/devto huggingface dataset:
Refactoring 008 - Convert Variables to Constant
Tags: javascript, webdev, beginners, programming
Published: 2022-08-26 12:17:48

*If I see a Variable that does not change. I call that variable a constant*

> TL;DR: Be explicit on what mutates and what does not.

# Problems Addressed

- [Mutability](https://dev.to/mcsee/the-evil-powers-of-mutants-1noo)

- Code Optimization

# Related Code Smells

{% post https://dev.to/mcsee/code-smell-158-variables-not-variable-39ke %}

{% post https://dev.to/mcsee/code-smell-127-mutable-constants-26dj %}

{% post https://dev.to/mcsee/code-smell-116-variables-declared-with-var-5mj %}

# Steps

1. Find the scope of the variable

2. Define a constant with the same scope

3. Replace the variable 

# Sample Code

## Before

[Gist Url]: # (https://gist.github.com/mcsee/3ae265e1ae7422164c175b16a7f822d3)

```javascript

let lightSpeed = 300000;

var gravity = 9.8;



// 1. Find the scope of the variable

// 2. Define a constant with the same scope

// 3. Replace the variable 

```

## After

[Gist Url]: # (https://gist.github.com/mcsee/e25d1ded85b4547d20fee70e4c1f0ca6)

```javascript

const lightSpeed = 300000;

const gravity = 9.8;



// 1. Find the scope of the variable

// 2. Define a constant with the same scope

// 3. Replace the variable 



// If the object is compound, 

// we might need Object.freeze(gravity);

```

# Type

[X] Automatic

Our IDEs can check if a variable is written but never updated.

# Safety

This is a safe refactor.

# Why code is better?

Code is more compact and declarative.

We can make and step further and use operators like *var*, *let*, *const*, etc.

The scope is more clear.

# Tags

- Mutability

# Related Refactorings

{% post https://dev.to/mcsee/refactoring-003-extract-constant-4j5p %}

# See also

{% post https://dev.to/mcsee/the-evil-powers-of-mutants-1noo %}

* * * 

This article is part of the Refactoring Series.
Poliview - Your smart compass to the political world
Tags: redishackathon
Published: 2022-08-26 12:12:58

### Overview
Poliview is a political analysis tool for understanding the politics behind companies. See where companies and their employees donate their money. Get a political score for how liberal or conservative a company is. And much more!

This web app was built using Redis as it's primary databases for it's blazing fast speeds and edge compatibility. Using Redis along with Upstash (how ever if we built it again we would use Redis Cloud as it's more reliable) we were able to store JSON easily and quickly retrieve it.


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

I was inspired to build this because I was tired of companies making political stands with ideas I do not agree with. I wanted to be able to see which companies had made political stands and choice not to support them.

**Please note:** This product was not intended to be open-source, but we have open-sourced the frontend to be able to show off how powerful Redis Database is. I have made the front end licensed under [MIT](https://choosealicense.com/licenses/mit/). Installing Poliview locally is not recommend and would be very difficult instead check out a [live demo](https://poliview.sellersew.com).



### Submission Category: 
MEAN/MERN Mavericks


### Language Used
JS/TS/Node.js

### Link to Code
[Poliview Frontend on Github](https://github.com/SellersEvan/poliview-open)
[Poliview Live Demo](https://poliview.sellersew.com)


### Collaborators
@sellersevan 


- - - 

* _Check out [Redis OM](https://redis.io/docs/stack/get-started/clients/#high-level-client-libraries), client libraries for working with Redis as a multi-model database._
* _Use [RedisInsight](https://redis.info/redisinsight) to visualize your data in Redis._
* _Sign up for a [free Redis database](https://redis.info/try-free-dev-to)._
BUILDING AMAZING PRODUCTS WITH THE RIGHT DESIGN CHOICES.
Tags: webdesign, uiux, product, design
Published: 2022-08-26 12:07:14


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

Product design is the process of imagining, creating and iterating problems to solve the needs of users and meet the business goals in a given market. The art of building can be seen as a way of communicating or solving a problem.
 
Sometimes it takes a very long time to come up with design specifications for the right product. All this is due to the weight of the project and purpose.

Design always puts the “user” first in everything. There are two aspects to product design.

They are;
1. User Interface Design (UI)
2. User Experience Design (UX)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9bvl7ii8aw5bfzmg26c.png)
All starting with the word “user” obviously cements the former explanation to user centering. Every product is built to suit a user’s purpose, style and preference. A perfect product combines the two aspects to achieve a complete and perfect package to user satisfaction.

There are also some things to consider when building functional products. These are **aesthetics, ergonomics, modularity, materials etc**. These aforementioned elements help in the way the design appears and looks always with the user in mind.

**User Interface (UI)**

User Interface is defined as communication between two or more things more so human-computer interaction in a device or product. This way through which the user interacts with the product, application or website. 

The UI is often talked about in conjunction with user experience UX, which may include the aesthetic appearance of the device, response time and the content that is presented to the user within the context of the user interface.


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

**User Experience (UX)**

User Experience is how a user interacts with and experiences a product, service or system. The first requirement for an exemplary user experience is to meet the exact needs of the customer, without fuss or bother. 
The addition of simplicity and elegance that produce products that are a joy to own and a joy to use. User experience goes far beyond giving customers what they say they want, or providing checklist features.

The right amount of everything makes a design a perfect fit for a product. Making the right choices and reassessing whatever is needed to make a product work to the users advantage whether it’s a mobile or web application.
Join Setplex at IBC Show 2022
Tags: ibc
Published: 2022-08-26 12:02:00

If you’re a content provider looking for an end-to-end [IPTV/OTT platform](https://setplex.com/en/), and the best in OTT middleware and white label app creation, stop by our booth at the convention!

On September 9-13 2022, Setplex will join other innovators, digital pioneers, and content experts at IBC Show 2022 at the RAI Convention and Exhibition Centre in Amsterdam, the Netherlands.

### Why Visit Setplex?
We are pioneers in the IPTV/OTT industry. In an ever-evolving streaming world, Setplex maintains its leadership in IPTV/OTT software. We scale with you. Our goal is to constantly innovate, delivering best-in-class software, with the highest quality user experience.

We’re in the business of technological innovation, creating groundbreaking IPTV/OTT systems that transform how end users consume content and interact with all kinds of media.

**Book a Meeting with Setplex**
Or **stop by Booth #5.A75**

### About the IBC

The International Broadcasting Convention, commonly known as IBC, is Europe’s largest Technology, Entertainment, and Media show.

IBC Show’s unparalleled exhibition and conference encompass the very latest developments in broadcasting, IPTV, mobile TV, R&D (research and development), and digital signage making it essential for everyone’s understanding of the industry and its future.

IBC Show 2022 includes technological exhibitions and attractions, dynamic thought leadership sessions, workshops and training sessions for content creators and designers, and a number of other events that help content and technology leaders explore innovative possibilities, make valuable connections, learn from industry leaders, and enjoy the best content technology (and Amsterdam, Netherlands) have to offer.

Originally published at [Setplex Blog](https://setplex.com/blog/join-setplex-at-ibc-show-2022/)
Using nginx to look for files by server date, e.g. 2022-07-10.json
Tags: beginners, nginx, server
Published: 2022-08-26 11:57:08

I ran into an instance recently where I wanted a low cost solution to serving up pregenerated files by date on the server.

We couldn't allow users to fetch on their by query string or similar; the server had to be in charge.


```nginx
location /example-endpoint {
    set $file "index.json";

    if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})") {
        set $file "$1-$2-$3.json";
    }

    index $file index.json =404;
}
```

This will look for a file of `2022-07-10.json`, default to `index.json`, and then a 404.

It allows you to setup a lot of pregenerated content on the server that changes per day without the ability to skip ahead. 

No additional processing required.
Survey: Understanding Overlap in Automatic Root Cause Analysis in Manufacturing Using Causal Inference
Published: 2022-08-26 11:53:16

## 選定理由

あまり有名な出どころではないが、製造業×因果推論が比較的新しい＆レアなので。

Paper: https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9664533
Code: N/A

## 概要

[社会課題]製造業の生産プロセスは非常に多くの要因が複雑に絡み合い影響を与えるため、KPIとなりうる要因を[根本原因分析](https://ja.wikipedia.org/wiki/%E6%A0%B9%E6%9C%AC%E5%8E%9F%E5%9B%A0%E8%A7%A3%E6%9E%90)(RCA:Root Cause Analysis)するには多くのデータ分析を必要とする。特に、オーバーラップは問題を複雑化させてしまう[[Oliveira2021](https://www.tandfonline.com/doi/abs/10.1080/00207543.2021.1992680)]。(図１)

![fig.1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/584xd9a5immclqz6gofq.png)

オーバーラップという単語の意味の定義は[Oliveira2021]のアブストによると以下のようにしている。

> Overlap, as we denominated, is a phenomenon where local synchronicities in the manufacturing process lead to data where it is impossible to discern the influence of each location in the quality of products, which impedes automated diagnosis, especially when using classifiers. 
 
[技術課題]オーバーラップがある場合は異なる製造工程から生成されるデータに擬似相関が生まれ、正しく因果関係を捉えられない。
[提案]オーバーラップがある製造工程を因果推論でモデル化し、本来の因果関係を識別するのに必要な条件を定式化する。又、その結果として要因群の中から正しい根本原因(Root Cause)を推定する。
[効果]（因果推論に頼らない）PMIの手法と同等の結果を得ることができた。

## 因果推論でのオーバーラップのモデル化

オーバーラップ、製造工程、生産物の因果モデルは以下のようにした。

![Fig.4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbjlhbh49fzu4h7opk3n.png)

この因果モデルにおいてタプルXiがone-hotベクトルであることが因果モデルを識別可能であることの必要条件であることは以下の式10から導くことができる。

![eq.10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ct8cbkvmr3icxfo2l9l0.png)

因果効果の定量化には様々なアプローチがあり、本研究では式13-15でこれらの因果効果を定式化した。

![eq.13-15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwujels4ybik8uxhdvu4.png)

なお、先行研究として比較しているPMIは相互情報量に似た依存関係の算出法である。

![eq.1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oaaqchhqjxuux8cjmzlh.png)
 
## 実験

### モックアップデータの作成

図6はモックアップデータの因果モデルを表す。εuはノイズ・干渉の影響を受ける確率を表し、この値が高いほど因果効果の伝搬が妨害されることを示す。又、εuは

![fig.6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wwp59hu2akz5bjw8wr0f.png)
 
### 実験結果

表５はモックアップデータでの実験を示す。εu が一定の値（1.00E-03）以上であれば、オーバーラップの影響力が減り、すべての因果効果値において要因を特定可能であることを示している。逆に小さい値であればオーバーラップの影響が強くなり因果効果を識別できていないことがわかる。

![table.5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77dj8q54y084b5j32s1l.png)

同様にεl に対する実験では表6のような結果である。εl は因果効果の識別に対してあまり影響力を持たないことがわかる。

![table.6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8377awftb02du48m3i7.png)
 
## Future Work

- 主要因が定義されない・不明なデータにおける要因分析
- より複雑な因果関係を持つ場合の要因分析：複数の主要因、主要因間が関連しあう
- ロジスティクスといった他の産業セクタやサプライチェーン分析への適用
Portfolio🌟👩‍💻
Tags: programming, css, github, html
Published: 2022-08-26 11:49:55

Hello, this is a sample website in collaboration with Kian and Arman Ebtekari 🤝

My Project Link https://github.com/Armanebtekari/Portfolio

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfh3tjxgauifzrgh54mk.png)
RustDesk is migrated from Sciter to Flutter
Tags: flutter, rust, dart, javascript
Published: 2022-08-26 11:33:00

Yesterday, the RustDesk project officially merged the flutter_desktop branch into the master branch in preparation for the final release.

The first desktop version of RustDesk used Sciter. The primary reason for choosing Sciter was its light weight, but Sciter is not open source. The author of Sciter launched an open source Kickstarter last year, but it failed.

We decided to migrate in this May, and hosted an discussion about chosing Flutter or Tauri, https://github.com/rustdesk/rustdesk/discussions/533.

Now RustDesk fully embraces Flutter, Flutter is adopted on all platforms (iOS / Android / Windows / Linux / Mac / Web). But since Flutter does not support 32bit Windows, Sciter still has to continue to serve for 32bit Windows.
How to declare a good variable name in programming.
Tags: beginners, programming, python, variable
Published: 2022-08-26 11:26:15

**1.What is a variable**
A variable can be a empty container in which we can store some data.

**2.Points to remember while declaring a variable**

- The variable name may start with a underscore or a letter.
- It can not start with a digit or a symbol. For example-7,4,%,!,?,etc.

- Variable can only contain letters, underscores, or a digit after a digit. For example-a=10
        a_2=12,etc.
**3.Examples**
1. 

```
num1_list1=['science', 'history', 'mathematics']
print(num1_list1)
```
Output:
['science', 'history', 'mathematics']

2.
```
_123=("dev community")
print(_123)
```
Output:
dev community

3.

```
foo="Hello"
print(foo)
```
Output:
Hello

4.

```
my_tuple = (1, 2, 3, 4)
print (len(my_tuple))
```
Output:
4
iOS — Drag and Drop using CollectionView
Tags: ios, drop, swift, swiftui
Published: 2022-08-26 11:25:15


Do You Know How to Implement [Drag](https://blog.canopas.com/android-drag-and-drop-ui-element-in-jetpack-compose-14922073b3f1) and Drop Using CollectionView in [iOS](https://blog.canopas.com/ios-dev-import-music-from-users-device-using-document-picker-98e3e76d83c5)?

In this blog post, we will implement Drag and Drop functionality with UICollectionView using [swift](https://blog.canopas.com/ios-persist-data-using-sqlite-swift-library-with-swiftui-example-c5baefc04334).

Today, we’ll create a food order book, that shows a list of food items with the list of persons. Users can select food items and drop them off to the person paying for them.

I’ve tried to make this Drag and Drop functionality as easy as possible.
At the end of this blog post, we’ll have UI something like this.


We’ll divide implementation into 3 simple steps to make each step easy to understand.
Design Views to show food items and users
Implement drag delegate
Implement drop delegate

For step by step guide, visit [canopas blog](https://blog.canopas.com/ios-drag-and-drop-collection-view-cell-using-swift-ea21d1f4045c).
Bye Bye Heroku
Tags: webdev, programming, cloud
Published: 2022-08-26 11:20:46

If you are a developer, you might have used or heard of [Heroku](https://www.heroku.com/).

Heroku is a cloud programming platform designed to help build and deploy online applications. 

Founded in 2007, it is now one of the largest PaaS platforms in existence, with hundreds of thousands of customers spread around the world. 

It supports six programming languages (through which to develop apps for distribution on the Web) and is based on the Debian operating system or, more recently, Ubuntu (two Linux distributions).

## Goodbye Heroku

According to a recent update, "Starting October 26, 2022, we will begin deleting inactive accounts and associated storage for accounts that have been inactive for over a year. Starting November 28, 2022, we plan to stop offering free product plans and plan to start shutting down free dynos and data services. We will be sending out a series of email communications to affected users".

### Why is this a pity?
Because many people/students/dev have their first experience with deploying an application on Heroku!
And to be honest, the quality of the environment was pretty good, even in terms of analytics.

## What's next?
I am sure many will move to other platforms to deploy their apps. Vercel, Netlify, GitHub Pages are all good options.
Do you know more?
Emacs
Tags: emacs
Published: 2022-08-26 11:15:00

Okay guys as promised today am going to get into Emacs Editor and if you haven't seen my blog on vi(visual Editor) just Check it out.
Emacs or EMACS is a family of text editors that are characterized by their extensibility.
Emacs include some extra futures like:

- Supporting many different human languages and programming/markup languages.

- tools for compiling, running, and testing programs. Emacs integrates with GDB to provide an IDE.

- compare two files and highlight their differences. 

- read news, mail, and RSS feeds. 

- You can even play tetris in Emacs

Fist before we start Emacs we need to learn this basic concepts 

- C -means Ctrl on your keyboard

- M -means Alt on your keyboard(Esc key)
 

---

## Starting Emacs

**To enter emacs type**

`emacs`
Here you will find all the instructions. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7w2q99frqwiv1my6g6r.png)

**To open a file**

`emacs <file_name>`

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yeaw2wc8s6154rs7wa0m.png)
**To close emacs and save**

`C-x C-c`

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

**To get out of the command**
`C-x C-g`

**To open a file**
`C-x C-f`

**To save the Changes**

`C-x C-s`

---

## Moving around

Some of the commands for movement in Emacs are:

`C-f  Forward one character`
`C-b  Back one character`
`C-n  Next line(Down)`
`C-p  Previous line(up)`

`C-a  Beginning of line`
`C-e  End of line`
`M-f	Forward one word`
`M-b	Back one word`
`M-a	Previous sentence`
`M-e	Next sentence`
`M-v	Previous screen`
`C-v	Next screen`
`M-<	Beginning of buffer`
`M->	End of buffer`

## Killing ("cutting") text

To cut a text in Emacs we use the command

`C-k	Kill line`

## Yanking ("pasting") text

To paste a text in Emacs we use the command

`C-y	Yanks last killed text`
`M-y	Replace yanked text with previously killed text`

## Undo

To undo the changes in Emacs

`C-/	Undo`

## Searching 

To search in Emacs

`C-s	Incremental search`

> Tip: for more info see the Emacs official Documentation [Emacs](https://www.gnu.org/software/emacs/tour/)
Amazing JavaScript Games | Play Now
Tags: tutorial, webdev, beginners, javascript
Published: 2022-08-26 10:36:01


![Amazing JavaScript Games | Play Now](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t04shq5tnaqkjb3hhetd.jpg)
In this enjoyable article, we’ll take a look at the fantastic JS13K sport Amazing JavaScript Games drawback. It is an annual coding competitor that places large proficient JavaScript builders to exhibit their video games made with solely 13kB of code or a lot much less.

We have now chosen just a few of our favorite video games from the closing yr to share with you. Get pleasure from them as a tiny gaming break from work or as a provider of coding inspiration!

## Amazing JavaScript Games

Tablet of Content 🙂

1. Everyone’s sky
2. Konnekt
3. Raven
4. Off The Line
5. Spacecraft
6. Re-wire
7. Strategies Offline
8. Offline Paradise
9. Super Chrono Portal Maker

## Everyone’s sky

Everyone’s sky provides the basic Asteroid model sport however with a journey and exploration RPG twist. You fly around the area and its photo voltaic methods, contacting different civilizations and accumulating assets. You may select to finish missions peacefully, make allies, or simply assault every little thing that is available in your approach.

## Konnekt

Konnekt: This can be an easy real-time-strategy recreation of the place a virus has contaminated a few of your system’s nodes and you must clear them earlier than they unfold. The sport is admittedly addicting and the extra you play, the more durable it will get and the extra nodes it’s important to cope with.

Read More : [Amazing JavaScript Games | Play Now](https://softcodeon.com/javascript/9-amazing-javascript-games-play-now.htm)
[Python]Control MS paint to draw a pixel style logo automatically
Tags: tutorial, python, productivity, opensource
Published: 2022-08-26 10:32:00

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

 
1. Firt of all, perpare a simple piture.
2. Install Python package:
 - `pip install opencv-python`
 - `pip install clicknium` 
> `opencv-python`: CV library. Load image and convert to a pixel style graph. 
> `clicknium`: Automation library. Lanch MS paint and control the mouse to pain the picture.   

3. Search and install `clicknium` in VS Code extension market.   
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxqnhghynqdbweode0s0.PNG)
4.  Get the source code
`git clone https://github.com/automation9417/mspaint-draw-img.git`
5. Use VS Code to open the souce code folder and press `F5`to run. Use Shift+F5 to stop.

You can also build your own automation task using Clicknium. This tool is very easy to use. You can use the Recorder to Capture UI element for both Windows applications and web browser. It will auto-generate the locator to help you to locate and control the UI elements. 

The Python script can also be package to a executable file and send to other people. Draw a something special or type some words that you want to speak to the one. 

More detial please check the [doc](https://github.com/clicknium/clicknium-docs)