teleren/devto huggingface dataset:
Fixing libssl1.1 and Installing MongoDb on Ubuntu 22.04.1 LTS
Tags: ubuntu, mongodb
Published: 2022-08-13 17:08:00


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

I just upgraded my ubuntu from 18 to 22.04 and i got a problem when installing mongodb on my local.

## Table Of Contents
- [Adding focal-security to sources list](#adding-source-list)
- [Installing libssl1.1](#installing-libssl1-1)
- [Download and configure mongoBb](#download-configure)


### 1. Adding focal-security to sources list <a name="adding-source-list"></a>

> echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
deb http://security.ubuntu.com/ubuntu focal-security main

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

### 2. Installing libssl1.1 <a name="installing-libssl1-1"></a>

> sudo apt install libssl1.1

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

### 3. Download and configure mongoDb <a name="download-configure"></a>

In this step we will download the .deb file. You can download the file [here](https://www.mongodb.com/try/download/community). 

Once download was successful then open the terminal and go to the directory then run command:
> sudo dpkg -i mongodb-org-server_6.0.0_amd64.deb 

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

To verify your MongoDB, you can run command to check the status:
> sudo systemctl status mongod

To run the MongoDB service, you can run command:
> sudo systemctl start mongod

To set the auto-start to your system, you can run command:
> sudo systemctl enable mongod

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


Reference:
[link](https://youtu.be/YuJPpCfuSJ0)
How Docker Works ? (Docker Series - II)
Tags: beginners, docker, tutorial, series
Published: 2022-08-13 17:04:00

Docker is a **Client- Server** architecture.

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

## What does the docker client do ? 
 The client is a tool for users to communicate/ interact  with Docker. We can use commands and also Docker provided API to communicate.

## What is docker host and what does docker host contain ?
The docker host environment to run or execute your application. It runs a program or a piece of software called Daemon. It communicates bi-directionally where it gets user-input and prints the response received.

**contains ?**:
    

1. **Docker Daemon:** This manages docker objects such as images and containers. Daemon builds the docker file and processes it as an image.

2. **Docker Image:** Read-only template, contains instructions to build a container. This can be either  own image or pulled existing image from docker registry. Docker images are built from a docker file. We can publish our own image in docker. Docker image communicates directly to Daemon. When redeploying an image it rebuilds where the image has changed, so it's light-weight and faster than vm technology.

3. **Docker Container:** Runnable instance of docker image, we can create, stop, run using cli or api. Containers are attached to networks and storage. By default it runs isolated  from its host machine. The container communicates to daemon through images.

## Docker Registry ?

Docker registry is a repository to store the images. We can also maintain a private registry. Docker will look for the images from the registry by default.

We can pull or run images that are available in the registry as well as push images.
Object Equality in JavaScript
Tags: javascript, webdev, beginners, programming
Published: 2022-08-13 16:33:00

Howdy! Here’s a simple way to check for object equality.

Let’s say we have two objects:

`const carA = {make: 'Ford', model: 'F150', year: '2018', color: 'white'}
const carB = {make: 'Ford', model: 'F150', year: '2018', color: 'white'}`

We can see that `carA` is the same as `carB`. So we would expect `carA === carB` to return true but it does not. This is because JavaScript checks for equality on non-primitive types like Objects, Arrays and Dates by reference.  This means, JavaScript checks if the two objects point to the same place in memory, not if they have the same key-value pairs.

One way to check for key-value equality of two objects, without the use of an external  library or much coding is by converting the objects to strings using `JSON.stringify()` .

`carA == carB // => false`
`carA === carB // => false`

`JSON.stringify(carA) === JSON.stringify(carB) // => true`

Keep in mind that this approach only works if the key-value pairs are in the same order on both objects. We could go into sorting object entries by key and other approaches in future posts.

Cheers! 🫖
I made a tmux plugin to spice up your terminal 🐧💅🏼
Tags: linux, tooling, showdev, productivity
Published: 2022-08-13 16:30:28


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

## What is this

tmux2k is a `tmux` plugin for that adds `powerline` support and pretty colors to your `tmux` status bar.

## Inspiration

tmux2k was inspired by [dracula/tmux](https://github.com/dracula/tmux).

## Prerequisites

Before you begin, ensure you have met the following requirements:

-   You have installed the latest version of `tmux`.
-   [tpm](https://github.com/tmux-plugins/tpm) for managing `tmux` plugins.
-   A [patched nerd font](https://www.nerdfonts.com/) for `powerline` and glyphs support.

## Installing tmux2k

Using `tpm`

If you are a `tpm` user, you can install the theme and keep up to date by adding the following to your `.tmux.conf` file:

```bash
set -g @plugin '2kabhishek/tmux2k'
```

Add any configuration options below this line in your tmux config.

### Activating tmux2k

-   Make sure run -b `~/.tmux/plugins/tpm/tpm` is at the bottom of your `.tmux.conf`
-   Run `tmux`
-   Use the `tpm` install command: prefix + I (default prefix is `ctrl+b`)

## Configuring tmux2k

```bash
# Tmux 2K default configs
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time
set -g @tmux2k-left-plugins "git cpu-usage ram-usage"
set -g @tmux2k-right-plugins "battery network time"
set -g @tmux2k-show-powerline true
set -g @tmux2k-show-fahrenheit false
set -g @tmux2k-military-time true
set -g @tmux2k-border-contrast true

# available colors: white, gray, dark_gray, light_purple, dark_purple, cyan, green, orange, red, pink, yellow
set -g @tmux2k-[plugin-name]-colors "[background] [foreground]"
set -g @tmux2k-cpu-usage-colors "blue dark_gray"

# it can accept `session`, `rocket`, `window`, or any character.
set -g @tmux2k-show-left-icon ""

# update powerline symbols
set -g @tmux2k-show-left-sep ""
set -g @tmux2k-show-right-sep ""

# change refresh rate
set -g @tmux2k-refresh-rate 5
```

## How it was built

tmux2k was built using `neovim`, `shellcheck`, `nerd-fonts`.

## What I learned

-   Learned a lot about the `tmux` and `tpm` ecosystem.
-   Did some fancy shell scripting.

## What's next

### To-Do

- Fix left plugins color logic
- Add more section scripts

Hit the ⭐ button if you found this useful.

{% embed https://github.com/2KAbhishek/tmux2k %}
Historical Question about Visio
Tags: discuss
Published: 2022-08-13 16:27:30

According to [the Wikipedia entry about Visio](https://en.wikipedia.org/wiki/Microsoft_Visio), at some unspecified time before 1992, a pre-release version 0.92 of Visio was distributed free on a floppy disk along with a Microsoft Windows systems readiness evaluation utility.

No other information is available about that floppy disk. 

There are several mentions of this on the interwebz, but they all seem to be copies of the exact same text found on Wikipedia.

I was wondering if anyone could confirm that this was in fact a floppy disk created by, and distributed by, Microsoft.
Cross-Posting to Medium
Published: 2023-04-29 21:26:33

---
title: Cross-Posting to Medium
published: true
date: 2022-08-13 16:03:12 UTC
tags: 
canonical_url: https://mikestaszel.com/2022/08/13/crossposting-to-medium.html
---

I love seeing when something I wrote helps someone.

Someone sent me an email _years ago_ thanking me for writing about some obscure bug or problem I solved and blogged about, and I remember it to this day!

[Medium](https://medium.com/) is a popular blogging platform that a lot of software engineers use, and I’ve started cross-posting there.

### Why Cross-Post?

A picture is worth a thousand words:

![60 claps!](https://mikestaszel.com/uploads/2023/b4658e06be.png)

That’s right - 60 people **found** my post and found it to be **useful** and clapped! That story has 179 views as of right now - that’s a great “clap-to-read” ratio.

Would 179 people even know about my personal blog, hosted at my personal domain, with absolutely _zero_ SEO?

You can also choose to monetize your posts on Medium, but I personally don’t.

### How to Cross-Post

#### What Not to Do

**Do not simply copy and paste your blog posts from elsewhere into Medium and post.**

There’s an easier way that also has SEO benefits.

#### Importing Stories

Rather than copy-pasting stories, use Medium’s “Import” functionality: [Importing a post to Medium](https://help.medium.com/hc/en-us/articles/214550207-Importing-a-post-to-Medium)

![Importing a story into Medium](https://mikestaszel.com/uploads/2023/9c1ec7be8c.png)

Not only is it faster - it also creates a canonical link between the Medium post and your external blog’s post.

I don’t really know the first thing about SEO, so I’ll let Wikipedia explain it: [https://en.wikipedia.org/wiki/Canonical\_link\_element](https://en.wikipedia.org/wiki/Canonical_link_element)

That’s all there is to it. Stories on Medium will have a “originally published at” link to your blog at the bottom of the posts. You get the benefits of “owning” your blog as well as the discoverability aspect of Medium.
Adding images in Ren'Py - part 1
Tags: gamedev, tutorial, python
Published: 2022-08-13 16:00:41

This article covers the basics on how to add images in Ren'Py for a visual novel. Stock or custom images can be used.

### Things to have 
 * Images to use (backgrounds, cursor, sprites, etc.) 
 * Photo editing software.  

## Adding a image

Take the image selected and locate the image folder in the project. Store the selected image in the folder. The ``bg`` tag is the naming convention for background images in the Ren'Py documentation. Suppose we have a image of that we want as a background with some narration.

```
    scene bg location

     "Where am I? "

    "I look around my surroundings."
```

For more customization, lets add a custom image as the cursor. I have placed a image for the cursor in the ``gui`` folder. Use the ``config.mouse``

```
define config.mouse = { }
define config.mouse['default'] = [ ( "gui/cursor.png", 0, 0)]
```

Here is code snippet that uses a background and custom cursor.

```
define m = Character("myCharacter")
define config.mouse = { }
define config.mouse['default'] = [ ( "gui/cursor.png", 0, 0) ]

label start:

    scene bg location

    "Where am I? "

    "I look around my surroundings."


    return
```

### Things to consider
When adding images make sure the size is appropriate. Use editing tools to scale images if they are not the correct size you want for the game. There are free assets that are already scaled by default that you can use for a visual novel.
Code Smell 158 - Variables not Variable
Tags: webdev, beginners, programming, tutorial
Published: 2022-08-13 15:32:31

*You assign a value to a variable and use it, but never change it*

> TL;DR: Be declarative on mutability.

# Problems

- Readability

- Honor the [Bijection](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086) mutability.

- Potential performance and memory issues. 

# Solutions

1. Change the variable to a constant and be clear on its scope

# Context

We are always learning from the domain.

Sometimes we guess that a value can change with the [MAPPER](https://dev.to/mcsee/what-is-wrong-with-software-5pa).

Later on, we learn it won't change.

Therefore we need to promote it to a constant.

This will also avoid [Magic Constants](https://dev.to/mcsee/code-smell-02-constants-and-magic-numbers-obb)

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/ab8aca666d5064bac5a4e8d096900138)
```php
<?php

function configureUser() {
  $password = '123456';
  // Setting a password on a variable is another vulnerability
  // And Code Smell
  $user = new User($password);
  // Notice Variable doesn't change
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/9649878302b3d66603b2cfdce2de87ba)
```php
<?php

define("USER_PASSWORD", '123456')

function configureUser() {  
  $user = new User(USER_PASSWORD);
}

// or 

function configureUser() {  
  $user = new User(userPassword());
}

function userPassword() : string {
  return '123456';
}

// Case is oversimplification as usual
```

# Detection

[X] Automatic 

Many linters check if the variable has just one assignment.

We can also perform mutation testing and try to modify the variable to see if tests break.

# Tags

- Mutability

# Conclusion

We must challenge ourselves and refactor when the variable scope is clear and we learn more about its properties and [mutability](https://dev.to/mcsee/the-evil-powers-of-mutants-1noo). 

# Relations

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

{% post https://dev.to/mcsee/code-smell-107-variables-reuse-3m53 %}

{% post https://dev.to/mcsee/code-smell-02-constants-and-magic-numbers-obb %}

# Refactorings

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

# More Info

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

# Disclaimer

Code Smells are just my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [Noah Buscher](https://unsplash.com/@noahbuscher) on [Unsplash](https://unsplash.com/s/photos/tied)  

* * *

> A complex system that works is invariably found to have evolved from a simple system that worked.

_John Gall_
 
{% 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 %}
How can i access single element of a grouped array nodejs?
Published: 2022-08-13 15:17:09

How can i access the elements of the final Array
```
function groupByKey(array, key) {
        return array
          .reduce((hash, obj) => {
            if(obj[key] === undefined) return hash; 
            return Object.assign(hash, { [obj[key]]:( hash[obj[key]] || [] ).concat(obj)})
          }, {})
     }
     var cars = [{'make':'audi','model':'r8','year':'2012'},{'make':'audi','model':'rs5','year':'2013'},{'make':'ford','model':'mustang','year':'2012'},{'make':'ford','model':'fusion','year':'2015'},{'make':'kia','model':'optima','year':'2012'}];
      const v  = cars['model']
     const result = groupByKey(cars, 'make')
     console.log(result)
```
Development methodologies - Waterfall
Tags: development, programming, tutorial, beginners
Published: 2022-08-13 14:43:00

![Waterfall image from [Here](https://thetravelauthor.com/why-do-we-love-waterfalls/)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3hwmsanw9a1xfx3pnnp.jpeg)

As a software engineer, you must have a good sight of development methodologies.
I always keep this sentence in my mind "Learn concepts, not languages".
So It gives you a great view when you learn and know the concepts.

What is **development methodology**? The software development methodology is a process or series of processes used in software development

You can do this process in different ways, but why reinvent the wheel again?

There are several methodologies to use, one of the most traditional methodologies is **Waterfall**.

Why waterfall? when a water from waterfall comes down, there is no way to get back, and it passes through some big rocks (Here we say stages).

In waterfall methodology, there are 5 stages:

1. Analysis
2. Design
3. Implementation
4. Testing
5. Maintenance

## Analysis
It's rooted in sequence and logic, and it has a cycle. So when you complete a stage, you can not get back, you need to completely finish a stage to continue.
In the first stage (Analysis), developers must write down all the requirements they need inside a requirement document.
The document is about what the system is going to do, but not necessarily how it works. The document contains the future of the software.


## Design
Developers use requirement documents to research and make decisions on how they should design the system, but without considering costs like hardware or software.
And also at the end of this stage, developers must make sure it works and it is not impossible with chosen hardware or software tech stacks.


## Implementation
In this stage, the project enters the coding and implementing level, and developers write the actual code.


## Testing
When coding is finished, the releases should test by beta testers, so they can report the bugs they face.
Developers patch and fix these bugs in this stage.


## Maintenance
Deployment and review happen in this stage, some people consider two stages (Deployment - Review) for the last but it depends on you.
This stage is where you release the stable version of your product, support your customers, maintain, and so on …
DON'T USE `in-app-webview`
Tags: privacy, javascript, ios, android
Published: 2022-08-13 14:37:59

Instagram and Facebook can track anything you do on any website in their in-app browser

The iOS Instagram and Facebook app render all third party links and ads within their app using a custom in-app browser. This causes various risks for the user, with the host app being able to track every single interaction with external websites, from all form inputs like passwords and addresses, to every single tap.

What gets injected?

The external JavaScript file the Instagram app injects is the (https://connect.facebook.net/en_US/pcm.js) which is code to build a bridge to communicate with the host app.According to Meta’s info provided to me in response to this publication, it helps aggregate events

## How to protect yourself as a user?

- Escape the in-app-webview
- Use the web version

read more >> https://krausefx.com/blog/ios-privacy-instagram-and-facebook-can-track-anything-you-do-on-any-website-in-their-in-app-browser
DAO
Tags: dao, web3, blockchain, javascript
Published: 2022-08-13 14:35:06

**_DAO_** stands for Decentralized Autonomous Organization (DAO) is an entity with no central leadership. Decisions are made from the bottom up, governed by a community organized around a set of rules validated by a blockchain.

In simple, DAO is a platform where decisions are made by platform users by voting on different proposals that members create.

## Learning platform as DAO (UDEMY as DAO)

Let's imagine UDEMY as a DAO, we'll call it UDEMYDAO.
Commnets in JavaScript
Tags: javascript, webdev, beginners, programming
Published: 2022-08-13 14:34:16

In JavaScript, there is a way to write pieces of text that will be ignored by the JS interpreter. Such texts are called **comments.** Why write them at all if in the end they're simply ignored? Well, the interpreter will ignore comments, but other developers won't. Comments allow you to make your code more readable and comprehensible for developers.

JavaScript language supports two types of comments: single-line and multi-line. Let's look at them more closely.

## Single-line comments

Comments that occupy only one line are called **single-line comments.** Take a careful look at the syntactic features of these comments:

```JavaScript
console.log("Nice to see you!"); // This code outputs the message to the console
```

In the example above, all text after `//` is ignored by the interpreter. With the help of such notes, you will quicly remember what a certain code fragment is intended for, even if it's been a while since you last saw it.

## Multi-line comments

Comments that take up several lines are called **multi-line comments.** These are their syntactic features:

```JavaScript
/*
  The following code outputs the message to the console
  The console will display a line with the text "Hello, JS!"
*/
console.log("Hello, JS!");
```

The interpreter ignores all text between `/*` and the nearest `*/`. Such comments are useful for explaining particularly complex pieces of code or temporarily commenting out code fragments when you need to find an error. Also, multi-line comments located at the beginning of a file are quite useful when you need to specify copyright information.

Sometimes you may find a slightly modified syntax of multi-line notes: the comment opens with the `/**` tag, and each line starts with an `*`:

```JavaScript
/**
* The first program
* Author: Danish
*/
console.log("Hi, I'm Danish");
```

Such comments often contains information about the programming file including its name, version, and the author of the script.

```Plain Text
JavaScript does not support nested comments. This means that you will not be able to write a comment inside another comment.
```

## Conclusion

Comments make your code more clear and help simplify the work of all those progrrammer who will work with your code in the future. Comments are also used to temporarily comment out code fragments when you need to find an error. In other words, you can really benefit from comments, so don't ignore them even though your JS interpreter will. Do not overuse comments, use them wisely, do not forget that comment can't replace well written code.

---

### Let's connect 💜

You can connect with me on [Twitter](https://twitter.com/MrDanishSaleem), [LinkedIn](https://linkedin.com/in/mrdanishsaleem), [GitHub](https://github.com/mrdanishsaleem/), [Discord](https://discord.com/users/890596597610737774/)

---

### Support me 🤝

You can support me on [Buy Me a Coffee](https://www.buymeacoffee.com/mrdanishsaleem)
How to check if a number is a power of two for O(1)
Tags: javascript, algorithms, dart, programming
Published: 2022-08-13 14:27:00


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gc4pcxap46oxznvc9k4.jpeg)*Dart solution.*

In JS looks something like this.  

```js
const isIntegerPowerOfTwo = number =>
    number > 0 && (number & (number - 1)) === 0;
```
Thanks to [Luke Shiru]("https://dev.to/lukeshiru") for code. 

### Explanation

In binary representation, numbers consist of 0 and 1. And it just so happens that all powers of two are 10*. 
For example, 2 -> 10, 8 -> 1000, and so on. 
When we do a comparison of number & number - 1 == 0, we check 100 & 011, which will always yield 0.

3 → 11. 3 & 2 => 11 & 10 = 1.