teleren/devto huggingface dataset:
I've read... A Mathematician's Lament
Tags: books, math
Published: 2022-01-16 18:24:41

> "If you want to build a boat, don't order people to gather wood and assign tasks and work, but instead teach people to long for the boundless immensity of the sea."

A Mathematician's Lament is more of an extended essay than a book - one man's problems with mathematics education without a viable solution. While I agree with him that the current state of mathematics in schools and universities is a travesty, the kind of "solution" he recommends is not the real solution. We all know what most of us thought about the math (and many other fields) in ES and HS, and leaving it all to the student is not an excellent solution.

> "Mathematics is the art of explanation. If you deny students the opportunity to engage in this activity - to pose their own problems, to make their own conjectures and discoveries, to be wrong, to be creatively frustrated, to have an inspiration, and to cobble together their own explanations and proofs - you deny them mathematics itself."

I think he argues that mathematics education gets tripped up in unnecessary formalism and syntax before conceptually interesting problems are tackled. The whole thing is defended with the ridiculous "you might need this someday" pragmatism that children will instantly tune out - is a sound one. It would be great if every elementary school teacher were the kind of engaged leader capable of putting their students to work on an exciting geometry or abstract algebra problem and wandering around not to give answers but to provide the occasional hint. But, unfortunately, I don't see how this will provide anyone with well-rounded mathematics education.

---

Don't get me wrong! I liked the premise of his essay. I would love that my professors had just a pinch of Lockhart's teaching spirit; it would make studying math much enjoyable. But, while I can see how it would make learning math so much more fun, it isn't practical. I think it could be accomplished in a small setting, but let's face it, the world doesn't allow for exploration. You have to master what they want you to master, troubling as that may be.
Cara Install MongoDB di Ubuntu 
Tags: ubuntu, linux
Published: 2022-01-16 14:59:06

Berikut ini langkah2 menginstall mongodb mengunakan sistem operasi linux dengan distro ubuntu versi 22.10

1. Import public key
```
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
```
Jalankan kode tersebut, maka akan memunculkan output bertuliskan OK

2.  Membuat file list
```
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
```

3. Reload package local
```
sudo apt-get update
```

4. Install package mongoDB
```
sudo apt-get install -y mongodb-org
```

5. Start server mongodb
```
sudo systemctl daemon-reload
sudo systemctl start mongod
sudo systemctl status mongod
```

### Troubleshooting
Jika anda mendapatkan error `Process: 8724 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=14)`
masukkan perintah berikut.
```
chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock

sudo service mongod restart
```

Sumber:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
https://askubuntu.com/questions/823288/mongodb-loads-but-breaks-returning-status-14
Understanding "this" in javascript
Tags: javascript, webdev
Published: 2022-01-16 18:15:23

Simply put "this" in javascript refers to the object itself, for example 
```
const myProfile = {
name:"Sabali",
sayHi:function(){
 console.log("Hi there, " + this.name)
  }
}

myProfile.sayHi() // "Hi there, Sabali"
```
Javascript is notoriously known for performing behaviors not expected by the developer . One of those unexpected behaviors comes from using the "this" key word by calling it through a reference. Here's a demonstration

```
let greeting = myProfile.sayHi()
greeting() // "Hi there, undefined"
```
The result is undefined reason being when calling a method through a reference, the method loses knowledge of what the original "this" was, in this case this becomes a global object.
In order to use this in an a reference we can employ the bind method.

Calling:

```
myProfile.greeting.bind(myProfile)
```
This creates a new function where this is bound to point to Sabali, independent of where and how the method is being called.
I created Quiz-app a quiz game ecosystem
Tags: javascript, webdev, css, beginners
Published: 2022-01-16 18:14:19

I have created a quiz-app with Html and Javascript 4 months ago which i used to learn javascript intermediately it uses basic javascript queries 
This Application is best for beginners and Intermediate Javascript Learners


Story so far
when i was thinking to create a Quiz-app for students who can take excerises from an application i didn't found a free Application that's why i created this project


features:
- Open sourced
- Runs online
- Have Multi-platform support
- Have Multi-device support
- Accesibility from anywhere
- Dark and Light Themes
- 13 Contributors

feel free to contribute on💚
 [Github](https://github.com/johnbabu021/quiz-app) 👩‍💻
Please star this project [Github](https://github.com/johnbabu021/quiz-app) 
## Light mode:

![Screenshot from 2021-10-03 14-59-41](https://user-images.githubusercontent.com/58719884/135747992-942328a0-3cf4-45eb-906e-d862d2b98c09.png)

## Dark mode:
![Screenshot from 2021-10-03 14-58-42](https://user-images.githubusercontent.com/58719884/135747965-89c60f7b-0cb7-400f-9775-54e6f899b8b2.png)


Running Live [Demo](https://johnbabu021.github.io/quiz-app/)


Feel Free to Contribute on [Github]💚(https://github.com/johnbabu021/quiz-app) 👩‍💻
I created Sweetgradients a Color gradient Ecosystem 🧠 🧠
Tags: javascript, css, html, webdev
Published: 2022-01-16 18:13:17

## [SweetGradients](https://sweetgradients.vercel.app/) -A Platform where you can find out color graidents easily


Story behind SweetGradients -When i was looking for gradients to be used in a project i didn't find anything but finally i findout a web app called Uigradients built with Vue.js.So i created a React.js version of that

[Github](https://github.com/johnbabu021/sweetgradients)

[demo](https://sweetgradients.vercel.app/)


Feel Free to contribute on this project 
[Github](https://github.com/johnbabu021/sweetgradients)
Made with  🥳
(function(){....})() Did you Know what is this
Tags: javascript, beginners, webdev, functional
Published: 2022-01-16 18:04:17

this function is called Immediately Invoked Function Expression(IIFE) 
what's the use of this function

- well this function get invoked itself at the time of load and we can do any ui process at that time let's say if i want to get data from     localstorge at the time of load to find the theme used by the user let's take this eg.
```
(function () {
    const value = localStorage.getItem('theme')
    if (value === 'Dark Mode') {
        darkMode()
//darkMode is outside IIFE
    }
    else if (value === 'Light Mode') {
        return null
    }
    else {
        localStorage.setItem('theme', 'Light Mode')
    }
})()
```

this code initially check theme and if it is dark calls another function in the script if it is light it returns null and if value is not present then create a theme useful in next load
How to create user IAM role for AWS console
Tags: aws, iamrole
Published: 2022-01-16 18:00:29

---

Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.

**1.** In the navigation pane, choose Users and then choose Add users.

![Add IAM user in AWS ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivd0a8z1jj6zb5pusxym.png)

**2.** Type the user name for the new user. This is the sign-in name for AWS. If you want to add multiple users, choose to Add another user for each additional user and type their user names. You can add up to 10 users at one time.

**3.** Select the type of access this set of users will have. You can select programmatic access, access to the AWS Management Console, or both.
  • For Console password, choose Autogenerated password or Custom password
![Create IAM user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qchawso8g619itylq7q6.png)

**4.** On the Set permissions page, specify how you want to assign permissions to this set of new users. Choose one of the following three options:
  • Add user to the group. 
  • Copy permissions from an existing user. 
  • Attach existing policies directly. 

![Add IAM user permission](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b6riq0rpcx8icb69qhff.png)

**5.** (Optional) Add metadata to the user by attaching tags as key-value pairs. 

![IAM user metadata- key,value](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jeszsiqqtnyb6jmhpzhy.png)

**6.** Next: Review to see all of the choices you made up to this point. When you are ready to proceed, click on Create user.

![Review IAM User details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phzo5b2gq0cb2741rnf4.png)

**7.** Now your login details is already to use. Login using your credentials. [Login Page](https://console.aws.amazon.com/console/home)
	 

For more IAM user details check out AWS guide[(Link)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console).
reusing css color attributes
Tags: css, design, webdev, beginners
Published: 2022-01-16 17:52:24

```
:root{
--primary-color:red;
--secondary-color:blue;

}
```

root element match the top most element in a web document(tree structure) so when creating variables in root it can be accessed anywhere inside the dom(Document Object Model)
--primary-color,--secondary-color are variablels.We can reuse this elements by the following code 
```
div{
color:var(--primary-color);
background-color:var(--secondary-color);
}
```


this selects --primary-color to all elements with a div parent and background-color to --secondary-color
DockerHub RateLimiting; Solving via Nexus OSS
Tags: docker, ci, devops, showdev
Published: 2022-01-16 17:41:35


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

## What is this about?

Docker is continuously moving towards commercialising their services, which is in a way correct thing to do to keep the ship sailing. One such change they brought in November 2020 is to rate limit the API calls being made to Docker Hub for Docker image pulls.
How we got impacted?
At our organisation, we run our CI system at fairly large scale, where there are thousands of developers actively consume the central CI system for their code commits. All the repos are Docker compatible hence most of them have rely on DockerHub for official images like centos, java, node, python, etc.

So, when this rate limiting was introduced it intermittently impacted our CI system where builds started failing with exceptions from Docker Hub like below :-

```
ERROR: toomanyrequests: Too Many Requests.
You have reached your pull rate limit. 
You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limits. 
You must authenticate your pull requests.
```

## Solution: Sonatype Nexus — Docker Registry

In my opinion Sonatype Nexus is an amazing, must have tool in a large scale CI system. We started using Nexus for proxying Java, NodeJS and also hosting private packages too.
So it was an obvious choice to use Nexus for solving DockerHub rate limiting issue. By proxying DockerHub and reducing dependency on DockerHub.

Docker Hub is the common registry used by all image creators and consumers. To reduce duplicate downloads and improve download speeds for your developers and CI servers, you should proxy Docker Hub and any other registry you use for Docker images.

We created a proxy repo in Nexus for DockerHub and added a small configuration to mirror the registry in our CI servers (which are autoscaled, so it was a change in the AMI).

## How it works?

The first time you request an image from your local registry mirror, it pulls the image from the public Docker registry and stores it in Nexus before handing it back to the CI servers. On subsequent requests, the Nexus registry mirror is able to serve the image from its own storage.
/etc/docker/daemon.json

```
{
  "registry-mirrors": ["http://nexus.domain.org:18000"]
}
```
Simple and effective !

For detailed information on configuration do check the official documentation of Nexus here https://help.sonatype.com/repomanager3/formats/docker-registry/proxy-repository-for-docker

## Looking for More…!!

Pls do follow. I am planning to post more such blogs which are practical and scalable solutions around Docker, AWS, Python.
In case any help is required for setup or approach pls don’t think twice, before asking me. 

Cheers!
Share Mp3 as Secret Message
Published: 2022-01-16 17:24:49

It's easy to share text, string, JSON, or XML data over the web. But what if there is a need to share an MP3 file as a secret message?

You can use MP3 to base64 string tool do that.

I have been using MP3 to base64 tools to generate the base64 string and send it via DM in tweeter or on Facebook.

This website helps to do achieve to send a mp3 file as string. 

https://codebeautify.org/mp3-to-base64-converter 

Open above link and upload the mp3 file. This tool will generate the base64 string.

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

I hope it helps.
How To Undo Staged (Indexed) Changes In Git
Tags: git, github, howto, beginners
Published: 2022-01-16 17:10:07

In this question, we are going to discard and undo staged (index) changes in a Git repository. If you need to clean unstaged files, you can refer to [this question](https://devtonight.com/questions/how-to-undo-unstaged-changes-in-git-working-directory?utm_source=dev&utm_medium=questions&utm_campaign=how-to-undo-staged-indexed-changes-in-git).

First, stage all the files required to discard with the `git add` command.

```
git add .
```

If you only need to discard some specific files, stage them like this.

```
git add file1 file2 file3
```

## Discard Staged Changes With Git Reset

We can use `git reset` with `--hard` to discard staged files. After running the `git reset` command, all the changes of the staged files including the newly created and existing files will be discarded.

```
git reset --hard
```

## Discard Staged Changes With Git Stash

The main intention of Git Stash is to move current changes into a separate temporary area so you can continue with something else and the stashed changes can be applied later. But we can use the Git Stash to discard staged changes as well. After running the `git stash` command, all the staged changes will be disappeared and move to the stash list.

```
git stash
```

Now you will be able to see the stash list by running this command.

```
git stash list
```

If you need, you can remove the lastly created stash.

```
git stash drop stash@{0}
```

Or otherwise, clean the entire stash list.

```
git stash clear
```

## Unstage First, Then Discard Approach

It is obvious, `git reset` and `git stash` commands do the job quickly in one go. However, you can use the following commands to unstage the staged files first and then discard them using the commands we explained in the [How To Discard Undo Changes In Git Working Directory](https://devtonight.com/questions/how-to-undo-unstaged-changes-in-git-working-directory?utm_source=dev&utm_medium=questions&utm_campaign=how-to-undo-staged-indexed-changes-in-git) question.

Unstage all the staged files using the `git restore` command.

```
git restore --staged .
```

Unstage some specific files.

```
git restore --staged file1 file2 file3
```

Unstage all the staged files using the `git reset` command.

```
git reset
```

Unstage some specific files.

```
git reset file1 file2 file3
```

Feel free to visit [devtonight.com](https://devtonight.com?utm_source=dev&utm_medium=questions&utm_campaign=how-to-undo-staged-indexed-changes-in-git) for more related content.
How to Vibrate Phone using Online Vibrating Tool?
Published: 2022-01-16 17:09:37

Sometime there is dire need to test the phone vibration on any mobile phone. 

Instead of going to any setting and figure out how to vibrate any phone, here is an tool which can do it for you.

You can google **Online Vibration Simulator** or click on this link 

https://codebeautify.org/online-vibration-simulator

This link only works only on mobile.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3mfh4jtysgkfkgk3hry.png)
 
User can click on the preference provide in this site. Either user can vibrate phone for 1 or 2 or 5 second.
Rename Python Variables with nvim
Tags: python, vim
Published: 2022-01-16 16:26:46

---
canonical_url: https://waylonwalker.com/til/nvim-rename-python/
cover_image: https://images.waylonwalker.com/til/nvim-rename-python.png
published: true
tags:
- python
- vim
- vim
title: Rename Python Variables with nvim
series: til
---

I don't use refactoring tools as much as I probably should.  mostly because I work with small functions with unique names, but I recently had a case where a variable name `m` was everywhere and I wanted it named better.  This was not possible with find and replace, because there were other `m`'s in this region.


I first tried the nvim lsp rename, and it failed, Then I pip installed rope, a refactoring tool for python, and it just worked!

```bash
pip install rope
```

Once you have rope installed you can call rename on the variable.

```vim
:lua vim.lsp.buf.rename()
```
JavaScript Algorithm: Sum of All Primes
Published: 2022-01-16 16:49:15

This problem asks to return sum of all prime numbers that are less than or equal to a given number. 

A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. 

Here is how to solve that algorithm:

**Step 1. Set up the algorithm, accounting for the number 2 (the lowest prime):**

```
function sumprime(num){
    if (num < 2){
        return 0; 
    }
    return num;
}

sumprime(10); 
```

**Step 2. If num is greater than 2, we want to keep track of all the prime numbers up to and including the given parameter. We will need to use a for loop to check for composite numbers (the opposite of prime).**

```
function sumprime(num){
    if (num < 2){
        return 0; 
    }

    const primes = [];
    for (let i = 2; i <= num; i++){
        let composite = false; 
        for (const p of primes){
            if (i % p === 0){
                composite = true; 
                break; 
            }
        }
        if (!composite){
           primes.push(i)
        }
    }
    console.log(primes)
    return num; 
}

sumprime(10); 
``` 

**Step 3. Sum up the numbers!**

```
function sumprime(num) {
    if (num < 2) {
        return 0;
    }

    const primes = [];
    for (let i = 2; i <= num; i++) {
        let composite = false;
        for (const p of primes) {
            if (i % p === 0) {
                composite = true;
                break;
            }
        }
        if (!composite) {
            primes.push(i)
        }
    }
    let sum = 0;
    for (const p of primes) {
        sum += p;
    }
    return sum;
}

sumprime(10);
```
How to use REM units with react-window with a custom hook
Tags: hooks, reactwindows, react
Published: 2022-01-16 16:51:34

---
title: How to use REM units with react-window with a custom hook
published: true
date: 2022-01-16 16:44:56 UTC
tags: hooks,reactwindows,react
canonical_url: https://relatablecode.com/how-to-use-rem-units-with-react-window-with-a-custom-hook/
---

![Window](https://cdn-images-1.medium.com/max/1024/1*Bc9VxPgcqhUaWW7Pcmmd5g.jpeg)
_Photo by Hannah Tims on Unsplash_

A while back I transitioned my web app to using [REM](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units) units instead of the PX unit. This has a lot of benefits that I won’t get into this article, but I did encounter a few conflicts I did not consider initially. [react-window](https://github.com/bvaughn/react-window) is a library that helps virtualize long lists!

This is super useful for rendering a considerably less amount of components/tags in the HTML to optimize the performance of the app. But, one thing to consider is that react-window expects certain parameters and properties to be specified in PX.

This article will quickly go over how I solved this problem.

### react-window

React-window offers a component called FixedSizeList which can render out our list of components. The property we are most interested in is itemSize. This takes in the following:

> _Size of a item in the direction being windowed. For vertical lists, this is the row height. For horizontal lists, this is the column width._

However, the word **size,** in this case **,** refers specifically to pixels! What we have to do is convert our REM units to PX.

This is the small hook I created:

![useRemtoPx hook](https://cdn-images-1.medium.com/max/1024/0*XmhLf4CaNNAlUoLx)

### Implementing the hook

Let’s break down this hook into several parts. For sake of clarity, I named the variable **itemSize** inside the hook but can this can be done with an early return. First, we get the font size from the user with getComputedStyle, calling upon the document properties. Afterward, we multiply that amount with how we plan to convert the units from PX to REM.

This hook can just be directly called in the component with the necessary REM units/multiplier that may be necessary:

![Small example component](https://cdn-images-1.medium.com/max/1024/0*18m6tZabRu2I4oIx)

And that's it! Let me know if this hook was of any use to you or if you have any other preferred way to use REM units with react-window or any other library that specifically requires PX units.

More content at [Relatable Code](https://relatablecode.com)

_Originally published at_ [_https://relatablecode.com_](https://relatablecode.com/how-to-use-rem-units-with-react-window-with-a-custom-hook/) _on January 16, 2022._
How to host wordpress website in 3 easy steps using AWS Lightsail
Tags: wordpress, aws, webdev, lightsail
Published: 2022-01-16 16:39:24

#### **_Step 1:_** Create or login to AWS account - [Login/sign up to AWS](https://aws.amazon.com/console/)


#### **_Step 2:_** Create Wordpress Instance in Ligtsail
      
After Login Click on Services in AWS console and search for Lighsail and open Lighsail service. It will open the Lightsail console.

   **1.** Click on create instance option.

![Create Lightsail Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47wv89s316hk4q2d8b8w.png)

   **2.** Select instance location, platform, and predefined WordPress blueprint

![Lightsail platform and blueprint selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rap40v3fngfdedc8uqj.png)

  **3.** Select preferred instance plan 

![AWS lightsail plan](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28eg0jrut87ym67igxt3.png)

  **4.** Add Instance identity name and click on create an instance

![lightsail instance name and create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7fj4ysparfxkcx3a6ou.png)


####**_Step 3:_** Get your Lightsail WordPress login password via SSH

 **1.** Click on the recently created WordPress instance and you can see the IP address and manage instance option. Click on "Connect using SSH".

![connect lightsail instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4d8kl07lsq4gnldxcs1.png)

**2.** After open the SSH client in the browser, enter the following command to retrieve your default password.

```
cat $HOME/bitnami_application_password
```


![Retirve default password in Lightsail wordpress](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sfkpprlvqg6mdnjjo23.png)

**3.** Open WordPress login using your static IP and login to WordPress console

```
http://<PublicIpAddress>/wp-login.php
```

For more detail related to AWS lightsail Please follow me and comment and ask your query, I will happy to help everyone.
Check Lighsail official document for AWS WordPress Lightsail details. [LINK](https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-tutorial-launching-and-configuring-wordpress)