teleren/devto huggingface dataset:
Code Smell 152 - Logical Comment
Tags: javascript, webdev, beginners, programming
Published: 2022-07-24 20:45:18

# Code Smell 152 - Logical Comment

![Code Smell 152 - Logical Comment](belinda-fewings-73XDjmZQo6Y-unsplash.jpg)

*Temporary hacks might be permanent*

> TL;DR: Don't change code semantics to skip code.

# Problems

- Readability 

- Non-Intention Revealing

# Solutions

1. If you need a temporary hack, make it explicit

2. Rely on your source control system

# Context

Changing code with a temporary hack is a very bad developer practice.

We might *forget* some temporary solutions and leave them forever.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/a07a71db83f2c65adefffd736e77ee91)
```javascript
if (cart.items() > 11 && user.isRetail())  { 
  doStuff();
}
doMore();
// Production code

// the false acts to temporary skip the if condition
if (false && cart.items() > 11 && user.isRetail())  { 
  doStuff();
}
doMore();

if (true || cart.items() > 11 && user.isRetail())  {
// Same hack to force the condition
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/174010435acb2c12f45124f2a085fa51)
```javascript
if (cart.items() > 11 && user.isRetail())  { 
  doStuff();
}
doMore();
// Production code

// Either if we need to force or skip the condition
// we can do it with a covering test forcing
// real world scenario and not the code

testLargeCartItems() {}

testUserIsRetail() {}
```

# Detection

[X] Semi-Automatic 

Some linters might warn us of strange behavior.

# Tags

- Comments

# Conclusion

Separation of concerns is extremely important in our profession.

Business logic and hacks should always be apart.

# Relations

{% post https://dev.to/mcsee/code-smell-151-commented-code-5d8l %}

# Credits

Photo by [Belinda Fewings](https://unsplash.com/@bel2000a) on [Unsplash](https://unsplash.com/s/photos/road-closed)  

Thanks @[Ramiro Rela](@racter) for this tip

* * *

> You might not think that programmers are artists, but programming is an extremely creative profession. It's logic-based creativity.

_John Romero_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Day 106: No work
Published: 2022-07-24 20:40:06

Hi!
There was no work today I wanted to work but I couldn't I was in a bad mood to do anything so I took the day for relaxation and rest as it should have been in the first place. I didn't continue the Figma course either so I think I will go through it again next weekend or mid week If I will be able to pare some time. tomorrow I expect to get back to React work I don't have a week plan yet so I will probably go through it as well tomorrow it will be a long one. see you there

signing off...
My list of plugins I use daily and why. 🔌
Tags: wordpress, plugin, productivity, discuss
Published: 2022-07-24 20:33:23

So WordPress still powers around 30% ⚡ of the worlds sites, which roughly equates to 455 million websites<sup>[1]</sup>. I'd estimate that each site using a least one plugin, wether that be create custom post types, or protect their site from spam comments or contact form submissions. 

I have a certain plugin suite to extend WordPress, below is the list of plugins we use and why we use them. So lets just dive straight into them!

## ACF (Advanced Custom Fields)
[Link to ACF](https://www.advancedcustomfields.com/)

ACF allows developers to add different types of components to pages, templates and custom posts. Ranging from simple text and WYSIWYG fields, to gallery and repeating fields.

We use ACF as we build bespoke websites and this helps us build templates, quicker and easier.

## Gravity Forms
[Link to Gravity Forms](https://www.gravityforms.com/)

Gravity Forms is the form builder we use. Yes, we could have chosen Ninja Forms, Formidable, or even Contact Form 7. But we realised quickly there were a-lot of extensions that will allow us to use Stripe, or extending it to use our marketing software Campaign Monitor. It's simple, and easy to build forms and allows dynamic data so we can change fields depending on links.

## EWWW.IO
[Link to EWW.io](https://ewww.io/)

EWW is an image optimiser that allows you to delivery highly-optimised but still delivering high-quality images. We can also delivery images in WEBP format [read more on WEBP from Google](https://developers.google.com/speed/webp)

These are our core suite of plugins, use anything different of similar? Comment below, I'd love to hear your thoughts!

[1] [What Percentage of Websites are WordPress in 2022?](https://techjury.net/blog/percentage-of-wordpress-websites/#gref)
How to use icons in your HTML code using fontawesome
Tags: javascript, webdev, beginners, programming
Published: 2022-07-24 20:25:09

## in this Article i will give you How to get and use icos in your website Step bt Step.

## click Here =>[How to add icons in your website step by step](https://lodstare.blogspot.com/2022/07/addicons.html)
## connect with me on : 
- [YouTube](https://www.youtube.com/channel/UCEDF5YBStH5cWnqK2U4BCkw)
- [Twitter](https://twitter.com/ayoub_el_achab)
- [Instagram](https://www.instagram.com/ayoub_el_achab_/)
- [Git Hub](https://github.com/Lodstare)
- [Linkedin](https://www.linkedin.com/in/ayoub-el-achab/)
Tricks to overcome your fears while becoming a Dev!
Tags: javascript, react, webdev, beginners
Published: 2022-07-24 20:08:00

**How ​​I Overcomed my fears**

Hey Devs, if you're reading this post, I assume you're trying to become a Dev!, I just wanted to say you're in the right place. Let's dive in...

First, let me tell you a litle story about my journey while becoming a Developer.

In my journey of becoming a frontend developer, I faced many problems like, I was afraid to learn new things, but one day I decided to challenge myself, so I started thinking like this 

> "if Mark Zukerburg made Facebook, why can't, I also create something amazing like so"

he's also a human like me, so what he can do I can do too."

Listen my friend, if you use this mindset, trust me, you will be able to create amazing things.

If you found this Post useful share with others and help them to overcome their fears with this trick!

Do you have a trick, share with us in the comment!

Follow me , See you in my next article!

Github : [@realkevinbrian] (https://github.com/realkevinbrian)
Trade binance futures with freqtrade
Tags: algorithms, datascience, blockchain
Published: 2022-07-24 19:57:25

Freqtrade is a standalone platform. It supports data acquisition, indicators and expert advisors (strategies). You may use backtest with fixed parameters as well as apply optimization to boost the performance. Spot market as well as derivatives usage has been built in.

Beginners may rely on functional web interface. Advanced users may utilize command line interface.

Check config.json to be configured for futures:
1. trading mode
```
        "trading_mode": "futures",

        "margin_mode": "isolated",
```        

2. exchange pairs
```
        "exchange": {
            "name": "binance",
            "sandbox": true,
            "key": "your_exchange_key",
            "secret": "your_exchange_secret",
            "password": "",
            "log_responses": false,
            "ccxt_config": {},
            "ccxt_async_config": {},
            "pair_whitelist": [
                "BTC/USDT",
                "ETH/USDT"
            ],
            "outdated_offset": 5,
            "markets_refresh_interval": 60
        }
```        

Leverage trading requires a custom strategy. For details inspect freqtrade/strategy/interface.py

Read the full article at [https://product-development-service.blogspot.com/2022/06/trade-binance-futures-with-freqtrade.html](https://product-development-service.blogspot.com/2022/06/trade-binance-futures-with-freqtrade.html)
Feed Saxo Bank instruments price into sqlite database
Tags: algorithms, blockchain, datascience
Published: 2022-07-24 19:51:00

Though Saxo Bank has dropped MetaTrader support back in 2015. Open API allows to implement a custom broker.

We are going to consider read-only mode, when price of instruments is continuously put into sqlite database.

Authentication is required prior. A user friendly token generator allows to use a single header instead.
```
def k1(uic, asset_type, token):
    assert re.compile(r'[a-zA-Z]+').match(asset_type)
    with requests.get(
        'https://gateway.saxobank.com/sim/openapi/ref/v1/instruments/details/%d/%s' % (
            uic,
            asset_type
        ),
        headers=dict(
            authorization='Bearer %s' % token,
        ),
    ) as p:
        market_info = p.json()
    assert 'Symbol' in market_info
    return market_info
```  

token is generated at https://www.developer.saxo/openapi/token/current

Available instruments vary between forex, stocks and derivatives.

Read the full article at [https://product-development-service.blogspot.com/2022/06/feed-saxo-bank-instruments-price-into.html](https://product-development-service.blogspot.com/2022/06/feed-saxo-bank-instruments-price-into.html)
Getting started with React & TypeScript
Tags: react, typescript, webpack, beginners
Published: 2022-07-24 19:50:00

This post is inteded for developers looking to get started with frontend development using the following

- React
- TypeScript
- Webpack 5
- SASS

Why the forementioned selection? Well, I would say more of my personal choice. While there are numerous bundlers available in the market, I find Webpack 5 great because of its flexibility and extensibility. I find the combination of the above 4 an easy, as well as great combination for frotnend projects. The Github repository aims to be served as boilerplate code for beginners.

Please refer to the [Github repository](https://github.com/vishalraj82/typescript-webpack5).
Backtest support line bounce based indicator accuracy
Tags: algorithms, blockchain, datascience
Published: 2022-07-24 19:48:26

Support line indicator is based on repetitive extremum points. If say few times in a row price has dropped at some value and then got up. That value is defined as support line. It's likely that it comes close to support line again the pattern will repeat. We are to place an order when this occurs. Stop loss equals support line value. Take profit equals +1% of the entry price. To avoid amount of false positives, we are to use some extra margin like 0.1% during comparisons. So that if price fluctuates around support line +-0.1% we are to wait, until it is either <-0.1% or >0.1% to take the action. If the value drops below support line, indicator didn't work in this case. Otherwise, we are placing an order. To further reduce false positives few times is defined as 3 times, or any other positive number. It can be adjusted later on based on backtest results. But it's not good to optimize all of the indicator constants to avoid over fitting. 

Read the full article at [https://product-development-service.blogspot.com/2022/07/backtest-support-line-bounce-based.html](https://product-development-service.blogspot.com/2022/07/backtest-support-line-bounce-based.html)
My first full stack application and blog! :D
Tags: portfolio
Published: 2022-07-24 19:42:00

#### this is a test blog for my personal portfolio, as i am going to use Dev.to API on NEXT JS


![Grow Media Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgx8h6jt8wure77qbftp.png)

1. football
2. cricket

- football
- cricket

> hi i am tushar

`console.log("hello")`


Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem. Veritatis obcaecati tenetur iure eius earum ut molestias architecto voluptate aliquam nihil, eveniet aliquid culpa officia aut! Impedit sit sunt quaerat, odit, tenetur error, harum nesciunt ipsum debitis quas aliquid. Reprehenderit, quia. Quo neque error repudiandae fuga?

---

Ipsa laudantium molestias eos sapiente officiis modi at sunt excepturi expedita sint? Sed quibusdam recusandae alias error harum maxime adipisci amet laborum. Perspiciatis minima nesciunt dolorem! Officiis iure rerum voluptates a cumque velit quibusdam sed amet tempora. Sit laborum ab, eius fugit doloribus tenetur fugiat, temporibus enim commodi iusto libero magni deleniti quod quam consequuntur! Commodi minima excepturi repudiandae velit hic maxime doloremque. Quaerat provident commodi consectetur veniam similique ad earum omnis ipsum saepe, voluptas, hic voluptates pariatur est explicabo fugiat, dolorum eligendi quam cupiditate excepturi mollitia maiores labore suscipit quas? Nulla, placeat.

`ok`

```
console.log("this is code block");
```


![default profile image of grow media](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2smag29r7b4pvmp9ryhx.gif)




Thank you! :D [**<u>growmedia.click</u>**](https://growmedia.click/)
How variables get instantiated?
Tags: javascript, java, cpp, variable
Published: 2022-07-24 19:35:56

Follow my first article on Medium about the under the hood mechanism of memory instantiation.

[https://medium.com/@djmsuman/how-variables-get-instantiated-698ec1d31ee9](https://medium.com/@djmsuman/how-variables-get-instantiated-698ec1d31ee9)
How to deploy a Kubernetes cluster using Terraform and Ansible on AWS: Use EC2 or EKS
Tags: aws, terraform, devops, ansible
Published: 2022-07-24 19:22:17

While I was in the initial stages of learning Kubernetes, I always struggled to get a quick Kubernetes cluster to work on my practice labs. Though there are many online alternatives available which can be used in such scenarios but somehow I always felt if I could easily spin up a lab environment of my own, it will be good for my learning. Thats when I came up with this process to spin up a basic Kubernetes cluster easily and quickly. The process described here can be a good learning to use Terraform and Ansible in such scenarios too. With modifications to the steps, this can also be used to launch actual clusters in projects.  

For this post, I will go through the process of spinning up a basic Kubernetes cluster using Terraform on AWS. I will cover two ways to launch the cluster:  
  - Using Terraform to launch EC2 instances on AWS and use Ansible to bootstrap and start a Kubernetes cluster  
  - Using Terraform launch an AWS EKS cluster    

More details about the post can be found here: https://amlanscloud.com/terrakubedeploy/
PLEASE SOLVE THIS ERROR
Tags: react, javascript, webdev, programming
Published: 2022-07-24 19:15:49


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/daq446hpnegaq82ngo6j.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6f66hs3wgftxitqdqe8.jpg)
Voltei
Tags: beginners, webdev, css, html
Published: 2022-07-24 19:15:01

Depois de uma pausa nos estudos, de dois meses, por motivos pessoais. Voltei a estudar e dessa vez aproveitei uma promoção que estava tendo na udemy, de [desenvolvedor Web](https://www.udemy.com/course/curso-html5-css3-javascript/), o curso é muito bom, recomendo para quem tem um conhecimento breve de html e css, pois o curso já começa com projeto, algumas coisas não tem explicação aprofundada e o curso contém algumas informações desatualizadas. Não chega a ser um problema, pois se você colocar prática vai ter uma noção melhor, recomendo ler as documentações e usar como base outros sites ;) 

E além de estudos, retomei a um projeto que estava tendo muita dor de cabeça para fazer:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3iwyz6104s7xoaccvv9.png)

Tentei fazer essa landing page varias vezes e tinha desistido, depois de assistir as aulas da udemy decidi volta e finalmente finalizei, ficou um pouco diferente do que tinha planejado mas consegui fazer em uma semana, sem ter dores de cabeça
O [Site](https://gracielle-sampaio.github.io/LandingPage-solnascente/), o [repositório](https://github.com/Gracielle-Sampaio/LandingPage-solnascente)

Além desse site, tem um de receita que também queria retomar, entre outros.

Obrigada quem leu até aqui!
Curso JavaScript Condicionais - parte 2
Published: 2022-07-24 18:41:48

Mais um vídeo novo!!!
Segunda aula sobre condicionais em #javascript 
Estou mais satisfeito com esse modelo de vídeo, mais foco no código durante a produção. Musiquinha tmb ficou show. Segue eu lá!

{% youtube 9hLem1flbww %}
what is the best way to add a social media feed to your app .
Tags: twitterclone, mediafeedapi, socialmedia, help
Published: 2022-07-24 18:28:38

hello
i want to add a small social media page with feed and posts onto a small community mobile app.which is the easiest open source that is also reliable ie it wont dissapear.im a non developer so pointers to developers who can intergrate an open source program would be appreciated
How to add 5 seconds delay without locking up UI using ES6 async/await
Published: 2022-07-24 18:27:08

You will need to promisify sleep function manually.

```
function timeout(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function sleep(fn, ...args) {
    await timeout(3000);
    return fn(...args);
}
```

Btw, to slow down your loop you probably don't want to use a sleep function that takes a callback and defers it like this:

```
while (goOn) {
  // other code
  var [parents] = await Promise.all([
      fn(...args).then(
        //code here
      ),
      timeout(5000)
  ]);
  // other code
}
```
Subdominios vs. Hosts virtuales
Tags: spanish, webdev
Published: 2022-07-24 18:21:22

Es importante entender la diferencia entre subdominios y VHosts porque puede afectar la forma en que se accede a su sitio web y cómo los motores de búsqueda indexan su sitio web. Si no está utilizando el tipo de alojamiento correcto, también puede afectar la velocidad y el rendimiento de su sitio web e incluso ser vulnerable a las vulnerabilidades de seguridad cibernética como el secuestro de DNS, las vulnerabilidades del certificado SSL y las secuencias de comandos entre sitios.

Subdominio
==========

Un subdominio es un dominio de segundo nivel que forma parte de un dominio más grande. Por ejemplo, si tiene un sitio web en `example.com`, puede crear un subdominio en `subdomain.example.com`. Un subdominio se puede usar para crear un sitio web separado, o se puede usar para apuntar a un sitio web o directorio diferente en el mismo servidor.

Host Virtual
============

Un host virtual (VH) es un servicio de alojamiento de Internet que permite a las organizaciones alojar sus sitios web en un único servidor. Un VH se puede usar para alojar varios sitios web, cada uno con su propio nombre de dominio, o se puede usar para alojar varios sitios web que comparten el mismo nombre de dominio. Los VHosts pueden o no tener registros de DNS públicos, por lo que para acceder a su sitio, es posible que deba cambiar los nombres y las direcciones de los hosts en su servidor local (generalmente ubicado en `etc/hosts`) o usar el encabezado `Host:` de un solicitud HTTP.

---


En conclusión, es importante comprender la diferencia entre subdominios y VHosts para garantizar que su sitio web sea accesible y funcione de manera óptima.

Revisa esta publicación en Art Of Code: https://es.artofcode.tech/subdominios-vs-hosts-virtuales/
Shell and REPL
Tags: programming, computerscience
Published: 2022-07-24 18:10:00

A **shell** is a command-line interpreter that **interprets** what user enters in the command-line interface (CLI). And the CLI per se is a computer program for users to interact with computers with text-based UI.

A computer with [Unix-like](https://en.wikipedia.org/wiki/Unix-like) OS such as Linux, usually uses Unix-shell e.g. Bourne Again SHell (bash), TENEX C shell (tcsh), the Korn shell (ksh), the Z shell (zsh), etc. 

A **CLI implements** read, evaluate, print, and loop (**REPL**) to make the interface interactive. It will loop until there is a condition that makes the process: read, evaluate, and print terminate.

However, those are some programming languages that have their own shell e.g. Python, Java, Clojure, NodeJS, etc. In Java, we will use java shell (JShell) in our CLI in order to interpret java syntax entered. In general, people call a CLI that uses JShell as Java REPL, it goes the same for other languages. 

Actually, I am still figuring out the main purpose of a programming language REPL. We usually use IDE to develop a program with necessary, helpful, and important features inside. Presumably, because it only executes a unit of code, so it will be helpful to test atomically through REPL instead of running the program entirely. Honestly, I prefer to use [replit.com](https://replit.com/) for that case.

Popped in my head, if you inspect your browser and go to the console tab, it uses JavaScript. Yeah, I think that’s the best approach for a programming language REPL appearance.
Subdomains vs. Virtual Hosts
Tags: webdev
Published: 2022-07-24 18:07:00

The difference between sub-domains and VHosts is important to understand because it can affect the way your website is accessed and how search engines index your website. If you are not using the correct type of hosting, it can also affect the speed and performance of your website and even be vulnerable to cybersecurity vulnerabilities like DNS hijacking, SSL certificate vulnerabilities, and cross-site scripting.

Subdomain
==========

A sub-domain is a second-level domain that is part of a larger domain. For example, if you have a website at `example.com`, you can create a subdomain at `subdomain.example.com`. A subdomain can be used to create a separate website, or it can be used to point to a different website or directory on the same server.

Virtual Host
============

A Virtual Host (VH) is an Internet hosting service that allows organizations to host their websites on a single server. A VH can be used to host multiple websites, each with its own domain name, or it can be used to host multiple websites that share the same domain name. VHosts may or may not have public DNS records, so in order to access your site, you may need to change host names and addresses on your localhost (typically located in `etc/hosts`) or use the `Host:` header of a standard HTTP request.

---


In conclusion, it is important to understand the difference between sub-domains and VHosts in order to ensure that your website is accessible and performing optimally.
Firstpost</>
Published: 2022-07-24 17:51:00

public class Firstpost{
      public static void main(String a[])
{
      System.out.println("Today is a special day.i started studying Java,started dev.to account and also i'm having Eletronic device and circuits Endsem exam tomorrow.I haven't studied EDC but practicing Java.")
}
}
Edit-1
System.out.println("After publishing this post i came to know that i have created my dev.to account in october 2021")