teleren/devto huggingface dataset:
CLRS - Foundations - 2
Tags: algorithms, programming
Published: 2022-10-20 16:38:07

Page _11 - 22_

- Importance of efficient algorithms - assuming that the algorithm to solve the problem takes f(n) microseconds , have a look at the table . Having an algorithms of `O(n!)` can only solve for maximum input size of `17` if  given time of ***1 century*** . _Just imagine !_

Have a look at the table and you will appreciate the importance of good algorithms. 

> considering `f(n)` will take `1 microsecond` to execute

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


**Insertion Sort**
-  Insertion sort works the way many people sort a hand of
playing cards. We start with an empty left hand and the cards face down on the
table. We then remove one card at a time from the table and insert it into the
correct position in the left hand. To find the correct position for a card, we compare
it with each of the cards already in the hand, from right to left, as illustrated in
 At all times, the cards held in the left hand are sorted, and these cards
were originally the top cards of the pile on the table

Here is the example 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi4svbnzmri5e564dgxl.png)
Here is the code for insertion sort , from what I have understood `insertion sort` is an inplace algorithm which means it ***don't need extra space*** to sort the array. 

```cpp
// C program for insertion sort
#include <math.h>
#include <stdio.h>
/* Function to sort an array
using insertion sort*/
void insertionSort(int arr[], int n)   // n is the size of array
{
	int i, key, j;
	for (i = 1; i < n; i++)
	{
		key = arr[i];
		j = i - 1;

		/* Move elements of arr[0..i-1],
		that are greater than key,
		to one position ahead of
		their current position */
		while (j >= 0 && arr[j] > key)
		{
			arr[j + 1] = arr[j];
			j = j - 1;
		}
		arr[j + 1] = key;
	}
}
```

#### Loop variant and correctness of an algorithm

**Initialization**: It is true prior to the first iteration of the loop.

**Maintenance**: If it is true before an iteration of the loop, it remains true before the next iteration.

**Termination**: When the loop terminates, the invariant gives us a useful property that helps show that the algorithm is correct.


Here is one interesting question I have found in the exercise 

**Consider the problem of adding two n-bit binary integers, stored in two n-element arrays A and B. The sum of the two integers should be stored in binary form in an array of size (n+1) C**

`Think about it before moving forward`

```py
def sumBin(a,b,n):
    c=[None]*(n+1)
    carry=0
    for i in range(n-1,-1,-1):
    
        c[i+1] = (a[i]+b[i]+carry) %2
        if((a[i]+b[i]+carry) >=2):
            carry = 1
        else:
            carry = 0
        
    c[0] =carry
    
    return c


a = [1,1,0,1,1]

b=[1,1,1,1,0]

print(sumBin(a,b,len(a)));
```

The only hard point for me is to get bit value from sum of two elements of the arrays, `(a[i]+b[i]+carry) %2`. 

Bye , Gonna eat dinner .
[pwnable.kr] fd writeup
Tags: pwnable, security
Published: 2022-10-20 16:19:15

```
ls -al
total 40
drwxr-x---   5 root   fd   4096 Oct 26  2016 .
drwxr-xr-x 116 root   root 4096 Nov 11  2021 ..
d---------   2 root   root 4096 Jun 12  2014 .bash_history
-r-sr-x---   1 fd_pwn fd   7322 Jun 11  2014 fd
-rw-r--r--   1 root   root  418 Jun 11  2014 fd.c
-r--r-----   1 fd_pwn root   50 Jun 11  2014 flag
-rw-------   1 root   root  128 Oct 26  2016 .gdb_history
dr-xr-xr-x   2 root   root 4096 Dec 19  2016 .irssi
drwxr-xr-x   2 root   root 4096 Oct 23  2016 .pwntools-cache
```
The file we want to read is a `flag` file, and only the `fd_pwn` owner or the root user can read the file.
BUT we are `fd` now.
So we should be the fd_pwn to gain proper permission.
`fd` has SetUID to `fd_pwn`. We can use it to gain access. 

Look the source file up:
```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char buf[32];
int main(int argc, char* argv[], char* envp[]){
	if(argc<2){
		printf("pass argv[1] a number\n");
		return 0;
	}
	int fd = atoi( argv[1] ) - 0x1234;
	int len = 0;
	len = read(fd, buf, 32);
	if(!strcmp("LETMEWIN\n", buf)){
		printf("good job :)\n");
		system("/bin/cat flag");
		exit(0);
	}
	printf("learn about Linux file IO\n");
	return 0;

}
```
We have to put an argument value, and if we put `0x1234` in the argument value, fd = 0 so that we can use standard input (keyboard) to input. After that we can set `buf` to `LETMEWIN` via standard input.
0x1234 is `4660` in decimal, so run following command to get the desired result:
```
./fd 4660
LETMEWIN
good job :)
_FLAG_
```
The deeptech startup Luos is the winner of the regional call for applications operated by La French Tech Bordeaux.
Tags: opensource, microservices, startup, luos
Published: 2022-10-20 15:53:27

💬 “The deeptech startup Luos is the winner of the regional call for applications operated by La French Tech Bordeaux.” - French press release on French Tech

▶️ https://www.frenchtechbordeaux.com/luos-representera-la-nouvelle-aquitaine-lors-de-french-tech-rise/

The Luos team will defend the region's colors in December in Paris during a half-day meeting with investors, organized by the French Tech National Mission.

Thanks to Mikael Lozano for this article and to all the French Tech team!

![Luos will represent New Aquitaine at French Tech Rise](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rgy019lzx4inrw1y7vld.jpg)
RN AllSpark Beta launching on 11/11
Tags: startup, dweb, reactnative
Published: 2022-10-20 15:53:18

Hello Everyone, 
At AllSpark, we are on a mission to bring about a local-first world. Our goal is to create a frictionless, user-centric and privacy first consumer world by moving authentication, storage and personalization to the edge. 

AllSpark is a smart content aggregator like Feedly but also adds integrations to pull content from products. The beta, built on react-native, comes pre-built with HN and Reddit streams and will continue to add content streams. Read more about our launch from: [Announcement blog](https://allspark.substack.com/p/allspark-beta-announcement?r=18j1jl&utm_campaign=post&utm_medium=web) 

Explore the demo & join the waitlist at [GetAllSpark.co](https://www.getallspark.co/)

{% embed https://youtu.be/SP9aihPNnAw %}

By building AllSpark data store and ml engine at the edge (in-device) we aim to to deliver local first auth (magic.link crypto login), data storage and machine learning. 

If you have researched local-first mobile DB's, drop a line in the comments. We are currently comparing Crypto Pouch, PouchDB, WatermelonDB and RxDs. 

Best,
@yonz
NextSketch 2: Rewritten Diagram Engine!
Tags: news, devjournal, tooling, architecture
Published: 2022-10-20 15:35:16

Hello!

We thought today we’d give a bit of an update on NextSketch 2 development. Right now, the rewrite of the core diagram engine has been mostly completed and we’re now compiling a list of new features that we think the NextSketch community will love.

The rewrite makes it much easier for us to work on the NextSketch code base. In NextSketch 1, we used a lot of state-tracking which as you can imagine, got out of hand fast. 

The new features will include simple things like actual zooming support (which is already completed!) to more inspections.

There’s also 1 really awesome feature that we’re _considering_, (but we’ll keep it a secret until we’re sure  😁). If we can squeeze this in, it’ll really change  the way we use NextSketch.

For those of you wondering why there’s no cover image, it’s because, right now, there’s not a whole lot new to see!

Anyway, we hope you’re excited for NextSketch 2 as much as we are! 

NextSketch Team
304 Not Modified 2
Published: 2022-10-20 15:33:44

In my last post i was trying to figure out how to fetch data from DEV.TO to my NextJS/Vercel, portfolio, but after deployed, the new posts was not been fetched, I changed the way of fetching from useEffect hook to useSWR, and this is how it's look now:


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

Link to the aplication: https://arthur-candido.vercel.app/
[PWN.01] Memory Layout
Tags: pwnable, security
Published: 2022-10-20 15:31:19


![Memory Layout Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocmzzqvs2k46r0oxmjbl.png)
## What is Memory Layout 
If an attacker can maliciously manipulate memory, the manipulated memory value can cause the CPU to misbehave.
We call it **`Memory Corruption`**
Memory in Linux System is divided into 5 major Segments.
### 1. Code segment(Text Segment)
where Executable machine code is located in.
_Code segment_ has `READ` and `EXECUTE` permission.

### 2. Data segment
Global variables and global constants whose values ​​are set at compile time are located.
_Data segment_ has `READ` permissions.
And This segment is divided into Two parts.

- data segment : writable
- rodata(read-only Data) segment : No writable

### 3. BSS segment (Block Started by Symbol)
Global variables whose values ​​are not set at compile time are located.
The variables are set to Zero all 

### 4. Heap segment(Lower → High)
Segment to store dynamically allocated data.
This segment has `READ` and `WRITE` permissions.

### 5. Stack segment(High → Lower)
Temporary variables such as function arguments or Local variables are stored here during execution.
Stack segment has `READ` and `WRITE` permissions.
This segment has `Stack Frame` which is created when a function is called and freed when the function returns.
Learning PromQL by Exercising
Tags: observability, beginners, discuss, prometheus
Published: 2022-10-20 15:30:55

---
title: Learning PromQL by Exercising 
published: true 
description: learning promql by exercising
tags: observability, beginners,discussion,prometheus
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-10-20 15:28 +0000
---

Hi, I just want to ask is there any web / resources to learn about promQL by use cases / tasks?

e.g. "create a query to fetch the max requests number from the defined timerange"

thank you in advance
OSINT made easy. Find emails for anyone.
Tags: go, tutorial, programming, beginners
Published: 2022-10-20 15:23:26

Ever wonder how to contact individuals if all you have is their social media link (like LinkedIn, Facebook, etc)? 

I was recently tasked with doing just that. Specifically, I had to take a spreadsheet and add email addresses or phone numbers to it for each row. The spreadsheets looked like this,


```csv
name,linkedin_url
Steve Wozniak,linkedin.com/in/wozniaksteve
Bill Gates,linkedin.com/in/williamhgates
...
```

I wasn't sure where to begin, but after some Google-fu I found an API makes this trivial. In particular, the [people enrichment API for Nymeria](https://www.nymeria.io/developers). What's better, they have a [Go SDK](https://git.nymeria.io/nymeria.go/about/)!

I put together a quick program to process a spreadsheet from the command line. 

Setting up a go module is easy enough, 

```bash
$ mkdir linkedin-enrichment
$ cd linkedin-enrichment
$ go mod init linkedin
$ go get git.nymeria.io/nymeria.go@latest
$ touch main.go
```

The code itself was simple. I'll let the code speak for itself (main.go below).

```go
package main

import (
  "encoding/csv"
  "fmt"
  "log"
  "os"

  "git.nymeria.io/nymeria.go"
)

func rows(filePath string) [][]string {
  f, err := os.Open(filePath)

  if err != nil {
    log.Fatal("Unable to read input file "+filePath, err)
  }

  defer f.Close()

  csvReader := csv.NewReader(f)
  records, err := csvReader.ReadAll()

  if err != nil {
     log.Fatal("Unable to parse file as CSV for "+filePath, err)
  }

  return records
}

func main() {
  nymeria.SetAuth("YOUR API KEY GOES HERE")

  rs := rows("YOUR FILE NAME HERE")

  // Note, [1:] to skip the header row.
  for _, row := range rs[1:] {
     params := []nymeria.EnrichParams{
        {
          // In my case, the URL was in the second column.
          URL: row[1],
        },
     }

    if es, err := nymeria.Enrich(params...); err == nil {
      for _, enrichment := range es {
        if enrichment.Status == "success" {
          if len(enrichment.Data.Emails) != 0 {
            fmt.Printf("%s,%s\n", row[1], enrichment.Data.Emails[0].Address)
          }
        }
      }  
    }
  }
}
```

Running and getting the output is simple,

```bash
➜  linkedin-enrichment: go run main.go
linkedin.com/in/wozniaksteve,steve@woz.org
linkedin.com/in/williamhgates,bill.gates@gatesfoundation.org
```

Has anyone else been tasked with similar problems? How did you solve them?
In One Minute : Amazon DynamoDB
Tags: aws, beginners, programming, oneminute
Published: 2022-10-20 15:23:04

Amazon DynamoDB is a fully managed proprietary NoSQL database service that supports key–value and document data structures and is offered by Amazon.com as part of the Amazon Web Services portfolio.

{% embed https://youtu.be/5lmaoE0M1-I %}

Dynamo had a multi-leader design requiring the client to resolve version conflicts and DynamoDB uses synchronous replication across multiple data centers for high durability and availability. 

DynamoDB was announced by Amazon CTO Werner Vogels on January 18, 2012, and is presented as an evolution of Amazon SimpleDB.

DynamoDB differs from other Amazon services by allowing developers to purchase a service based on throughput, rather than storage. If Auto Scaling is enabled, then the database will scale automatically.

To prevent data loss, DynamoDB features a two-tier backup system of replication and long-term storage.
Each partition features three nodes, each of which contains a copy of that partition's data.
Each node also contains two data structures: a B tree used to locate items, and a replication log that notes all changes made to the node.
DynamoDB periodically takes snapshots of these two data structures and stores them for a month in S3 so that engineers can perform point-in-time restores of their databases.


Official website : http://aws.amazon.com/dynamodb/
How to call static and non-static method of class in JavaScript
Published: 2022-10-20 15:16:40

Blow those pictures show how to require a class from one script to another script and call a **static and non-static method** of class in the JavaScript programming language.
The first pic is main.js and the second pic is script.js

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocvtw4y631ivnlor1vwt.png)
learning coding online
Tags: beginners, learning, help, codenewbie
Published: 2022-10-20 14:36:15

hi!
i recently started studying coding through _freeCodeCamp_.
i went through the HTML and CSS courses and im halfway through the Javascript one.

however, i noticed _courses might be very different from each other_ and so i find some harder to follow compared to others just due to the way they are presented.

so, i was wondering if there are other free sources/courses/camps out there you would reccomend as a way to complement fCC?

im about to try [Exercism](https://exercism.org/) and [The Odin Project](https://www.theodinproject.com/), but open to any other suggestion, especially if you have already had experience with them.
React Use hook
Tags: javascript, react, webdev, programming
Published: 2022-10-20 14:14:08

**New #React use hook**

**One of the coolest things coming to React in a long time!

React has a new RFC (request for comments) with a proposal for a new hook that will simplify fetching data and make it safer.

It will allow fetching more easily and also fetching conditionally.
It is similar to await in the sense that it unwraps the value of a promise.

React-query and SWR will still be relevant since they add a lot of features like caching. But they will probably incorporate the new API under the hood**



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twv5l88wnwm6l7djc6vh.jpg)
The modern age terminal
Tags: productivity, beginners, programming, typescript
Published: 2022-10-20 14:01:17

**Hey there everyone** 👋!

Surely we all use terminals in our life? (developers only). Yes, so people using terminal, be amazed of something new.

## 😮 Difference between a Terminal and Shell

- The **Shell** is the program that actually processes commands and outputs results whereas a **Terminal** is a wrapper program that runs a shell and allows us to enter commands.

- 🧑‍💻 For example, **_Command Prompt_** is an **Terminal** and **_Powershell_** is a **Shell**.

So basically, A terminal is a input-output program that runs the commands originally in a shell.

## 🦄 Introduction to Tabby

**_[Tabby](https://tabby.sh/)_** is a next-gen, modern terminal for developers. It might not be as light-weight as _[cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd)_ but it is quite productive.

**_Tabby_** was released publicly as a open-source Terminal on _[github](https://github.com/Eugeny/tabby)_ on December 23, 2016! The initial version were pretty good comparable to that time. Today, it is one of the most leading cool-UI and productive Terminals.

🧡 **Tabby** is a highly configurable terminal emulator, SSH and serial client for _Windows_, _macOS_ and _Linux_.

## 🪶 Terminal Features

- Supports various extensions
- Progress detection
- Tabs can be formed on any side of the window
- Notifications are sent when a certain progress is completed
- Warnings on multiline paste
- Supports customs shell profiles
- Supports configurable shortcuts and multi-chord shortcuts
- Integrated SSH client with a connection manager

## 🪸 Previews

![Preview 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0c3qvm0pyp0wdrr4e8kj.png)

![Preview 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqoik63bjyw7h0wwz7kn.png)


![Preview 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvi1c8r2ececrpapp4lw.png)


- The themes can be customized according to your comfort zone with simple changes in _css_ files.

## 🐲 Conclusion

Isn't all this just great? It's quite exciting to know we can always keep coding inside our comfort zone because of all the open-source developers out there in the world.

## 🙍 Connect with me

- **Mail** - `akashpattnaik.github@gamil.com`
- **Github** - `BLUE-DEVIL1134`
- **Twitter** - `akash_am1`
How to Delete Duplicate Numbers in Golang
Tags: go
Published: 2022-10-20 14:01:01

```
func Set(arr []int) []int {
	for i := 0; i < len(arr); i++ {
		for j := 0; j < len(arr); j++ {
			if arr[i] == arr[j] && i != j {
				arr = append(arr[:j],arr[j+1:]...)
			}
		}
	}
	return arr
}
```
HTTP 
Published: 2022-10-20 11:17:12


HTTP, in full HyperText Transfer Protocol, standard application-level protocol used for exchanging files on the World Wide Web. HTTP runs on top of the TCP/IP protocol and (later) on the QUIC protocol. Web browsers are HTTP clients that send file requests to Web servers, which in turn handle the requests via an HTTP service. HTTP was originally proposed in 1989 by Tim Berners-Lee, who was a coauthor of the 1.0 specification. HTTP/1.0 (released in 1996) was "stateless": each new request from a client established a new connection instead of handling all similar requests through the same connection between a specific client and server. HTTP/1.1 (released in 1997) includes persistent connections, decompression of HTML files by client browsers, and multiple domain names sharing the same IP address. HTTP/2 (released in 2015) was designed to solve problems with slow page loading and was a binary protocol in which binary values were used instead of plaintext as in previous versions. HTTP/3 relies on the faster QUIC protocol instead of TCP and, as of early 2022, was not yet released in final form but was supported by most browsers. In the 2010s many websites began using HTTPS (Secure HTTP), developed in 1994 by Netscape Communications Corporation and in which the SSL (Secure Sockets Layer) protocol was added to HTTP to provide a layer of encryption between browsers and servers.



According To Google: The Hypertext Transfer Protocol (HTTP) is the foundation of the World Wide Web, and is used to load web pages using hypertext links. HTTP is an application layer protocol designed to transfer information between networked devices and runs on top of other layers of the network protocol stack.
Triangle with loop
Tags: javascript, beginners, tutorial, programming
Published: 2022-10-20 13:54:23

## Source Code

```js
let myString = "#"
for(let i =0; i <= 7; i++){
  console.log(myString)
  myString += "#"
}
```
## Explained

As we already know, the for is a way to be able to execute the same code until the condition is fulfilled.

So, in this case, the logic I concluded is as follows:

Execute a string (in my case I chose #) X times, and for each time it is executed, an extra print will be added.

We start by creating a variable containing the string.
The `for` said something like this: start with `index = 0`, as long as the index is less than or equal to 7, add 1 to the index.
This will make us loop 7 times until our variable gets the value greater than 7.
Let see
```js
let myString = "#"
for(let i =0; i <= 7; i++){
  console.log(myString)
}
```
**Terminal show**
![input](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su1ehxaen1rtcc22z6o9.png)

Now we need to add another string for each `console.log` line. To do this we just need to do a sum of strings in the loop:
```
myString += "#"
```

![Result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gtqyu0d48xczh726r92.png)


Nice!
we already have our triangle with loop

If you have other way to do this triangle, share with us!!
which gateway?? ⛩
Tags: kubernetes, istio, opensource
Published: 2022-10-20 13:52:22

If you search up the term gateway with kubernetes, it's likely you will see the (new-ish) Gateway API, which was released as beta July 2022. This short article is a run down of what the "gateway" is in kubernetes land!

Naming is hard. And throw in jargon on top of it in an ever changing ecosystem makes it even tougher.

The concept of a gateway is to allow for traffic from outside your cluster to hit your services. 

A 'gateway' that people refer to is the Ingress Gateways. For example, [Istio](istio.io) has a [Gateway resource](https://istio.io/latest/docs/tasks/traffic-management/ingress/ingress-control/) (aka a "gateway"). This Gateway resource _configures_ a Gateway Deployment (also called a "gateway" as well). Usually, you will have decipher which gateway is being referenced in. So that's already 2 mentions of the gateway in jargon form.

Next up, we have the new [Gateway API](gateway-api.sig.k8s.io). This is a standardized API designed to be the superset of the Ingress API. It has been created out of inspiration from Istio's Gateway and other gateway 
The Gateway API's resources is comprised of "GatewayClass", "Gateway" (referred to as 'gateway'), and routes, such as "HTTPRoute", "TLSRoute", etc. 

That's a wrap on different gateways you might face in the k8's land!