teleren/devto huggingface dataset:
How to execute shell commands in Javascript
Published: 2021-09-21 11:28:13

Working in Javascript apps, you might have to use shell commands to retrieve some informations or execute some treatments.

So here is the snippet to do it!

---

## Code

```javascript
const childProcess = require('child_process');

async function sh(cmd_to_execute) {
    return new Promise(function (resolve, reject) {
        childProcess.exec(cmd_to_execute, (err, stdout, stderr) => {
            if (err) {
                reject(err);
            } else {
                resolve({stdout, stderr});
            }
        });
    });
}
```

You can use this function which will return you the result of the command.

---

I hope it will help you! 🍺
A TelegramBot for true paranoids.
Tags: telegram, python, showdev, cryptography
Published: 2021-08-12 18:15:30

{% youtube yH3SVmCZD7Q %}

### https://t.me/MasquerBot


I watched Snowden in 2016. It was the year, I became paranoid. 👻

Introducing 𝗠𝗮𝘀𝗾𝘂𝗲𝗿𝗕𝗼𝘁! It is a telegram_bot that can hide any given text message inside any given image, by manipulating the very pixels of that image (steganography)

• URL changes every 6 hrs, with 130 char long, therefore making it impossible to trace by anyone other than Telegram.

𝘍𝘢𝘳 𝘣𝘦𝘵𝘵𝘦𝘳 𝘥𝘰𝘤𝘶𝘮𝘦𝘯𝘵𝘢𝘵𝘪𝘰𝘯 𝘪𝘴 𝘰𝘯 𝘨𝘪𝘵𝘩𝘶𝘣, 𝘭𝘪𝘯𝘬𝘴 𝘢𝘵 𝘵𝘩𝘦 𝘦𝘯𝘥.

📈 𝗪𝗼𝗿𝗸𝗳𝗹𝗼𝘄:

• It works by creating an ECDSA encryption 🔑🗝key pair, returns you the 🔑public key, to distribute.

• To encrypt, one will have to send your 🔑key along with ✉text and 🖼image.

• The bot will encrypt the text and hide it then it will return the 🖼 encode-image.

• You as a recipient will send the encoded-image to the bot. and it will take your 🗝private key from the 📒database and will send you the hidden ✉text.

PS: Icon is not just eye-candy for otakus. try "/icon" command, within the bot. I bet you will love it. 😉


⚡𝗟𝗶𝗻𝗸𝘀:
Github: https://github.com/ra101/MasquerBot
LBRY: https://lbry.tv/@ra101/MasquerBot
What was your win this week?
Tags: discuss, weeklyretro
Published: 2021-08-13 17:36:53

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Hey there!


**Looking back on your week, what was something you're proud of?**

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Cleaning up your workspace... or whatever else might spark joy ❤️ 

---

Congrats in advance!

![Happy Friday the 13th](https://media.giphy.com/media/3o7aD2saalBwwftBIY/giphy.gif)
SDS Internship Experience!
Tags: internship, computerscience, python, sql
Published: 2021-08-14 02:56:25

Camilo Cortes
Blog SDS


Introduction
TransitHealth is a website that allows the general population to access comparative data and other metrics concerning the cross of the CTA and health within the Chicago community. Data from the CTA is compiled and processed in an offline pipeline using custom metrics.
I utilized CTA bus ridership data from the year 2019 to 2020 to analyze the quantity of trips taken daily. Although I ran out of time, I planned on using this data to form a timeline graph comparing the number of COVID-19 cases reported with the number of rides taken, in an attempt to find a correlation.

My Interest:
My interest in computer science started when I was six years old and my dad brought home our first computer! I was fascinated with it! Ever since I’ve been encaptured with the beauty of both hardware and software! My main goal is to somehow contribute to assistive technologies. And although I did run out of time, I was able to create scripts for endpoints crossing Chicago transit systems and health. 

First Image
This picture demonstrates my aggregation of data using SQL

Second Image
This photo demonstrates the subsequent transformation of data  utilizing Python 3

Third Image

This photo demonstrates the beginnings of crossing
the two reference points


Lessons Learned:

	I highly recommend this internship. You take a very hands on approach to problem-solving and this allows you to think more creatively. As you tackle issues on your own, you learn critical thinking skills, and you are always able to reach out to your mentor for assistance. I was able to witness the backend pipeline for the first time and understand it’s dynamics, an experience I really valued!
Take your time, and you will see success!
Build a simple Pie Chart with HTML and CSS
Tags: css, webdev, html, beginners
Published: 2021-08-14 18:32:45

You can create a **Pie Chart** in HTML using a simple CSS function called `conic-gradient`.

First, we add a `<div>` element to our HTML page, which acts as a placeholder for our pie chart.

```html
<div id="my-pie-chart"></div>
```

We need to provide a `width` and a `height` to the `<div>` element, which determine the size of our pie chart:

```css
#my-pie-chart {
    height: 100px;
    width: 100px;
}
```

Then, we need to make our pie chart circle-shaped by setting the `border-radius` value to `50%`:

```css
#my-pie-chart {
  border-radius: 50%;
}
```

And finally we are ready to populate the pie chart with our data. 

As an example, let's consider the world population data reported at the following link:
https://www.worldometers.info/geography/7-continents/
We want to show the population distribution per continent using our pie chart.

For each continent, we associate an arbitrary color and the population percentage taken from the above link. The data is summarized in the following table:

| Continent     | Color  | Population |
| ------------- |:------:| ----------:|
| Asia          | red    |   59.54%   |
| Africa        | orange |   17.20%   |
| Europe        | yellow |    9.59%   |
| North America | green  |    7.60%   |
| South America | blue   |    5.53%   |
| Australia     | black  |    0.55%   |
| Antarctica    | brown  |    0.00%   |

To apply these values to our pie chart, we need to partition it into 7 sectors, a sector for each continent. To create the sectors, we can use the `conic-gradient` CSS function. Each sector has a color, a start position and a stop position.

For example, Antarctica is represented by the brown color and has 0.00% of the world population. Therefore, we want a brown sector from 0.00% to 0.00%. 
Then, we want to plot a black sector representing the Australia, which has 0.55% of the world population. This results in a black sector going from 0.00% to 0.55%. 
Similarly, to represent the South America we want a blue sector going from 0.55% to 6.08% (= 0.55% + 5.53%). 
And so on.

At the end we will have the following CSS background property:

```css
#my-pie-chart {
  background: conic-gradient(brown 0.00%, black 0.00% 0.55%, blue 0.55% 6.08%, green 6.08% 13.68%, yellow 13.68% 23.27%, orange 23.27% 40.47%, red 40.47%);
}
```

:bug: That's all. Now we are able to create a pie chart in CSS.

{% codepen https://codepen.io/cscarpitta/pen/XWRQmxm %}
How to replace an existing document in MongoDB
Tags: mongodb
Published: 2021-08-14 15:53:24

---
title: How to replace an existing document in MongoDB
published: true
date: 2021-08-14 15:41:40 UTC
tags: MongoDB
canonical_url: https://donaldfeury.xyz/how-to-replace-an-existing-document-in-mongodb/
cover_image: https://donaldfeury.xyz/content/images/2021/08/MongoDB_Logo2-1.png
series: "Small Bytes of MongoDB"
---

 ![How to replace an existing document in MongoDB](https://donaldfeury.xyz/content/images/2021/08/MongoDB_Logo2-1.png)

---

For a full overview of MongoDB and all my posts on it, check out my [overview](https://donaldfeury.xyz/introduction-to-mongodb/).

[MongoDB provides several ways to update specifically one document](https://donaldfeury.xyz/how-to-update-a-single-document-into-a-mongodb-collection-2/) that works great when doing partial updates.

If you want to completely replace an existing document with a new one, you can use `replaceOne`.

First, let's insert some data into a collection called `podcasts`:

```
db.podcasts.insertMany([
    {
        "name": "Tech Over Tea",
        "episodeName": "#75 Welcome Our Hacker Neko Waifu | Cyan Nyan",
        "dateAired": ISODate("2021-08-02"),
        "listenedTo": true,
    },
    {
        "name": "Tech Over Tea",
        "episodeName": "Neckbeards Anonymous - Tech Over Tea #20 - feat Donald Feury",
        "dateAired": ISODate("2020-07-13"),
        "listenedTo": true
    },
    {
        "name": "Tech Over Tea",
        "episodeName": "#34 The Return Of The Clones - feat Bryan Jenks",
        "dateAired": ISODate("2020-10-19"),
        "listenedTo": false
    }
])

```

Let's completely replace the podcast that aired on `2020-07-13` with a new podcast. Unlike `update` and `updateOne`, `replaceOne` does not use `update operators`.

```
db.podcasts.replaceOne(
	{dateAired: ISODate("2020-07-13")},
	{
		"name": "Tech Over Tea",
		"episodeName": "#73 Is This A Gaming Podcast Now | Solo",
		"dateAired": ISODate("2021-07-19"),
		"listenedTo": false
	}
)

```

The arguments are similar to `update` and `updateOne` where the first argument is the query to match a document to replace. However, the second argument is a new document that will completely replace the first matched document.
Use of string concatenation within loops in JAVA
Tags: java, strings, loops
Published: 2021-08-14 21:18:12

In Java, do you know about the pitfall of using string concatenation within loops??
Since strings are immutable in JAVA, when we try to append another char to a string, it creates a new copy of the string and updates the copy instead of the original string.😯

Example :
```java
String s = "value";
s.concat("d");
```
On doing so, value of string s is not changed rather a new updated copy of string s is created in heap.
Now think, if concatenating string creates one another copy of string object, what would happen if do string concatenation within a loop.

```java
string s = "coding";
for(int i = 0;i < 100000;i++){
   s += "java";
}
```
This would create 100000 new copies of string object s!!!😲😶😲

Creating 100000 copies leads to significantly impacting code performance. So you must be thinking what's the solution??
We have two alternative to tackle this issue?

🎉🎉 StringBuffer & StringBuilder 🙌🙌

Both serve the purpose of avoiding creation of string objects upon concatenation!

Example:
``` java
StringBuffer s3 = new StringBuffer("value");
String s2 = "value2";
for(int i = 0;i < 100000;i++){
   s3.append(s2); // s3 = s3 + s2;
}
```

In this scenario, no creation of string objects happen! Cool, isn't it?😁

Same can be achieved with StringBuilder, so what's the difference between the two then??
StringBuilder is not thread safe while StringBuffer is!

But more on threads later!! Hope you enjoyed this !!
Microtasks and (Macro)tasks in Event Loop
Tags: javascript, webdev
Published: 2021-08-15 02:01:40

JavaScript has a concurrency model based on an **event loop**, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks.

Here, we will see about microtask and macrotask in event loop and how event loop will handle tasks.

let’s dive in! 🏃‍♂️

Within the Event Loop, there are actually 2 type of queues: the (macro)task queue (or just called the task queue), and the microtask queue. The (macro)task queue is for (macro)tasks and the microtask queue is for microtasks.

###Microtask

A **microtask** is a short function which is executed after the function or program which created it exits and only if the **JavaScript execution stack is empty**.

* Promise callback
* queueMicrotask

###Macrotask

A **macrotask** is short function which is executed after **JavaScript execution stack and microtask are empty**.

* setTimeout
* setInterval
* setImmediate

###Explanation

When a Promise resolves and calls its then(), catch() or finally(), method, the callback within the method gets added to the microtask queue! This means that the callback within the then(), catch() or finally() method isn’t executed immediately, essentially adding some async behavior to our JavaScript code!

So when is a then(), catch() or finally() callback executed?🤷‍♂️

Here the **event loop gives a different priority to the tasks**.

All functions in that are currently in the **call stack get executed**. When they returned a value, they get **popped** off the stack.

When the **call stack is empty**, all queued up **microtasks are popped** onto the call stack one by one, and get executed! (Microtasks themselves can also return new microtasks, effectively creating an infinite microtask loop).

If both the **call stack and microtask queue are empty**, the event loop checks if there are tasks left on the **(macro)task queue**. The tasks get popped onto the call stack, executed, and popped off!

###Example

Task1: A function that’s added to the call stack immediately, for example by invoking it instantly in our code.

Task2, Task3, Task4: microtasks, for example a promise then callback, or a task added with queueMicrotask.

Task5, Task6: a (macro)task, for example a setTimeout or setImmediate callback

First, Task1 returned a value and got popped off the call stack. Then, the engine checked for tasks queued in the microtask queue.
Once all the tasks were put on the call stack and eventually popped off, the engine checked for tasks on the (macro)task queue, which got popped onto the call stack, and popped off when they returned a value.

Here’s graphic illustration of the event loop 👇

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kr6bsfd5o0ipc85kyaf8.gif)

###Conclusion

Congratulations for reading until the end! In this article you’ve learned:

* How microtask and macrotask are working in event loop.

I hope you find this article helpful in understanding microtask and macrotask how it works.

**Suggestions are highly appreciated ❤️**
Rust Trait Objects Demystified
Tags: rust
Published: 2021-08-15 05:44:29

Dealing with Trait Objects in Rust is a trap for young players, especially when you want to obtain a composition of traits.

Here's a deep-dive with code-examples and a Github repo for you to play with - Enjoy!

https://desilva.io/posts/rust-trait-objects-demystified
Big Shout  to Zuri 
Tags: react, figma
Published: 2021-08-15 08:05:02

<main>
       Thank you Zuri team for giving me a chance to be part of this cohort(Frontend Track).The internship has several  tracks : -
 <ul>
       <li>
         Frontend Track
       </li><li>
         Backend Track
       </li>
       <li>
      Devops Track
       </li>
       <li>
        Entrepreneurship Track
       </li>
       <li>
      Digital marketing Track
       </li>
       <li>
         UI-UX Track
       </li>
      </ul>
   <h2>My Goals for Zuri Internship</h2>
         <ul>
           <li>  Be a proficient  Frontend developer (React)</li>
           <li> Use my skills to solve on the SDG Goals (Sustainable  Development Goals) </li>
           <li>Improve my soft skills</li>
           <li>Grow my skills with my team</li>
         </ul>
         <p>As i go along this journey , this will be my guiding tutorials</p>
      <ul>
           <li>
               <a href="https://youtu.be/qz0aGYrrlhU">HTML  and  Css  </a>
           </li>
           <li>
               <a href="https://www.youtube.com/watch?v=Qqx_wzMmFeA&t=50s">Javascript</a>
           </li>
           <li>
             <a href="https://youtu.be/_uQrJ0TkZlc">Python</a>
           </li>
           <li>
              <a href="https://youtu.be/TlB_eWDSMt4">Node js</a>
           </li>
           <li>
             <a href="https://www.youtube.com/watch?v=xuB1Id2Wxak&t=4s">Github</a>
           </li>
           <li>
             <a href="https://www.youtube.com/watch?v=c9Wg6Cb_YlU">Introduction to Figma</a>
           </li>
</ul>
   </main>
   <footer>
     <p>Sign up for the internship      <a href="https://internship.zuri.team">Zuri Internship</a></p>
   </footer>
Why ditched Windows for Linux
Tags: linux
Published: 2021-08-15 08:17:51

## What Is Linux
When it comes to this topic there are two kinds of people. People who react What is Linux even? and the People who say like Yeah I know Linux and I have it on my pc.

Well, Linux is not a single operating system but a whole family of them. A man named Linus Torvalds created the Linux Kernel (A program made to manage all the devices connected to a system) and made it available open source and that was the starting point of Linux. From then People started adding their own code on top of it to create various operating systems.

There are 100s no 1000s of operating systems under the linux family of operating systems a whole new you have probably not discovered.

These operating systems do again upload things open source and then more and more operating systems use their existing code to create new operating systems.

Some of the Jewels of Linux's Crowns are. ArchLinux, Fedora, Ubuntu, Debian and Linux Mint. Most of the operating systems are used to manage servers, but a few people use it as their daily operating system.

The one which I use is Linux Mint which is based on Ubuntu and Ubuntu itself based on Debian and Debian just sits on top of the Linux Kernel.

## Why Linux
Ok, we just discussed that Linux exists, but its mere existence will not mean that you have to use it over Windows (In this article I am comparing Windows and Linux keeping Macos out of the arena because I never owned a mac). It should have features that make it better than the computer gaint Windows.

### Speed
The problem of having a 4gb ram laptop increase when you program in it. I used my laptop to code and it just used to break up every now and then.
I was fed up of this problem and decided to do a quick google search about the fastest operating system ( I knew linux existed but I never actually tried it). The answer was Linux Mint and after the switch I got relieved from the problem of repetitive hangs. It stil hangs but not every now and then but occasionaly or if I be honest weekly

### Simplicity
Do you own a Windows laptop then you know the pain of updating it now and then like every month or so. A automatic Candy Crush install when you buy your PC. All this won't happen in Linux. They tell you want is happening on your pc. Just the apps you want and no hassle to install updates foricbly.

### Reviving Old Systems
If I own a windows laptop then the biggest problem for me is that if it is not that high-end then the operating system will take repetitve hiccups. Linux on the other hand can be run on a 2gb ram laptop as well. Your daddy's old PC has got no need to be upgraded use linux and save money.

### Free
This is the most striking feature of Linux. It has better features than Windows but is still free. That is why Linux laptops are cheaper than Windows laptops.
HNG Internship Goals
Tags: programming, goals, internship, zuri
Published: 2021-08-15 09:32:55

If you're a developer with an eye out for internships, you must've heard of the HNG internship and the drills they put developers through to make them world class software engineers. 
The internship is open to anyone and aims at creating a virtual work environment that fishes out the best candidates from a pool of participants. Operated by the [zuri](https://zuri.team) team, the internship is one developers around the world keep an eye out for.
You must be wondering if I am a participant, well, you guessed right, I am in the 8th cycle of the HNG internship and I'll be stating my goals in this article.

## Become a better developer
It's undeniable, working with other awesome developers around the world make one better, you get to learn a lot of things quickly and HNGi (HNG Internship) provides a fast paced environment with the talent for such.

## Network with Great Minds
There is an excess supply of super awesome developers, designers and the likes in such an environment and I wouldn't let the opportunity to network pass me by.

## Work on Awesome Products
Building software is every developers' joy, even better when you're building it with great developers.

## Scale this Challenge
I have always considered HNG internship a challenge and I don't take challenges lightly. I was in a previous installment but crashed out halfway, this time, I am seeing it through to the end.

In conclusion, I aim to generally get better at what I do, which is building APIs and web apps with MongoDB, Express, React and NodeJS.

In case you're wondering, the internship is open to beginners but keep in mind it is a fast-paced environment and as such you should be willing to learn at lightening speed. Basic knowledge of git and github is a plus, check out this [tutorial](https://opensource.com/article/18/1/step-step-guide-git) to get started with git. 
Basic knowledge of figma is also an added advantage, get up to speed with figma [here](https://trydesignlab.com/figma-101-course/introduction-to-figma/).
Check out this [tutorial](https://html.com/) to get the basic knowledge of HTML.
I would also recommend getting the most basic know-how (atleast for a start) on a backend language like [NodeJS](https://www.tutorialspoint.com/nodejs/index.htm)

With all those, you're more than ready to go, take the leap and  dive right in. See you on the other side!
My Expectations at Zuri Internship Program
Published: 2021-08-15 12:23:44

ZURI INTERNSHIP

Background
I am Atwine Nickson, a software developer with 3 years of playing with code experience. Apart from UI development (Frontend), I am a full-stack developer pro efficiently with Python(Django and Flask).
 
I am always looking for new challenges to help me improve my skills and that is when I found the Zuri Internship Program, and I applied, then was selected, and here is my first task of writing this article.
About Zuri Internship
Zuri internship is an engineering-as-a-service business that helps companies build remote teams quickly and cost-effectively. We have 1,000+ software engineers working as full-time, embedded members of development teams at over 200 leading tech companies.

Zuri got its first set of interns in 2018 and is now a multi-national corporation, with over 35,000 employees in more than 115 countries. Today, Cisco solutions are the networking foundations for service providers, small to medium business and enterprise customers which includes corporations, government agencies, utilities and educational institutions.

Follow this link to learn more about Zuri Internship https://internship.zuri.team/
Benefits of Zuri Internship
Learning
Connections
Jobs

Who can Apply
You have prior coding or design skills/knowledge.
You are a professional looking to connect with others.
You are looking for a challenge.

My Expectations

The chance to learn valuable work skills and gain useful experience
Sensible working hours
A reference upon completion of the internship.
Meet new software engineers
Work on real world Projects
Access to Zuri network composed of past finalists.
Get recommended to potential employers.
Access to job opportunities.
Occasional stipends depending on performance during the internship.

GIT TUTORIAL

 https://www.youtube.com/watch?v=RGOj5yH7evk

HTML TUTORIAL

 https://www.youtube.com/watch?v=qz0aGYrrlhU
 
JAVASCRIPT TUTORIAL

 https://www.youtube.com/watch?v=W6NZfCO5SIk

FIGMA TUTORIAL 

https://www.youtube.com/watch?v=g6rQFP9zCAM




Congratulations you have reached the end of this article.

Thank you for your time.

Feel free to leave a comment below, also advice is also welcome for improvement as this is my first article.