teleren/devto huggingface dataset:
Code Smell 29 - Settings/Configs
Tags: oop, webdev, tutorial, codenewbie
Published: 2020-11-20 03:19:26

*Changing system behavior in a control board is the customer's dream. And the software engineer's nightmare.*
 
# Problems

- Duplicated Code

- [If Pollution](https://dev.to/mcsee/how-to-get-rid-of-annoying-ifs-forever-1jfg)

- Global usage

- [Coupling](https://maximilianocontieri.com/coupling-the-one-and-only-software-design-problem)

- Testability and explosion of testing scenarios.

- Complexity
 
# Solutions

1. Avoid Settings

2. Create polymorphic objects. Inject them externally.

# Sample Code

## Wrong 

{% gist https://gist.github.com/mcsee/f001710d13fd158e75313c9b54ffc1aa %}

## Right
 
{% gist https://gist.github.com/mcsee/b4f9f8e80f19c89e99e10c999871ea2d %}

# Detection

This is an architectural pattern so it should be controlled/avoided by design policies. 

# Examples

- Connection Settings

- User settings

- [Feature Toggle](https://en.wikipedia.org/wiki/Feature_toggle)

# Exceptions

- Sometimes we use Feature togging as a safeguard mechanism. This is acceptable in a legacy system. These toggles should be very short-lived in a [CI/CD](https://en.wikipedia.org/wiki/CI/CD) system.

- Hyper parameter settings should be managed by configuration objects. You can read these objects from any persistence media and change your system behavior in runtime in an *explicit and controlled way*.

# Tags

-  Globals

# Conclusion

Setting runtime behavior is great for software systems. 

We should configure our objects, so they can behave in different ways, and we should achieve it in an explicit way with explicit behavioral objects.

In this way, our code will be more declarative, clean and testable. It is not as easy as adding an *IF Statement*. This kind of lazy developers bring lots of coupling and unexpected issues on our systems.

> A system with 300 Boolean configurations has more test combinations (2 ^ 300), than the number of atoms in the universe (10 ^ 80).
 
#Also known as

- [Feature Toggles](https://jeromedane.medium.com/feature-flags-are-dangerous-88ef9d6c9f04)

# More Info

{% post https://dev.to/mcsee/how-to-get-rid-of-annoying-ifs-forever-1jfg %}
 
* * *

> Simplicity is the soul of efficiency. 

_Austin Freeman_
Pure CSS 3D Human
Tags: codepen, css, purecss
Published: 2020-11-20 04:32:49

Recently, I've been working on leveling up my CSS illustration abilities. One of the biggest areas I've found is the infinite possibility of transform properties, specifically in 3D transformations. Until very recently, I had absolutely no idea that CSS could handle 3D dimensions.

Now, the thing I was surprised to find is that while CSS can handle three dimensions, it has no support for creating three-dimensional objects. To make a cube, one has to create six two-dimensional elements (or pseudo-elements) and arrange them in 3D space as the cube's sides.

Now, I love the concept of being able to illustrate in 3D. I could do so much with that, and I know it would be a valuable skill when I'm making more in-depth projects like games. The more I can transfer the illustration to CSS, the more lightweight and adjustable it'll be. I don't want to be importing all kinds of Javascript libraries that only work in certain browsers.
But cubes won't cut it. I need to be able to do more versatile shapes. After worrying over the problem for a while, here's what I came up with: If I take an element, duplicate it a few dozen times, and then distribute their rotations evenly on a single axis (remembering to use `preserve-3d` and `perspective`), I end up with a 3-dimensional element. Using this method, I put together this illustration of a human:

{% codepen https://codepen.io/bibliobone/pen/oNLRLpZ %}

Now, this method definitely has its limitations:

1. Only works on shapes that are symmetrical
2. It'll always end up with a circular shape. If I want something boxier, I can use the normal method I described earlier, with different elements as sides of a box.
3. If you look at the shape from the top or the bottom, you can see the gaps between the elements
4. The more elements you have, the more smooth the shape, but also the worse your page's performance.

These are definitely issues, but they can be partly fixed.

I know Issue #3 can be helped by adding more elements at the top and bottom (though not completely unless you're creating a cylinder). I originally had a sphere as the head of the person, but I ended up replacing it with a circle that rotates to always stay facing the user. This gives the illusion of a sphere, but without performance issues or revealing the fan. With some shapes, that works.

I'm not sure yet about the other issues, but I'm confident that as I continue foraying into this untapped field, I'll uncover more and more reliable methods to create a wider range of three-dimensional elements.

If you say any ways to improve my methodology or know of any examples of this kind of illustration on the web, please do let me know! I am very open to any new information I can get.
In case of case and other mnemonics for remembering syntax 
Tags: ruby, markdown
Published: 2020-11-20 04:15:52


When I first started learning a foreign language (Japanese in my case), I kept track of the words through rote memorization. But in college, I learned a different way!

  

My professor had a good way of drilling vocabulary and grammar structures into our heads: by creating phrases so senstaional it’d be hard to forget. Even now, I can remember some of those bizzare analogies. Masaka, massacre — no way, there’s been a massacre.

  

  

Code really is just another language after all, and it helps to remember syntax and structures with a fun mnemonics device.

  

  

## Markdown

  

I struggled for the longest time to remember the order for linking a… link. Finally, someone suggested SR, square round, Sally Ride, and it just stuck.

  

```

[square](round)

```

  

## Case Statements 

  

Case statements are a bit different in most languages but the structure remains the same: a case declaration, a when condition, a result for each condition, and a result for all other conditions.

  

Although I knew the structure, I would often forget to pass in the argument through the declaration (as some languages expected). Now, when I get an error, I just remember in case of case.

  

```

  

case some_value

when object = 1

	puts “object is one”

when object = 2

	puts “object is two”

else

	puts “object is not one or two”
end 

```

  

## Ruby

  

Mnemonics  are especially helpful in Ruby, which uses (mostly) descriptive language to define its methods.

  

### Take and Drop

  

Given an argument, drop removes an amount of elements equal to the given number. This is different from take, which takes the amount of elements and returns them.

```rb

[1, 2, 3, 4, 5,].take(1)

  

=> [1]

  

[1, 2, 3, 4, 5,].drop(1)

=>

[2, 3, 4, 5]

  

  

```

  

### tr

The tr method replaces characters of a string with other characters of a string. I like to think of it as directly translating the characters, as opposed to substituting a sequence (in which case you would use gsub).

  

```rb

“I swear”.tr(“swear”, “*****”)

  

=> “I *****”

  

“You got grit”.tr(“gt”, “12”)

  

=> “You 1o2 1ri2”

  

  

```

  

### Strings

  

You likely know about strings in Ruby. But, if you wanted to use Heredocs you’d need to construct it using the <<- operator. I’ve always thought <<- looks like a fallen pine tree, and what do you make documents (paper) from? Trees!

  

```rb

  

document = <<-HERE

This is my text.

HERE

  

```

  

### Ranges

  

For array ranges, two dots indicate the range is inclusive while three means the range is exclusive.

  

```rb

>>arr[1..3] # .. inclusive

=> [5,1,2]

>>arr[1...3] # …threexclusive

=> [5,1]

```

## Conclusion 

There are a bunch of tricks for remembering syntax and procedures. What are some of yours?
release 0.3.1
Published: 2020-11-20 04:15:03

For the external contribution, I worked on a CI/CD area for [this repo](https://github.com/kaspanet/kaspad/issues/1120). The pull request address is [https://github.com/kaspanet/kaspad/pull/1130](https://github.com/kaspanet/kaspad/pull/1130).

This repo is using Jenkins to build and test, they want to try something new. I suggest that they can try Github actions which is awesome for this kind of job.

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


I added a `go.yaml` file to complete this task. The code I added:

```yaml
name: Go

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    strategy:
      matrix:
        go-version: [1.15.x]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Set up Go 1.x
      uses: actions/setup-go@v2
      with:
        go-version: ^1.15

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

    - name: Build
      run: go build -v .

    - name: Test
      run: go test -v .
```

After I did some tests, I noticed that the code build on windows always gets an error.

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

I think this is an error they need to solve, instead of a bug of GitHub actions.
TN21D: Day 1-The Blogs I Wish I Wrote
Tags: thenext21days, devjournal, devrel
Published: 2020-11-20 04:07:56

Day One.  Usually you'd think of new, fresh.  Not today.  Day One starts with a problem confusion and regret.  I regret not having written this blog sooner.

Every time I have ever decided to write a blog about my journey into tech I end up spending 6 hours jumping down rabbits holes of projects I should write a blog about starting and of course I start the project and I forget to write the blog.

Today, I am going to write the blog.  No more excuses, no more rabbit holes.  

First things first, I told Twitter I would do it (because that's how I start things in tech I guess?) 

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">• I would like to start making YouTube videos<br>🦚 P2: SOLUTIONS<br>• I decided to write this blog post.<br>• I will write another blog about going through <a href="https://twitter.com/freeCodeCamp?ref_src=twsrc%5Etfw">@freeCodeCamp</a> Basic JavaScript course for my <a href="https://twitter.com/TechtonicaOrg?ref_src=twsrc%5Etfw">@TechtonicaOrg</a> application.</p>&mdash; dev_advocate_myles (@AdvocateMyles) <a href="https://twitter.com/AdvocateMyles/status/1329521571585638400?ref_src=twsrc%5Etfw">November 19, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Next I cloned the repo for this project:
https://github.com/erostribe/classsed-graphql-mern-apollo

At this point I desperately need a break.  I know that this project is going to take 6 hours and I only have 4 free hours, so I pause.  I decide to get lunch and go on a 30 minute walk.  This is something I never do, but I also end up tired, frustrated and feeling cooped up and boxed in.

I have 3 work hours left, so I decide to build the landing page for this project in my portfolio.  The Landing Page generally gives every project a space where I hope to add technology I learn later.  In the code its where I explain exactly what I hope to put there.  On the user side it has links to the project.


I ended up taking a nap and there went the remaining 3 hours of work time before I had a JavaScript meetup.  In the end I'm glad that I slept, because I managed to eat during the meetup and now I'm ready to look at this with a clear(er) head.

My purpose for today feels complete.  I wanted to find something that would add substance to my portfolio and blog about it.  Day One *COMPLETE*.  I'm going to schedule some time to work on completing the project (Saturday or Sunday most likely)
VS Code Plugin for React.js and Javascript developers.
Tags: react, javascript, webdev, beginners
Published: 2020-11-20 03:34:57

In this post I will give you a list of react.js and javascript vscode extensions I use.


#### 1.  <u>[React-ES7 syntax and auto complete](https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets)</u>


![Screen Recording 2020-11-20 at 08.52.16.47 AM](https://dev-to-uploads.s3.amazonaws.com/i/8gk6brtk39kxbi85caw0.gif)
 


This extension has various benefits but the most important one is the use of shortcuts.


#### 2. <u> [Javascript snippet completion](https://marketplace.visualstudio.com/items?itemName=jmsv.JavaScriptSnippetsStandard)</u>

Another very good extension for completion of code for vanilla JS.

#### 3. <u> [Color brackets](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer) </u>

Another awesome extension which differentiates the brackets within functions with multiple colors.

This is a life saver when we try to find errors in our code.

If you know any other better vscode extensions for react.js development please mention it in the comments.

### Thank you for reading!

If you like this article, Unicorn this one! Heart/Like this one and save it for reading it later.



### <u>My Other Articles: </u>



- [Universal CSS properties everyone must know](https://dev.to/gautham495/universal-css-properties-everyone-must-use-4kie)

- [Create-react-app](https://dev.to/gautham495/creating-a-new-react-app-with-create-react-app-4e9m)

- [Git for beginners](https://dev.to/gautham495/basic-git-knowledge-for-beginners-m4p)

- [Change headers in react with react-helmet](https://dev.to/gautham495/changing-headers-in-react-with-react-helmet-d0d)

- [Know How to apply box-shadow on all four sides.](https://dev.to/gautham495/know-how-to-apply-box-shadow-on-all-four-sides-43pn)
 
- [Simple CSS Selectors](https://dev.to/gautham495/simple-css-selectors-for-beginners-2i44).

- [CSS Pseudo Elements](https://dev.to/gautham495/css-pseudo-elements-for-beginners-53ob).

- [CSS Pseudo Classes For Beginners](https://dev.to/gautham495/pseudo-classes-for-beginners-3lc0
).
S1E10 Learn JMeter Series - HTTP Authorization Manager
Tags: performance, webperf, tutorial, testing
Published: 2020-11-20 03:34:09

Welcome to Learn JMeter Series!

In this season one, episode ten, you will learn the following:

* HTTP Authorization Manager

{% youtube tuxx6L4UhCU %}

✔ [Buy me a tea 🍵](https://www.buymeacoffee.com/qainsights)
✔ [My Blog](https://qainsights.com)
✔ [My Udemy Course](https://www.udemy.com/course/performance-testing-using-truweb)
Into the world of Microsoft Azure
Tags: microsoft, azure, cloud
Published: 2020-11-20 02:45:34

Today I started a part time job at a help desk for a local company who is partnered with Microsoft and uses the Azure cloud. This has inspired me to briefly take a step away from AWS and jump into Azure to get myself familiar with it! After some research, here is what I’ve learned. 

Microsoft Azure is Microsoft's public cloud computing platform. It provides a range of cloud services, including compute, analytics, storage and networking. Users have the ability to pick and choose from these services to develop and scale new applications, or run existing applications in the public cloud. 

Once customers subscribe to Azure, they have access to all the service that the Azure portal has to offer. Because Microsoft Azure consists of numerous service offerings, its use cases are extremely diverse.

Microsoft provides five different options for Azure:
- Basic
- Developer
- Standard
- Professional Direct
- Premier
 To help with privacy concerns, Microsoft has created the online Trust Center, which provides detailed information about the company's security, privacy and compliance initiatives. According to the Trust Center, Microsoft will only use customer data if it is necessary to provide the agreed upon services.
 
I hope you liked my general overview of Azure, thanks for stopping by!
Release 3.1 - telescope
Tags: opensource
Published: 2020-11-20 02:43:33

For this release, I contribute to this issue [https://github.com/Seneca-CDOT/telescope/issues/1351](https://github.com/Seneca-CDOT/telescope/issues/1351). The pull request [https://github.com/Seneca-CDOT/telescope/pull/1352](https://github.com/Seneca-CDOT/telescope/pull/1352)

This is a relatively easy issue, We need to change the environment variable `MAX_POSTS_PER_PAGE`. The first thing I do is search this variable in our code.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/e8a3qvfr8bvaao2nyhmk.png)

Three results from three files. 
Here are the steps I did.
- create a new branch with the issue number.
```
git checkout -b issue#1351
```
Then, I set the value of this variable to 5. The coding job is done.
- remove the old `.env` file, and copy the new `env.example` to `.env`
```
cp env.example .env
```

Then test the code in my local machine. It works, we have 5 posts per page.

## Problem to push the code.

When I push the code to the remote `git push origin issue#1351`, git gives me a warning `no permission to push`. I checked the remote address `git remote -v`. I make a mistake and clone the repo from telescope. Now the original address is `https://github.com/Seneca-CDOT/telescope.git`.

## How I solve the problem.

If I am not in this class, I will delete everything and clone a new repo from my forked repo `git@github.com:yzwdroid/telescope.git`. 

But I am a git master now (Thanks for @humphd), the remote repo is just a name `origin`. I can just add another remote with the command `git remote add yzwdroid git@github.com:yzwdroid/telescope.git`. Then just push the current branch `$issue1351` to the `yzwdroid` remote repo.
```
git push yzwdroid issue#1351
```

Then I do the pull request from github.
filter() method explained : JS
Tags: javascript, 100daysofcode, webdev
Published: 2020-11-20 02:25:13

The `filter()` method creates a new array filled with all the elements of the old array that pass a certain test, provided as a function. 

Let's take a look at the syntax:- 

```javascript
let new = array.filter((v, i, a) => {
   // return element to new if condition are met 
  // skip element if conditions are not met
  });

// new - the array that is returned
// array - the array to run the filter function on
// v - the current value being processes
// i - the current index of the value being processed
// a - the original array
```

The `filter()` method can be thought as of a loop, that is specifically for filtering in/out certain values from an array. See the example below:- 

```javascript
let nums = [11, 12, 13, 14, 15, 16];
let evenNums = [];
for(var i = 0; i < nums.length; i++) {
   if (nums[i] % 2 === 0) evenNums.push(nums[i]);
 }

// evenNums = [12,14,16]
```

This code tests all of the values in the nums array. Only the even values are accepted and pushed onto the evenNums array. yes, it works, but there is an easier way to achieve the same result.

Rewriting the previous function using the `filter()` method. 
```javascript
let nums = [11,12,13,14,15,16];
let evenNums = nums.filter(value => value % 2 === 0); 
   // evenNums = [12,14,16]
```
**Just see. Without any loop. **

And using the arrow function we have a nice and clean function to create the same array. Because we only use the value, we only pass that to the `filter()` method. 

Now we will see a more complex example that utilizes an array of object. Below is the data we will be using for our example. 

```javascript


let data = [ 
{ 
    country: 'India',
    population: 17122267, 1,  
},
{  
  country: 'Germany' , 
    population: 83694772, 
},
{  
  country: 'United Kingdom',
    population: 67767045, 
},  
{
    country: 'Belgium' , 
    population: 11572813, 
    }
];

```

**So now what ? ** <br>

We want to create a new array with only with the countries that have a population smaller than 50million. To do this, all we have to do is test our data and return true id **data.population** is smaller than 50,000,000.

```javascript
let smallCountries = data.filter(v => v.population > 50000000);
```
Just this one line code ensuers that only the smaller countries make it our new array. Even though our data is more complex the process to filter it remains relatively unchanges. Aftfer running our filter function, we're left with this:

```javascript
// smallCountries = [
// {country: "India", population: 17122267},
// {country: "Belgium", population: 11572813},
// ];
```
I'm Done! Thanks For Reading. <br> If you find it useful plz show some love and comment.
First Seen [Here](https://rahulism.co/filter-method-explained)
Create SQL from CSV files for larger updation or insertion
Tags: mysql, sql, sublime, programming
Published: 2020-11-20 02:22:19

Few days back I came across one problem where I have to create a bulk update script based on a given CSV or Excel file. First I thought of finding something in excel level by writing some macros or functions. 

Then my friend helped me to use the easiest method using a sublime text editor. Would like to know about this approach ? 

As I said above it's simpler to create and update scripts. Let's take an example I have below CSV file content. 

```
mumbai,avinashdalvi@test.com
thane,avinash@malinator.com
bangalore,test@mailinator.com
``` 
Follow below steps : 

1.  Open CSV file in sublime text editor. 
2. Open Replace toolbar from Menu -> Find -> Replace ( You can directly open by short command **Option+Command+F** for Mac user, **Control+Shift+F** for Window or ubuntu user.
3.  Enable regex option in toolbar ( It will look like **.***). You can see 👇🏻 below image.
4.  Considering two fields in CSV, write `(.*),(.*)` in the Find field on the toolbar.  
![Find Toolbar Image](https://cdn.hashnode.com/res/hashnode/image/upload/v1605776179521/MvLW1Rzv6.png)
5. `update table tablename set fieldname1 = '$1' where fieldname = '$2'` in Replace field. `$1` stand for first field and `$2` stand for second first. Vice versa if you have multiple fields you can mention `$3` and so on.
6. Try to click on the find button and check whether it is highlighting properly or not.  
7. Then you click on "Replace All"  and see this output. 


**Output** : 
```
Update tablename set fieldname1 = 'mumbai' where fieldname = 'avinashdalvi@test.com';
Update tablename set fieldname1 = 'thane' where fieldname = 'avinash@malinator.com';
Update tablename set fieldname1 = 'bangalore' where fieldname = 'test@mailinator.com';
```


**Note** : You can write any other SQL like insert or delete to create a SQL script. This is a little hack which can help to save time while creating a script when you are dealing with more numbers of records.

Hope this helps you. Thanks for reading this blog. If any feedback feel free to reach out to me.