teleren/devto huggingface dataset:
Let's add a key value to the Windows 10 registry
Tags: tutorial, beginners, windows10
Published: 2022-06-14 00:34:44

The registry is a database of information that contains, user passwords, windows, and hardware settings. A key value contains settings specific to a program, these include its location and version.

There are 5 root keys, known also as a HIVE, that a tech should be aware of, these are the following, ROOT, USER, MACHINE, USERS, and CONFIG.
![Keys](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfz8r4p8zrs6ct1m91dq.PNG)

**HKEY_CLASS_ROOT**
Contains information about file extensions, and registered applications such as OLE. Settings that are specific to the local computer. 

**HKEY_CURRENT_USER**
Contains information about the user who is currently logged in to the Windows machine.  

**HKEY_LOCAL_MACHINE**
Stores information about hardware and software settings, specific to the local computer. This information used by all users that login on to the computer. 

**HKEY_USERS**
Holds information about all the users who are actively loaded on the local machine, includes generic and user-specific information.

**HKEY_CURRENT_CONFIG**
HKEY_CURRENT_CONFIG is a shortcut to HKEY_LOCAL_MACHINE, but this contains information about the hardware attached to the computer.

You can also view the keys in their binary format in the following file location 
`This PC -> Local Disk (C:) -> Windows -> System32 -> config`
![binary files](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwlaqoq19a9nqbrgsqqg.png)

Now allows us to begin creating a new sub-key by simply opening `regedit.exe` using `run (Windows + R).`
![run command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvb3yq37pb68tfryboqb.PNG)

Once Registry Editor opens, click on `HKEY_LOCAL_MACHINE` 
![machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kl9r8hoiivh4oyz8oaod.PNG)
Then select the `SOFTWARE`, scroll down until you find the `Microsoft` tab
![Microsoft](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rnxppschsjxgjf2i98j.PNG)
Once again, scroll down until you find `Windows → Current Version -> Run`
![Windows found](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96hsuj7sb1y2u84uzcz3.PNG)
![Run](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tes8jmflhs7lszvw25m.PNG)
Hover over `Run` with the mouse, right-click mouse button, once the menu pops up, select `new -> key`, specify a name for the new key. I will call mine Kenji
![Kenji](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mopm6ab0l20c90r0x7k9.png)
after hover over the blank space, right-click the mouse button again and select `new -> key`
![new key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mehl7k1wgg1coitmxb1b.png)
Provide a key value name.
![kenjihere](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3bmdxxyzyv2f86y9ptl.png)
That's it! That's how you create a new key value. Now, most of the time you'll be inputting values from a manual to solve a problem. This was a little guide to show, how one would go about doing it.

Thanks for reading!
Kenji
Installing Node.js using nvm, the best way.
Tags: webdev, beginners, tutorial, react
Published: 2022-06-14 00:20:13

This article is intended to take you through the best way to get node.js LTS running on your windows machine at ease. 

## Node.js
This is an open-source, cross-platform JavaScript runtime environment; that runs on Windows, Linux, Unix, Mac, etc. It's not exclusively designed for the Backend as it also feeds the Frontend with API services and then serves it in real-time. 

##Steps to get node.js installed

- Follow the link to  download nvm [nvm repository](https://github.com/coreybutler/nvm-windows)
- Download the nvm-setup.zip
- Open the zip file, to extract the nvm-setup.exe file.
- install the setup as administrator. the Windows installation wizard will prompt you.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kf9qc9wc1sbpa02ljqd.PNG)
- Once the installation is complete. Open your CMD, Gitbash, or PowerShell to list versions currently running or installed. with Windows-nvm (nvm ls)  if non, continue the process.
![check for current version in use](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcsydlru9o6c1m1ccck8.PNG)

- Check for available versions of node.js to use with (nvm list available)
![list of node.js using nvm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecn59r5flpqqrw1b0aod.PNG)

- From the list above chose the recommended version for you. The latest stable release LTS of node.js is highly Recommended. Let us install the LTS version number with(nvm install 16.15.1).
![latest version of nvm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stm4a76rv886d40gwi0n.PNG)

- You can now list the versions of node.js that are installed with (nvm ls)
![list node.js installed nvm ls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wbj4ivlupp7skjotv8w.PNG)

- Use the Windows-nvm command. (nvm use 16.15.1) to set or activate the current version to be used, you can as well switch version 

- Finally, verify that node.js is installed and the version with (npm --version).

> With this you can confidently run all your ng, npx, npm command for Angular, React, etc... smoothly.

## Error Handling
Incase you've installed node.js without nvm and you're experiencing errors, try installing it now with nvm. if the error persists, kindly navigate to your local(c:) -> program file -> locate node.js folder and delete it or rename it and continue the installation.

> Hope this helps... Cheer
Aaaand I’m done! API Deployment and Review
Tags: api, node, heroku, webdev
Published: 2022-06-14 00:17:19

Deployment ultimately became a trivial part of the application despite the effort I put into thinking about the platform I was going to deploy it on. So in my previous article, I thought about deploying it as a serverless function and explored that idea. The conversion I spoke about in the previous article was an attempt to prepare the application for that deployment. The reason why I say that deployment became trivial is because I decided to deploy on Heroku. I had done so because I had an application previously deployed on Heroku and I knew enough of the process to make deployment relatively pain free.

The main thing would be compiling the application to JavaScript (for those who don’t remember, this was written in TypeScript) and then deploying the files in the dist folder. The deployment process that I have isn’t very streamlined honestly. I manually copy the dist file over to another folder that handles deployment. If there are any necessary changes that need to be made, I’ll make them (I believe the deployment folder has a different package.json or at least one that’s a bit modified) and then I’ll go through the process of pushing them to a Heroku account. A slight annoyance but I was able to get my app up quickly and ready for review.

I then reached out to my mentor to get my work reviewed. We did it over a Twitter Space and took his time playing around with the application. He had a few critiques here and there but he really loved it for the most part. The thing that he enjoyed the most was the Swagger UI that was added to the application. It wasn’t something that was needed but after working with it at work, I wanted to do something similar for my application as well. This made testing really easy since I haven’t created a Front-End for the application, it made it so much easier to work with. I personally learned a lot from the review as well, my main takeaway being the idea of middleware in APIs. The reason why it came up was because I had decided to have all the other HTTP verbs other than POST to send a not implemented error code if someone attempted to use it. I had done so by manually setting endpoints and I was given the suggestion of updating the application to use a middleware to do that job rather than manually setting the endpoints. Was definitely something I was interested in doing and so I took notes and decided I would look that up later.

All in all, I felt I did a great job delivering this and learned a massive amount from this entire experience!

Here’s a commit showing my reviewed app: https://github.com/chadstewart/you-go-backend-project/tree/79c5401ecd76675632ce1f13e63ab6aa70af037c

In the next article of this series, I’ll talk about some miscellaneous work I did such as logging, adding middlewares and making the image manipulations a service.
Count Number of Texts
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 00:00:48

Alice is texting Bob using her phone. The **mapping** of digits to letters is shown in the figure below.

![](https://assets.leetcode.com/uploads/2022/03/15/1200px-telephone-keypad2svg.png)

In order to **add** a letter, Alice has to **press** the key of the corresponding digit `i` times, where `i` is the position of the letter in the key.

*   For example, to add the letter `'s'`, Alice has to press `'7'` four times. Similarly, to add the letter `'k'`, Alice has to press `'5'` twice.
*   Note that the digits `'0'` and `'1'` do not map to any letters, so Alice **does not** use them.

However, due to an error in transmission, Bob did not receive Alice's text message but received a **string of pressed keys** instead.

*   For example, when Alice sent the message `"bob"`, Bob received the string `"2266622"`.

Given a string `pressedKeys` representing the string received by Bob, return _the **total number of possible text messages** Alice could have sent_.

Since the answer may be very large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** pressedKeys = "22233"
**Output:** 8
**Explanation:**
The possible text messages Alice could have sent are:
"aaadd", "abdd", "badd", "cdd", "aaae", "abe", "bae", and "ce".
Since there are 8 possible messages, we return 8.

**Example 2:**

**Input:** pressedKeys = "222222222222222222222222222222222222"
**Output:** 82876089
**Explanation:**
There are 2082876103 possible text messages Alice could have sent.
Since we need to return the answer modulo 109 + 7, we return 2082876103 % (109 + 7) = 82876089.

**Constraints:**

*   `1 <= pressedKeys.length <= 105`
*   `pressedKeys` only consists of digits from `'2'` - `'9'`.

**SOLUTION:**

    class Solution:
        def ways(self, m, n):
            if m == 0:
                return 1
            if (m, n) in self.cache:
                return self.cache[(m, n)]
            ways = 0
            for i in range(1, min(m, n) + 1):
                ways += self.ways(m - i, n)
            self.cache[(m, n)] = ways
            return ways
        
        def countTexts(self, pressedKeys: str) -> int:
            self.cache = {}
            keys = [0, 0, 3, 3, 3, 3, 3, 4, 3, 4]
            n = len(pressedKeys)
            i = 0
            ways = 1
            while i < n:
                ctr = 1
                while i < n - 1 and pressedKeys[i] == pressedKeys[i + 1]:
                    i += 1
                    ctr += 1
                i += 1
                c = pressedKeys[i - 1]
                ways = (ways * self.ways(ctr, keys[int(c)])) % (10 ** 9 + 7)
            return ways
Reflections on a Decade at Heroku
Published: 2023-06-08 21:53:34

---
title: Reflections on a Decade at Heroku
published: true
date: 2022-06-14 00:00:00 UTC
tags: 
canonical_url: https://greg.nokes.name/2022/06/14/a-decade-at-heroku/
---

At about 7:45am March 26th 2011, I walked up to the doors at Heroku for the first time. I was early because that’s what you did where I came from.

The doors were locked. No one responded to the buzzer.

So I went and got some really bad coffee at the [DNA Lounge](https://www.dnalounge.com) next door, and waited. As I recall, I saw someone walk in at about 9, and followed them in. That’s how the next chapter in my life started.

[Read More](https://greg.nokes.name/2022/06/14/a-decade-at-heroku/)
“Adopt A Pet” in 3D — Swap Out Assets in Real Time in Unity
Tags: tutorial, 3d, unity3d, cloud
Published: 2022-06-13 23:42:17

Swap out assets in real time in Unity! Here we simulated a virtual pet adoption. Adopt a dog or cat (or both) from the animal shelter. All you have to do is change the entry ID of each asset (cat or dog) for them to appear.

Register
========

Don’t have an echo3D account? Register for FREE at [echo3D](https://console.echo3d.co/#/auth/register).

Video Tutorial
==============

Follow along with the video here

{% youtube nxEGKecwJX0 %} <br>



Setup
=====

*   Clone the [repo](https://github.com/echo3Dco/Unity-echo3D-demo-AdoptAPet/)
*   Install the echo3D [Unity SDK](https://docs.echo3d.co/unity/installation)
*   Download the 3D models from the Models folder in the project
*   Go to echo3D console and [click “Add to Cloud”](https://docs.echo3d.co/quickstart/add-a-3d-model) and upload the models
*   Add this [metadata](https://docs.echo3d.co/web-console/manage-pages/data-page/global-data-and-metadata) to each asset:

![](https://miro.medium.com/max/1400/1*smwFmynow_k0kScrS8ilvA.png)![](https://miro.medium.com/max/1400/1*KT2tBByUUsWkuCcGcSdToQ.png)

*   Open the SampleScene in Unity
*   Drag the echo3D\_Animal and echo3D\_Kennel prefabs into the Hierarchy
*   [Add the API key](https://docs.echo3d.co/quickstart/access-the-console) and entries ID on the echo3D object in the Hierarchy using the the Inspector. Swap them out between Play Modes to see them change in real time.
*   Play in Unity to see the asset materials in real time from the echo3D console

Learn more
==========

Refer to our [documentation](https://docs.echo3d.co/unity/) to learn more about how to use Unity and echo3D.

Support
=======

Feel free to reach out at [support@echo3D.co](mailto:support@echo3D.co) or join our [support channel on Slack](https://go.echo3d.co/join). For additional troubleshooting, debug [here](https://docs.echo3d.co/unity/troubleshooting).

Screenshots
===========

![](https://miro.medium.com/max/1400/1*hx06DLXpbd1kEZY_AmxUmA.png)![](https://miro.medium.com/max/1008/1*nAyL4w4KZBh4wUiLinODVw.png)![](https://miro.medium.com/max/1004/1*rfatwVMykRhoqMbreXcF3Q.png)

For more easy tutorials, check these out:

*   [Build a 3D Balloon Pop game in Unity](https://medium.com/echo3d/build-a-balloon-pop-game-unity-free-eed9fe7d8be9)
*   [Get a Quarantine Dog in AR](https://medium.com/echo3d/get-a-quarantine-dog-in-ar-8383ea55376b)
*   [How to Create 3D Content and See It In AR](https://medium.com/echo3d/how-to-create-3d-content-and-see-it-in-ar-free-no-coding-required-369e5b4a4b3e)

***

>_**echo3D** ([www.echo3D.co](http://www.echo3d.co/); Techstars 19’) is a cloud platform for 3D/AR/VR that provides tools and network infrastructure to help developers & companies quickly build and deploy 3D apps, games, and content._

![](https://miro.medium.com/max/1400/1*cNrRDT0JEpkcy-zG6KBNgw.png)
React Slider Responsive Help Needed
Tags: help, javascript, react
Published: 2022-06-13 23:41:01


I'm trying to create a carousel that is responsive and will keep my image in ratio and not stretch them on different devices. What library should I use, and how can I achieve this?

I'm using ReactJS

What were you expecting to happen?
I want my images to remain in the same ratio as they are meant to be, on larger displays, 4 images will be shown, then the smaller the display the less images there will be per slide, until on mobile it's only 1 image per slide

What is actually happening?
The responsiveness that it does go from 4 images on a bigger display down to 1 image on a mobile display, however across different devices the images looses their ratio and become stretched.






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


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


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


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6s86vweurg2qcxo6a7iv.jpg)

This is a screenshot on my iPhone 12 Max Pro


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

This is a screenshot on my Samsung S20E


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

This is a screenshot on my iPad Pro landscape


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ud0h3xhub3qrdvj5fek.jpg)

This is a screenshot on my iPad Pro portrait.



As you can see the images appear to stretch. How can I solve this?



This is the original image dimensions


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

Kind Regards,
Louis
Two Sum - O(n^2) solution
Tags: cpp
Published: 2022-06-13 23:37:35

```cpp
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        
        int i = 0;
        int j;
        vector<int> sol;
        
        while (i < nums.size())
        {
            
            j = i+1;
            
            while (j < nums.size())
            {
                if (nums[i] + nums[j] == target)
                {
                    sol.push_back(i);
                    sol.push_back(j);
                    break;
                }
                else
                {
                    ++j;
                    continue;
                }
                
            }
            if (sol.size() > 0) {
                break;
            }
            
            ++i;
        }
        
        return sol;
    }
};
```
Reverse Linked List
Tags: leetcode, dsa, theabbie
Published: 2022-06-13 23:30:40

Given the `head` of a singly linked list, reverse the list, and return _the reversed list_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg)

**Input:** head = \[1,2,3,4,5\]
**Output:** \[5,4,3,2,1\]

**Example 2:**

![](https://assets.leetcode.com/uploads/2021/02/19/rev1ex2.jpg)

**Input:** head = \[1,2\]
**Output:** \[2,1\]

**Example 3:**

**Input:** head = \[\]
**Output:** \[\]

**Constraints:**

*   The number of nodes in the list is the range `[0, 5000]`.
*   `-5000 <= Node.val <= 5000`

**Follow up:** A linked list can be reversed either iteratively or recursively. Could you implement both?

**SOLUTION:**

    # Definition for singly-linked list.
    # class ListNode:
    #     def __init__(self, val=0, next=None):
    #         self.val = val
    #         self.next = next
    class Solution:
        def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
            prev, curr = None, head
            while curr:
                curr.next, prev, curr = prev, curr, curr.next
            return prev
Evitar timeout en conexiones por SSH
Tags: ssh, linux, server, tutorial
Published: 2022-06-13 23:24:40

La mayoría de los servidores a los que nos conectamos por ssh cierran la conexión en cuanto detecta inactividad por parte del usuario. 

Para prevenir una desconexión por parte del servidor tendremos que agregar una línea al archivo /etc/ssh/ssh_config, este fichero es leído por nuestro sistema cada vez que iniciamos una conexión ssh. 

Lo que indicaremos con la línea de texto es lanzar un paquete cada 120 segundos, haciéndole saber al servidor que aún estamos trabajando con él. 

La línea a agregar es la siguiente: 

```
ServerAliveInterval 120
```

Saludos.
How to enable PCNTL on Ubuntu server 16.04
Tags: ubuntu, php, aws
Published: 2022-06-13 23:05:35

for ubuntu 18 and 20: [replace 7.4.28 with your php version]

1- `php -v`
result for exapmle: PHP 7.4.28

2- `sudo wget https://www.php.net/distributions/php-7.4.28.tar.gz`.

3- `sudo tar xfz php-7.4.28.tar.gz && sudo rm -rf php-7.4.28.tar.gz`

4- `cd php-7.4.28/ext/pcntl/`


5- `sudo phpize`
if phpize is not installed you can install it with `apt install php7.4-dev`

6- `sudo ./configure --with-php-config=/usr/bin/php-config`

7- `sudo make && sudo make install`
the result must be like Installing shared extensions: `/usr/lib/php/20190902/`
  
8- `cd ../../../ && sudo rm -rf php-7.4.28`

9- `cd /etc/php/7.4`

10- `sudo sh -c "echo 'extension=pcntl.so' > ./mods-available/pcntl.ini"`

11- `sudo nano ./cli/php.ini` then add `extension=pcntl`.
repeat this job for `sudo nano ./apache2/php.ini` or `sudo nano ./fpm/php.ini`.

12- in all above `php.ini` there is disable_functions that include `pcntl` prefix. you must enable which one you want.

13- restart your apache2 or fpm with:
`sudo service apache2 restart`

14- you can check it with `die(extension_loaded('pcntl'))`; in `test.php`

note: if you got error : PHP Warning: Module 'pcntl' already loaded in Unknown on line 0, remove `extension=pcntl` only in `cli/php.ini`

Source:[https://stackoverflow.com/a/64634134/7521380](https://stackoverflow.com/a/64634134/7521380)
Number of Recent Calls
Tags: leetcode, dsa, theabbie
Published: 2022-06-13 22:30:40

You have a `RecentCounter` class which counts the number of recent requests within a certain time frame.

Implement the `RecentCounter` class:

*   `RecentCounter()` Initializes the counter with zero recent requests.
*   `int ping(int t)` Adds a new request at time `t`, where `t` represents some time in milliseconds, and returns the number of requests that has happened in the past `3000` milliseconds (including the new request). Specifically, return the number of requests that have happened in the inclusive range `[t - 3000, t]`.

It is **guaranteed** that every call to `ping` uses a strictly larger value of `t` than the previous call.

**Example 1:**

**Input**
\["RecentCounter", "ping", "ping", "ping", "ping"\]
\[\[\], \[1\], \[100\], \[3001\], \[3002\]\]
**Output**
\[null, 1, 2, 3, 3\]

**Explanation**
RecentCounter recentCounter = new RecentCounter();
recentCounter.ping(1);     // requests = \[1\], range is \[-2999,1\], return 1
recentCounter.ping(100);   // requests = \[1, 100\], range is \[-2900,100\], return 2
recentCounter.ping(3001);  // requests = \[1, 100, 3001\], range is \[1,3001\], return 3
recentCounter.ping(3002);  // requests = \[1, 100, 3001, 3002\], range is \[2,3002\], return 3

**Constraints:**

*   `1 <= t <= 109`
*   Each test case will call `ping` with **strictly increasing** values of `t`.
*   At most `104` calls will be made to `ping`.

**SOLUTION:**

    import bisect
    
    class RecentCounter:
    
        def __init__(self):
            self.times = []
    
        def ping(self, t: int) -> int:
            bisect.insort(self.times, t)
            n = len(self.times)
            return n - bisect.bisect_left(self.times, t - 3000)
    
    
    # Your RecentCounter object will be instantiated and called as such:
    # obj = RecentCounter()
    # param_1 = obj.ping(t)
eBPF learning material(updating)
Tags: ebpf
Published: 2022-06-13 22:16:55

preparing for next learning...

## Background and design
[A thorough introduction to eBPF](https://lwn.net/Articles/740157/)
[An introduction to the BPF Compiler Collection](https://lwn.net/Articles/742082/)
[Early packet drop — and more — with BPF](https://lwn.net/Articles/682538/)
[XDP](https://github.com/iovisor/bpf-docs/raw/master/Express_Data_Path.pdf)

## Good to start
[ebpf-beginners](https://github.com/lizrice/ebpf-beginners)

## eBPF tool
### c
https://github.com/iovisor/bcc
### go
[libbpfgo](https://github.com/aquasecurity/libbpfgo)
[ebpf](https://github.com/cilium/ebpf)

## Book
[BPF Performance Tools](https://www.brendangregg.com/bpf-performance-tools-book.html)

## website
https://www.brendangregg.com/ebpf.html

## supported eBPF program
What kind of eBPF program can be triggered by event, depends on the kernel version. 

can be found in the *bpf.h* 
https://elixir.bootlin.com/linux/v5.18/source/include/uapi/linux/bpf.h#L922

or use *bpftool* to find them
```shell
//todo
```

## eBPF command
https://elixir.bootlin.com/linux/v5.18/source/include/uapi/linux/bpf.h#L840