teleren/devto huggingface dataset:
Shortest Common Super-sequence Leetcode (Same as Lcs string)
Tags: java, dp, algorithms
Published: 2022-08-13 14:22:34

Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return any of them.

A string s is a subsequence of string t if deleting some number of characters from t (possibly 0) results in the string s.

 

**Example 1**:
```
Input: str1 = "abac", str2 = "cab"
Output: "cabac"
Explanation: 
str1 = "abac" is a subsequence of "cabac" because we can delete the first "c".
str2 = "cab" is a subsequence of "cabac" because we can delete the last "ac".
The answer provided is the shortest such string that satisfies these properties.
```

**Solution**:
Time complexity is same as that of longest common subsequence
i.e. O(m*n) , space complexity is O(m*n) for using dp array.


```java
class Solution {
    String str = "";
    public String shortestCommonSupersequence(String str1, String str2) {
        int dp[][] = new int[str1.length()+1][str2.length()+1];
        
        for(int i=0;i<=str1.length();i++){
            dp[i][0] =0;
        }
        for( int i =0;i<=str2.length();i++){
            dp[0][i] = 0;
        }
        
        for( int i =1;i<=str1.length();i++){
            for(int j =1;j<=str2.length();j++){
                if(str1.charAt(i-1)==str2.charAt(j-1)){
                    dp[i][j] = 1 + dp[i-1][j-1];
                }
                else dp[i][j] = Integer.max(dp[i][j-1],dp[i-1][j]);
            }
        }
        int p = str1.length(), q = str2.length();
        
        while(p>0 && q>0){
            if(str1.charAt(p-1) == str2.charAt(q-1)){
                str = str1.charAt(p-1)+ str;
                p--;
                q--;
                
            }
            else if(dp[p][q-1] > dp[p-1][q]){
                str = str2.charAt(q-1) + str;
                q--;
            }
            else {
                str = str1.charAt(p-1) + str;
                p--;
            }
        }
        
        while(p>0){
            str  = str1.charAt(p-1)+ str;
            p--;
        }
        while(q>0){
            str = str2.charAt(q-1) +  str;
            q--;
        }
        return str;
    }
}
```
What is Active Record
Tags: ruby
Published: 2022-08-13 14:06:00

To non-programmers this might sound like a recording label. However, in computer programming what is Active record? active record is a ruby gem that handles the database stuff without worrying to much about writing SQL.

**Object/Relational Mapping (ORM)**
ORM stands for Object-Relational-Mapping. Essentially, Active Record takes data stored in a relational database, which needs to be modified or retrieved by writing SQL statements. Developers can interact with that data using Ruby object.

**Example without Active Record**
```
class User
  attr_accessor :name

  @@all = []

  def initialize(name)
      @name = name
      @@all << self
  end

  def self.all
      @@all
  end
```
**Example with Active Record**

```
class User < ActiveRecord::Base
 
end
```
Forget SQL, All My Homies Use LINQ
Tags: dotnet, sql, linq, csharp
Published: 2022-08-13 14:04:00

> Learning SQL is a pain. Using SQL is a pain. Be better. Choose .NET. Choose LINQPad.

{% embed https://www.youtube.com/embed/q0KhPdDE7Ek %}

Early last year I was building out a [database site for a game](https://impact.moe/) and decided it would be a good opportunity to start playing with [Entity Framework](https://docs.microsoft.com/en-us/ef/core/) (or EF Core, as it's now called) that I'd been meaning to get into for awhile, but never got to using. I already had my database setup and some data inserted but I figured it wasn't a big deal to just re-write it with EF Core and generate a new database.

But after some digging, I discovered that EF Core actually has functionality specifically for the case of reverse engineering an existing SQL schema and generating the associated .NET models: [scaffolding](https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli)

## Scaffolding, Yay

![Generating models with EF Core](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4aal1c7belzlgnhwgix.gif)

```bash
dotnet ef dbcontext scaffold "server=127.0.0.1;uid=root;pwd=password;database=classicmodels" Pomelo.EntityFrameworkCore.MySql
```

You just provide the database connection string and the SQL provider package (SqlServer, MySql, etc.), and EF Core will handle the rest. Note that you'll also need the global dotnet-ef package for this to work, which you can install with the following:

```bash
dotnet tool install --global dotnet-ef
```

This was brilliant, so I generated some models and I was immediately able to run LINQ queries on my database, no effort required.

But then I realized, this would be extraordinarily useful as a dedicated app: to be able to connect to a database and start manipulating it directly within your app with LINQ, rather than having to use the syntactically unappealing and generally displeasing SQL. Okay, it's not that bad, but I've always disliked the structure and semantics.

So I got to work and started building a prototype. When Monday came, and I informed one of my colleagues about my clever idea and the project I started building out, to which he replied "isn't that just LINQPad?"

## [LINQPad](https://www.linqpad.net/)

![LINQPad in action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3u4lskgapb0vi283y0i.gif)

LINQ is probably one of the most beloved aspects of .NET.

And LINQPad takes advantage of that. You can connect to a variety of SQL database flavors and it will generate the models and display a code editor within the app, and it supports all of the .NET languages (VB, C#, F#, etc), has a useful model explorer, and even has intellisense and integrated debugging. When you run your LINQ queries you can then output it in a grid format, exactly like you'd see in something like MySQL Workbench. It really was everything I wanted, and more. The only qualm I have is that it is Windows only...

LINQPad, where have you been my whole life?
Astro 1.0 is out! Let's check it out! Did a live demo in my Twitch Channel
Published: 2022-08-13 13:53:00

For those who missed my stream earlier, we took Astro 1.0 for a spin! It was really a delightful experience! Check out the replay here `https://www.twitch.tv/videos/1560582959` to see how we ran an example blog using Astro.

Check out Astro here https://astro.build/

You can follow me in Twitch to get live notifications. 

Replay is also available in my youtube channel 

{% embed https://www.youtube.com/watch?v=YrqBk9B6tZI %}
How to get more contributors for our open source project?
Tags: opensource, webdev, discuss
Published: 2022-08-13 13:49:46

We have been coding for our open source project called [Deviser Club](http://deviser.club/). And our contributors are increasing very slowly, how can I rapid up that process?
Here's the project...
> https://github.com/Bishwas-py/deviser-club
Laravel: object _get Alternative for optional Helper Function
Tags: laravel, helpers, tips, php
Published: 2022-08-13 13:31:45

**Hi Devs**, In Laravel when accessing a relationship property we not sure whether the relationship data exists. if exists it's good to go. but what if not exists those times we get the following Warning;

Consider the Below code

```
$user = User::findOrFail(1);
$subscription = $user->subscription->created_at;
```

`PHP Notice:  Trying to get property 'created_at' of non-object in /Users/benittoraj/code/laravel/mas-laraveleval()'d code on line`

To Avoid the above error we often use optional helper function. 

```
 $subscriptionCreatedAt= optional($user->subscription)->created_at;
```

Do You know there is another way of handling this using object_get helper function


```
$subscriptionCreatedAt = object_get($user, 'subscription.created_at);
```

The Nice thing about object_get helper function is we can access the relationship relation property using dot syntax. So our code looks clean. If some relation data does't exists it stops there and return null;

[object_get helper implementation](https://github.com/illuminate/support/blob/master/helpers.php#:~:text=*/-,function%20object_get(%24object%2C%20%24key%2C%20%24default,%7D,-%7D)


**_Keep Learning!!_**
Coding: A life
Tags: codenewbie, codepen, programming, product
Published: 2022-08-13 12:53:00


**Coding becomes life for a Coder as** If testing of code went successful, it is lifesaving but if it comes out with number of bugs, it put our lives in danger. That breath holding moment (Surely every coder might have experienced it) is even difficult to imagine and definitely most difficult to face as Every self written code requires a lot of time due to logic making and converting logic  into a code. 
so, I pray that **_may every coder experience such situations least number of times as much as possible.
_**
HTTP Methods "GET", "POST", "PUT", "PATCH", "DELETE"
Tags: api, webdev, javascript, tutorial
Published: 2022-08-13 12:50:00

> To work with REST API efficiently, Its important to know the basic HTTP methods and what each of them does.

Out of 39 http methods, developers typically use the **"GET", "POST", "PUT", "PATCH"** and **"DELETE"** methods.
In this article, I will be showing you the difference between the 5 methods mentioned above and when to use them.

## ✔ GET
The GET method is used to retrieve resources from a server. It is said to be a **safe method** as it does not change the state of the resource in any way.
GET method is **idempotent** Thus calling this method multiple times will always give the same result.

**Example URIs**
```javascript
HTTP GET 'http://www.apidomain.com/users'
HTTP GET 'http://www.apidomain.com/users?size=20&page=5'
HTTP GET 'http://www.apidomain.com/users/123'
HTTP GET 'http://www.apidomain.com/users/123/address'
```
## ✔ POST
POST method is used to create a new resource into the collection of resources on a server.

> 
It is important to note that POST is Non-idempotent. Thus invoking two identical POST requests will result in duplicate information being created on the server.

**Example URIs**

```javascript
HTTP POST 'http://www.apidomain.com/users'
HTTP POST 'http://www.apidomain.com/users/123/accounts'
```
## ✔ PUT
PUT is used to update the existing resource on the server and it updates the full resource.
If the resource does not exist, PUT may decide to create a new resource.
PUT method is **idempotent** Thus calling this method multiple times will always update the same resource multiple times.

**Example URIs**

```javascript
HTTP PUT 'http://www.apidomain.com/users/123'
HTTP PUT 'http://www.apidomain.com/users/123/accounts/456'
```
## ✔ PATCH
PATCH is used to update the existing resource on the server and it updates a portion of the resource.
If the resource does not exist, PUT may decide to create a new resource.
Just as the PUT method, PATCH is also **idempotent**

**Example URIs**

```javascript
HTTP PATCH 'http://www.apidomain.com/users/123'
HTTP PATCH 'http://www.apidomain.com/users/123/accounts/456'
```

## ✨PATCH vrs PUT 
PUT method primarily fully replaces an entire existing resource but PATCH partially updates an existing resource.

> The PATCH method is not a substitute to the PUT method. It applies a delta (diff) rather than replacing the entire resource.

## ✔ DELETE
DELETE Method is used to delete the resources from a server. It deletes resource identified by the Request-URI.

DELETE method are idempotent.

## Conclusion

> 
As a backend developer, It is very important to follow the standard approach in building your API.

Bentil here🚀
If you like my content, you can support me here to keep up the work.👇
<a href='https://www.buymeacoffee.com/qbentil' target="_blank">
![buy me a coffee](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf2285oqld8zpevvsqvt.png)

Let me know your questions or suggestions in the comment box below
How to Build Creative eCommerce Website Using HTML CSS JavaScript
Tags: css, javascript, beginners, tutorial
Published: 2022-08-13 12:49:32

{% youtube AMI-6F7CSFc %}

How to Build Creative eCommerce Website Using HTML CSS JavaScript

This video will show you how to build a creative ecommerce website using html css javascript

[Live Website](https://codewithsadee.github.io/glowing)
[Github Repo](https://github.com/codewithsadee/glowing)

---

HI 👋
I'm Sadee (webdev)
In this channel I make videos about Complete Responsive website.
You can checkout my channel 👇

📺 My Channel : [codewithsadee](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g)
🔔 Subscribe : [subscribe now](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g?sub_confirmation=1)

---

🔗 Essential links
-----------------------------
[Download the starter file to practice](https://drive.google.com/file/d/10eNzmvh6jrTEnS8rrhFEFsQYF4FQ73o8/view?usp=sharing)

---

⏱️ Timestamps
-----------------------------
0:00 - Demo
7:02 - File structure
7:30 - Project initial
13:09 - Header
33:47 - Hero section
42:45 - Collection section
50:39 - Shop section
1:05:19 - Banner section
1:09:09 - Feature section
1:12:28 - Offer section
1:18:43 - Blog section
1:23:05 - Footer
1:36:55 - Scroll reveal
1:39:58 - Media queries

---

[![Become a patreon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnjl14kdm5qf08hu5lop.png)](https://www.patreon.com/bePatron?u=62535867)
Maximum Subarray: LeetCode
Tags: javascript, leetcode
Published: 2022-08-13 12:21:00

```
var maxSubArray = function(nums) {
    
  let max = nums[0];
  let maxEnding = nums[0];
  for (let i = 1; i < nums.length; i++) {
    maxEnding = Math.max(maxEnding + nums[i], nums[i]);
    max = Math.max(maxEnding, max);
  }
  return max;
};
```
Complete JavaScript Tutorials
Tags: javascript, webdev, tutorial, react
Published: 2022-08-13 12:15:37

We have created a youtube channel, in which we have covered almost all the main topics of JavaScript development, by learning these topics you can be able to master your coding interviews.

https://www.youtube.com/channel/UC9WtUscS9EUCaJuazSYjUlQ

We are currently working on TypeScript series along with ReactJS and NextJS
Passky Password Manager
Tags: opensource, productivity, javascript, php
Published: 2022-08-13 12:01:55

For everyone that care about their privacy, we have released free and open source password manager that can be self-hosted with ease.

Link: [https://passky.org](https://passky.org)
Source Code: [https://github.com/Rabbit-Company](https://github.com/Rabbit-Company)
Summer pause
Tags: devjournal
Published: 2022-08-13 12:00:00

I will be back in a few weeks, folks

Meanwhile, you can read my series of article about:

- screensavers and tips in i3

The first article: {% embed https://dev.to/ccoveille/xautolock-corners-5161 %}

- git journey

The first article: {% embed https://dev.to/ccoveille/git-interactive-patch-4f55 %}

See you
Information Architecture (IA)
Tags: ux, webdev, beginners, design
Published: 2022-08-13 11:55:00

 

![IA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4kh00fruaatpvcajzuzt.png)
In case you are wondering, information architecture is as important as having a skeleton or shall I say, a backbone? Just the same way a building needs an architect before the actual construction, so does a website or a web application.

#### What is (IA) Information Architecture?

> It is the art and science of organizing and labelling websites, intranets, online communities and software to support usability and findability <br>
-From Wikipedia


<u>**Information Architecture determines:**</u>

- What information should go where.

- Which elements are most important and should be given priority.

To achieve a good User experience,the information architecture must be logical. 

##### Below are the 4 basic steps involved in Information Architecture:

###### 1. Define Company Goals
Determine the goals which may range from; reducing costs, making money to even helping customers make better decisions. Whatever the goal may be, get together with the key stakeholders and outline clear objectives.

###### 2. Define User Goals
Determine the users of the product. What are they going to do on the website and what do they hope to achieve? Conduct user interviews and create user personas. Here, you will need to think of any constraint the user might have.

###### 3. Conduct Competitor Analysis
Analyzing similar products on the market will give you an idea of what your customers expect.
Before defining your own Information Architecture, take a look at what your competitors are doing. Look at where they are displaying information. Consider their strengths and weaknesses; are their websites easy to navigate?

###### 4. Define your Content
When working with information architecture, you will either be redesigning an existing website or creating one from scratch. If a website already has content, go through it and decide what to keep and what to get rid of.
If you are short of time and resources, just focus on the important parts of the website.
<br>
In a nutshell, IA ensures that things are where they should be therefore creating a user experience that doesn't require the user to think too hard.

#### Conclusion

> By investing time in IA design, you create a foundation for efficient user experience. After all, content is the heart of every app or website. <br>
Words by
Nick Babich
How to test a beta version of phabalicious in parallel
Tags: phabalicious, phab
Published: 2022-08-13 11:42:00

Sometimes it would be neat to test if a new beta version of phabalicious works with my local projects, without breaking
my productivity if I encounter problems. Fortunately it is rather safe to have two phab versions installed on your local
computer.

Usually you keep phabalicious up-to-date by running `phab self-update`. The easiest way to install a beta-version side
by side to the official version are the following commands:

```shell
$ curl -L  https://github.com/factorial-io/phabalicious/releases/download/3.8.0-beta.16/phabalicious.phar --output /usr/local/bin/phab38
$ chmod +x /usr/local/bin/phab38
$ phab38 --version
phabalicious 3.8.0-beta.16
```
Please adapt the version in the url to your likings. After a successfull installation you can update the beta version using

```shell
phab38 self-update --preview
```

And if you want to test if your project is still working with the new beta version, just substitute `phab` with `phab38`, e.g.

```shell
phab38 -cmbb docker run
```

* If you encounter any problems with a beta or a stable version please create an [issue](https://github.com/factorial-io/phabalicious/issues)
* To remove the beta-version just run `rm /usr/local/bin/phab38`
8 nightmare Chrome Extensions for developers🤖
Tags: chrome, extension, developer, speed
Published: 2022-08-13 11:36:57


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fxm2zs0zcrucadks1wa.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1ft7m40bgw5ppo8fkkk.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w03jy1ylx16gy5w0asg6.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mnvvjcox06ur507y52f1.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlc9yq9pu17zphx3a1pk.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/forpe8ageyvpiy26gwlj.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgtf5nkrfm387wohvoa8.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enoilrtcvzgov8hqx5jg.png)
Skilled Worker Visa UK
Published: 2022-08-13 11:25:53

Getting a UK Skilled Worker Visa is easy if you are a software engineer and want to move to the United Kingdom.

Last year I decided to move to the United Kingdom from Poland to work as a software engineer in London on a Skilled Worker Visa. I was recently endorsed by Tech Nation for the Global Talent Visa.

In this video I talk about what you need to know about the UK Skilled Worker Visa and how you can move to the United Kingdom with this visa:

{% embed https://youtu.be/KGJJaAVRwo8 %}
Initial Loader
Published: 2022-08-13 11:02:59

Hey ☀️

I am creating a Nextjs + tailwind app and would like to add in an initial homepage loader i.e. when the user first arrives on the app a preloader page should show until the homepage content has fully rendered. 

The route change set up doesn't work since this is for initial load not navigating pages. 

Any suggestions / experience with this would be a big help
Converting Binary to Decimal with parseInt's Base Feature
Tags: javascript, webdev, tutorial
Published: 2022-08-13 10:14:00

Binary numbers are numbers which are expressed in base 2 notation, rather than the base 10 we are used to. Consider how we normally count in base 10 - when we reach 10, we have to add an extra number to express it. Similarly, in base 2, when we reach 1, the next number has to be expressed by adding a new number to it. So while **1** is equivalent to 1, **10** is equivalent to 2.

You can convert any binary numbers to decimal using the calculator below.

## Binary to Decimal Calculator
{% codepen https://codepen.io/smpnjn/pen/RwMePJK %}

## Converting Binary to Decimal using parseInt in Javascript
You've probably used `parseInt` before if you've worked in Javascript - but did you know you can set the **base** using `parseInt`? If you use the second argument of `parseInt`, you can set the base:

```javascript
let x = parseInt('10101', 2);
console.log(x); // Returns 21
```

Most likely, you'll want to use base 2, but you can use any base you like here. So `parseInt('10010', 3)` will convert a base 3 number to a decimal too. This is a pretty useful and little used `parseInt` feature.


## Converting Binary to Decimal using Calculations
As mentioned previously, you can calculate a binary value in decimal when you consider that you can only ever go as high as `1` in binary, just as you can only ever go as high as `9` in decimal. So as in decimal, when you reach `9`, you have to add another number to represent `10`, in binary, when you reach `1`, you have to add another number to represent `2` - so `10` is `2`.

The easiest way to convert a binary number to a decimal is to understand that each number in a binary can be represented like so:
```
BINARY:  1   0   1   0   1   0   1
DECIMAL: 64  32  16  8   4   2   1

```

All we have to do to convert a binary number to a decimal, is to know that each number can be represented in binary as a decimal number which increases by a multiple of 2 each time. So the last number, is `1`, and then the next is `2`, and the next is `4`, and so on.

To convert a binary like `1010101` to decimal, we multiply each number by its decimal representation. So we can do:
- `1 * 1` - giving us 1
- `0 * 2` - giving us 0
- `1 * 4` - giving us 4
- `0 * 8` - giving us 0
- `1 * 16` - giving us 16
- `0 * 32` - giving us 0
- `1 * 64` - giving us 64

Then we add them all up! So `1` + `0` + `4` + `0` + `16` + `0` + `64` - giving us **85**!