teleren/devto huggingface dataset:
[Binary Search]Kth Missing Number
Tags: 100daysofcode, algorithms, java, programming
Published: 2021-12-15 19:20:57

# [Description](https://binarysearch.com/problems/Kth-Missing-Number/solutions/7055221)

Given a list of sorted unique integers `nums` and an integer `k`, return the `k`th (0-indexed) missing number from the first element of the list.

**Constraints:** 

- `n ≤ 100,000` where `n` is the length of `nums`.

## Example 1

### Input

```
nums = [5, 6, 8, 9]
k = 0
```

### Output

```
7
```

### **Explanation**

```
7 is the first missing number.
```

---

## Example 2

### Input

```
nums = [5, 6, 8, 9]
k = 3
```

### Output

```
12
```

### **Explanation**

```
The first four missing numbers are [7, 10, 11, 12]
```

---

# Intuition

1. we need to find how many values are missing in this array
2. if missing values are beyond k, we can return the result
3. if missing values are below k, we need add the left value on the last number in the array

# Implementation

```java
import java.util.*;

class Solution {
    public int solve(int[] nums, int k) {
        int missing = 0;
        for (int i = 1; i < nums.length; i++) {
            int different = nums[i] - nums[i - 1];
            if (missing + different - 1 > k) {
                return nums[i - 1] + k + 1 - missing;
            }
            missing += different - 1;
        }
        return nums[nums.length - 1] + k + 1 - missing;
    }
}
```

## Time Complexity

- Time: O(n)
- Space: O(1)
Eclipse Not Working in 16.04 in Ubuntu?
Tags: ubuntu
Published: 2021-12-19 13:50:55

---
title: Eclipse Not Working in 16.04 in Ubuntu?
published: true
date: 2021-12-15 19:15:00 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/eclipse-not-working-in-16-04-in-ubuntu/
---

![](https://eadn-wc01-5196795.nxedge.io/cdn/wp-content/uploads/2021/12/eclipse-not-working-in-16-04-in-ubuntu_11712-300x225.png)

6.04eclipse

Eclipse was working as good as anything on 14.04. I did a clean install of 16.04 and installed Eclipse. But it runs a Java program only once after which it just hangs during subsequent attempts before I remove and reinstall it. I have tried many things, since in the beginning I needed CDT as well. Right now, I just want to remove everything related to eclipse and do a fresh install (remove all the configs and dependencies). Please note that I used Eclipse installer to install Eclipse and the eclipse icon image is also not appearing (the default ubuntu ? is appearing).

#### Accepted Answer

I had something the same with 16.04 and Eclipse Mars. I thought it had frozen but in fact it was running very, very slowly. The problem is the version of GTK+ 3, shipped with 16.04. Fortunately the solution is very easy. Open a terminal and then type `export SWT_GTK3=0`, then start Eclipse from the terminal. If that works, then a more persistent fix is to put the _2 lines below, as they appear_ in your `eclipse.ini`:

```
--launcher.GTK_version
2

```

before the line:

```
--launcher.appendVmargs

```

The bug is filed with Ubuntu at [bug 1552764](https://bugs.launchpad.net/ubuntu/+source/java-common/+bug/1552764)

The post [Eclipse Not Working in 16.04 in Ubuntu?](https://stackallflow.com/ubuntu/eclipse-not-working-in-16-04-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
Benefits of choosing computer science field in Pakistan
Tags: career, pakistan, beginners, programming
Published: 2021-12-15 19:13:10


## The Dilemma After A - Levels

After passing intermediate or A levels exams, a horde of students applies to different universities that offer STEM education. Many candidates already have their plans and, they work towards their goals. On the other hand, many students remain unsure about what field they should select. If you have studied math in college, you are eligible to apply for CS in any institution in the country.
CS has many subfields like artificial intelligence, data science, and cybersecurity, etc. Computer science revolves around programming, web designing, development, networking, and engineering. Here are the benefits of choosing CS over other fields.

### Demand for Developers
The demand for programmers is ever-increasing in the whole world. As Pakistan is a developing country, it has a long way to go in terms of innovation and technology. Many industries like banking, business, and medical need developers for automation. The advent of online systems, AI systems, applications, and cloud storage has produced a need for more developers. Also, technology is always going to evolve in the future, so the need for computer scientists is never going to end.

### Freelancing Opportunities
One of the pros of choosing CS is that you can do freelancing. Most developers do not have to work 9 to 5 at a specific place. Freelancing does not only free you from a fixed time frame but also provides more opportunities. You can work for clients all over the world while being your boss.

### Numerous Subdisciplines
The other advantage of becoming a computer scientist is that it is not limited to a single career. In other words, you can choose a substream according to your interest. After studying various concepts of programming, you may opt for application or game development, ethical hacking, networking, web designing, and much more according to your interest. On the other hand, in all other fields, one is confined to a single career.

### High Paying Job
As mentioned above, due to increased demand, there is a high scope of CS in Pakistan. A career in CS promises you a high income. The more skillful and expert you become, the more money you make. 

## Conclusion
To conclude, it is true that there are a lot of advantages of choosing CS as your career, but you must follow your heart first. A degree in CS is not an easy one but, it will pay off. Think about your interests and talents before selecting a field.
How to build a secure crypto wallet
Tags: cryptography, cryptocurrency, appsec, datasecurity
Published: 2021-12-15 18:47:55

[Cossack Labs](https://www.cossacklabs.com/) security engineers are engaged in improving the security of several large public blockchain ecosystems and their hot non-custodial crypto wallets.

We gathered lots of observations about crypto wallets security: how they are different from the banking apps, what are the unique threats they face, and how novel crypto works with traditional crypto?

> From security engineers—to software developers, we’re here to share this practical security development knowledge with you. 

💡 From the defender’s point of view, the crypto wallet’s attack surface is enormous. **But from the attacker’s point of view, it’s not so difficult to combine 3-4 flaws, especially if the crypto wallet’s code is open-sourced.** So, let’s explore specific security flaws and their synergies.

Click on the picture below to get lots of examples and practical advice on the risks and threats of crypto wallets, design concerns, and implementation issues. ⇲

[<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64e3xqxwu2cteloeh2in.png">](https://www.cossacklabs.com/blog/crypto-wallets-security/)

Follow [@Cossack Labs] (https://twitter.com/cossacklabs) for more updates!😊🔐
<Head>
    <link rel="canonical" href="href="https://www.cossacklabs.com/blog/crypto-wallets-security/" />
</Head>
Facing Issue with npm start
Tags: react
Published: 2021-12-15 18:47:48

As I am using latest react project and its working fine at start but as I close vs code and open other project and then open this project and do npm start, it shows server running ate localhoast 3000 but in browser its showing connection refussed. Facing this issue with mt 2 latest projects. Any help....


You can checkout my project on https://github.com/sayyedfaisal06/issue_project
Is It Okay to Delete the ~/.Cache Folder in Ubuntu?
Tags: ubuntu
Published: 2021-12-19 13:51:00

---
title: Is It Okay to Delete the ~/.Cache Folder in Ubuntu?
published: true
date: 2021-12-15 18:15:00 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/is-it-okay-to-delete-the-cache-folder-in-ubuntu/
---

![](https://eadn-wc01-5196795.nxedge.io/cdn/wp-content/uploads/2021/12/is-it-okay-to-delete-the-cache-folder-in-ubuntu_11702-300x225.png)

<header>
<p><span style="font-size: 1.2em;">cache</span><span style="font-size: 1.2em;">home-directory</span></p>
</header>

When I use disk usage analyzer and scan my home folder, the `.cache` folder in my home directory always shows up with a decent bit of things in it.

Would it be okay for me to delete the contents of this folder or would it damage something?

#### Accepted Answer

To answer the question, IMO you can delete all of `.cache` with no long term detrimental effects.

If your `.cache` is growing large, it might be better to look at the contents and determine what application is making it large and re-configure a bad acting application (rather than simply deleting `.cache` when it grows too large).

Another directory that can take up a lot of space (and/or save an embarrassing bit of evidence) is the `.thumbs` directory. Many files in `.thumbs` seem to be duplicates.

To clean (just take care with the `-rf` flag and other directories ![😉](https://s.w.org/images/core/emoji/13.1.0/72x72/1f609.png)

```
rm -rf ~/.thumbs/*

```

When you are new to Ubuntu/Linux it is hard to know what you can and can not delete in your home directory. For the most part you can delete most anything in your home directory, programs or applications that require `.cache` (or other dot files such as `.local`) will re-create them.

Most of the time, at worst, you will lose custom configurations, but no real harm to the system.

I would not advise you start a habit of deleting things you do not understand in your home directory, back it up or use a test account. If in doubt, the safe thing would be to make a back up or move the file.

```
mv .cache .cache_backup

```

You can then restore from backup if needed.

Definitely do NOT start deleting things you do not understand outside of your home directory.

The post [Is It Okay to Delete the ~/.Cache Folder in Ubuntu?](https://stackallflow.com/ubuntu/is-it-okay-to-delete-the-cache-folder-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
SPO600 - Project Stage 3
Tags: opensource
Published: 2021-12-15 18:12:42

## Introduction

We already discovered that `ffmpeg` is using Neon architecture extension in SIMD code.

To continue with the previou [blog post](https://dev.to/tcvan0707/spo600-project-stage-2-4cl6), this blog will be about the recommendations how `ffmpeg` should be extended to support **SVE2** (Scalable Vector Extensions v2)

## SVE2 (Scalable Vector Extensions v2)

SVE2 is a superset of **SVE** and **Neon**. In terms of data-level parallelism, SVE2 allows for more function domains. SVE2 inherits SVE's concepts, vector registers, and operation principles, and developers can choose to use hardware with a maximum of 2048 bits.

Some advantages that SVE2 has compared to the traditional SIMD are:
- The SVE2 program can be built once and run on a variety of hardware with different vector lengths
- SVE2 allows for more vectorization options
- SVE2 expands the instruction set, allowing for more application possibilities

## Recommendation

Since `ffmpeg` is mainly handling heavy works such as decode, encode, transcode, so using SVE2 will enable it to have more options, more flexibility, and so on.

I found that `libswscale` library - implements color conversions and scaling routines can be improved with SVE2 instead of traditional SIMD instruction. The reason is because the scaling process will take a quite of time, SVE2 would allow the tool to boost up this process.

Neon usage in `ffmpeg` can be changed to take the advantages of SVE2 because it allows vector code to adapt to different vector lengths during execution time. SVE2 has 32 scalable vector registers `Z0-Z31`, and it can be implemented from 128 bits up to 2045 bits with 128 increment.

`ffmpeg` can save more time when building and compiling program if the SVE2 is used, as well as user can get better experience while using the tool.

## Conclusion

In conclusion, we can consider to take the advantages of SVE2 functionalities for `ffmpeg` to maximize the flexibility of the tool. As well as increasing the ability to use variable-length instruction sets up to 2048 bits.
Vue.js Tutorial
Tags: webdev, beginners, javascript, vue
Published: 2021-12-15 17:52:02

Vue.js tutorial provides basic and advanced concepts of Vue.js. Our Vue.js Tutorial is designed for beginners and professionals both.

✅**Full Vue Js Course at** [VUE JS COURSE](https://bhylu.com/vue-js/vue-js-introduction/)

Vue.js is an open-source progressive JavaScript framework used to develop interactive web user interfaces and single-page applications. Vue.js is mainly focused on the view part of the application that is also called front end development. Vue.js is going popular day by day because it is very easy to integrate with other projects and libraries. It is very simple to install and use. Even beginners can understand it easily and start building their own user interfaces.

In this tutorial, you will learn what is Vue.js, how to install Vue.js, Vue.js Instances, Components, Properties, Bindings, Events, Rendering, Directives, Routing, Mixins, Render functions etc.

#What is Vue.js?

Vue.js is an open-source progressive JavaScript framework used to develop interactive web user interfaces and single-page applications (SPAs). Vue.js is commonly referred to as Vue and pronounced as "view.js" or "view."

What is a Single Page Application (SPA)?
A single page application or SPA is a web application or a website that provides users a very fluid, reactive, and fast experience similar to a desktop application. A single page application contains a menu, buttons, and blocks on a single page. When a user clicks on any of them, it dynamically rewrites the current page rather than loading entire new pages from a server. That's the reason behind its reactive fast speed.

Vue is basically developed for frontend development, so it has to deal with a lot of HTML, JavaScript, and CSS files. Vue.js facilitates users to extend HTML with HTML attributes called directives. Vue.js provides built-in directives and a lot of user-defined directives to enhance functionality to HTML applications.

✅**Full Vue Js Course at **[VUE JS COURSE](https://bhylu.com/vue-js/vue-js-introduction/)

#History of Vue.js
Vue.js was created by Evan You, who was then working for Google using AngularJS in their projects. He extracted some parts of AngularJS and built something lightweight JavaScript framework later released as Vue.js.

The first version of Vue.js was released in February 2014. It is now maintained by him and the rest of the active core team members coming from various companies such as Netlify and Netguru.
Vue.js is going popular day by day because it is very easy to integrate with other projects and libraries. It is very simple to install and use. Even beginners can understand it easily and start building their own user interfaces.

✅Full Vue Js Course at [VUE JS COURSE](https://bhylu.com/vue-js/vue-js-introduction/)
What’s the Difference Between “Service” and “/Etc/init.D/” in Ubuntu?
Tags: ubuntu
Published: 2021-12-19 13:50:50

---
title: What’s the Difference Between “Service” and “/Etc/init.D/” in Ubuntu?
published: true
date: 2021-12-15 15:15:00 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/whats-the-difference-between-service-and-etc-init-d-in-ubuntu/
---

![](https://eadn-wc01-5196795.nxedge.io/cdn/wp-content/uploads/2021/12/whats-the-difference-between-service-and-etc-init-d-in-ubuntu_11684-300x225.png)

<header>
<p><span style="font-size: 1.2em;">services</span><span style="font-size: 1.2em;">upstart</span></p>
</header>

I’ve been managing server installations both on and off Ubuntu flavor for some time – I’ve become quite adjusted to `/etc/init.d/` for restarting servcies. Now I get this message:

```
root@tatooine:~# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 14048

```

This seems to have been brought about in the latest LTS of Ubuntu – why? What’s so bad about `/etc/init.d/` and what/is there a difference between `service` and `/etc/init.d/`?

#### Accepted Answer

`/etc/init.d` scripts are the old way of doing things. They come from the System V standard. However, those scripts are fired only in a particular sequence, so no real dependencies can be established.

Therefore, upstart has been developed with the intent to substitute all the `/etc/init.d` scripts with upstart scripts (in `/etc/init`).

`service` allows the smooth transition from `/etc/init.d` scripts to upstart scripts. In the future, when more and more scripts are transferred to upstart, service will still work because it finds both possibilities.

- [How to enable or disable services?](https://askubuntu.com/questions/19320/whats-the-recommended-way-to-enable-disable-services)

The post [What’s the Difference Between “Service” and “/Etc/init.D/” in Ubuntu?](https://stackallflow.com/ubuntu/whats-the-difference-between-service-and-etc-init-d-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
Living in the Shell #16; curl (HTTP/S Client) (Part 1)
Tags: productivity, linux, bash, devops
Published: 2021-12-15 17:43:47

## `curl` 🌐

Makes requests in various protocols, including (but not limited to) HTTP/HTTPS/FTP/FTPS.

## Make a simple `GET` request

```sh
curl https://google.com
```

> ```text
> <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
> <TITLE>301 Moved</TITLE></HEAD><BODY>
> <H1>301 Moved</H1>
> The document has moved
> <A HREF="https://www.google.com/">here</A>.
> </BODY></HTML>
> ```

## Simple `GET` request with following redirects `-L`

```sh
curl -L https://google.com
```

## Write response to a file `-o`

```sh
curl -L https://google.com -o content.html
```

## Include response headers `-i`

```sh
curl -i -L https://google.com
```

> ```text
> HTTP/2 301 
> location: https://www.google.com/
> content-type: text/html; charset=UTF-8
> date: Wed, 15 Dec 2021 17:45:16 GMT
> expires: Fri, 14 Jan 2022 17:45:16 GMT
> cache-control: public, max-age=2592000
> server: gws
> content-length: 220
> x-xss-protection: 0
> x-frame-options: SAMEORIGIN
> ...
> ```

## Request via a HTTP proxy server `-x`

```sh
curl -L https://google.com -x proxy-server:port
```

## Request via a SOCKS proxy server `--socks`

```sh
curl -L https://google.com --socks proxy-server:port
```
Colorful Rain with JS
Tags: css, webdev, javascript, tutorial
Published: 2021-12-15 17:43:14



In this article, we are going to build a container that generates rain by using JS. And it is a colorful rain with random colors. You can play with colors however you want. So first, let's see what are we building.

### Preview

![preview](https://i.imgur.com/pt4KC8x.gif)

Now let's look at the code, how we can make that work.

### HTML
```html
<div class="rain-container"></div>
```

### CSS

```css
* {
  margin: 0;
  padding: 0;
}

.rain-container {
  position: relative;
  background: #000;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

i {
  position: absolute;
  height: 120px;
  border-radius: 0 0 999px 999px;
  animation: animate 5s linear infinite;
}

@keyframes animate {
  0% {
    transform: translateY(-120px);
  }
  100% {
    transform: translateY(calc(100vh + 120px));
  }
}
```

### Javascript

```js
const rainContainer = document.querySelector(".rain-container");

// background Colors for the raindrop
const background = [
  "linear-gradient(transparent, aqua)",
  "linear-gradient(transparent, red)",
  "linear-gradient(transparent, limegreen)",
  "linear-gradient(transparent, white)",
  "linear-gradient(transparent, yellow)"
];

const amount = 100; // amount of raindops
let i = 0;

// Looping and creating the raindrop then adding to the rainContainer
while (i < amount) {
  //  Creating and Element
  const drop = document.createElement("i");

  //   CSS Properties for raindrop
  const raindropProperties = {
    width: Math.random() * 5 + "px",
    positionX: Math.floor(Math.random() * window.innerWidth) + "px",
    delay: Math.random() * -20 + "s",
    duration: Math.random() * 5 + "s",
    bg: background[Math.floor(Math.random() * background.length)],
    opacity: Math.random() + 0.2
  };

  //   Setting Styles for raindrop
  drop.style.width = raindropProperties.width;
  drop.style.left = raindropProperties.positionX;
  drop.style.animationDelay = raindropProperties.delay;
  drop.style.animationDuration = raindropProperties.duration;
  drop.style.background = raindropProperties.bg;
  drop.style.opacity = raindropProperties.opacity;

  //   Appending the raindrop in the raindrop container
  rainContainer.appendChild(drop);
  i++;
}
```


{% codepen  https://codepen.io/j471n/pen/GRMNeZG %}


[![codepen](https://svgshare.com/i/cqh.svg)](https://codepen.io/j471n/pen/GRMNeZG)


### Wrapping Up
This is it. You can simply do that with this and you can also take this to the next level. If you enjoyed this article then don't forget to press ❤️. If you have any queries or suggestions don't hesitate to drop them. See you. 

> You can extend your support by buying me a Coffee.😊👇
[![buymecoffee](https://imgur.com/2QWo3cm.png)](https://www.buymeacoffee.com/j471n)


#### You might be interested in -

- [Creative Hover Menu with CSS](https://dev.to/j471n/creative-hover-menu-with-css-513c)
- [Typing Effect by using CSS](https://dev.to/j471n/typing-effect-by-using-css-50p)
- [Curved Timeline in CSS](https://dev.to/j471n/curved-css-timeline-5ab3)
The most important use Websites & Tools & communities for Web Developers
Tags: tutorial, webdev, programming, beginners
Published: 2021-12-15 17:34:28

####Hosting & Deployment
- Netlify 
- Heroku
- Google Cloud Platform
- Amazon Web Services
- Microsoft Azure
- Oracle Cloud
- IBM Cloud

####Royalty-Free Images & Video
- Unsplash
- Pexels
- Coverr
- Undraw
- Storyset

####Icons & Fonts
- Google Fonts
- Flaticon
- Font Awesome
- Animated icons8.com

####Learning
- Freecodecamp
- Theodinproject
- Mem.dev
- smashingmagazine

####Mockup Tools
- Figma
- Zeplin

####Freelancing
- Upwork
- freelancer
- Fiverr
- PeoplePerHour

####Project Design Ideas
- Awwwards
- Dribbble

####Exercises & Algorithms
- Leetcode
- Exercism
- Codewars

####General Tools
- Emailjs
- Caniuse
- Image compressor
- Css-tricks
- free-for.dev
- mytemplate.xyz
- getavataaars.com
- devdocs.io
- drawsql.app
- mockaroo
- jsonplaceholder.typicode

####Communities
- dev.to
- indiehackers
- hackernoon
- quora
- codeproject

All the best for you :)
Why I won't share more video tips on dev.to
Published: 2021-12-15 17:13:01

As you may have noticed, lately I was sharing short videos with JavaScript tips.

Unfortunately, I have received a public comment under my last video. Long story short, my videos are not welcomed here on dev.to as posts.

There is currently a beta section of videos. But uploading videos there does not work, at least for me.

The proposal from the moderator was to add transcript and code snippets to posts. That does not suit me, because I spend enough of personal time to share knowledge.

As you may know, it is my probono work that is not compensated and I really do not expect any compensation, because I have always liked to do it, and am rewarded by learning myself as well.

Since that said, while I understand that dev.to wants users to put as much value into dev.to as possible, for me, the cost of investing more into dev.to, is above what can invest right now.

Therefore sadly, and I won't be sharing more of my videos here. If you like them, please check out my other social media accounts, for example Medium or youtube, where I can freely share my knowledge.

Maybe I will share something here in the future. But currently I am focused on short videos because it is a great way to share some valuable knowledge without wasting people's time.

Hopefully someday dev.to will fix videos, than maybe I will contribute them here as well.