teleren/devto huggingface dataset:
Brute force recursion to dynamic programming(knapsack problem) 03
Tags: leetcode, algorithms
Published: 2022-06-26 04:07:06

## Question
Given two arrays of length N, w[] and v[], w[i] and v[i] represent the weight and values of item i, respectively. Given a positive number bag, representing a bag with a load bag. Your items cannot exceed this weight. Return what is the most value you can hold?
### Solution #1 Brute force recursion

1. Found the base case, two cases, the array of w is end or bag capacity is less than zero. Because the weight of w[i] may be zero.

2. Decision, whether the w[i] position needs to be. If necessary, the bag capacity minus the weight of w[i] and add the value of v[i]. If not necessary, skip w[i] position. Choose the maximum of the two decisions.

```
public static int myMaxValue(int[] w, int[] v, int bag) {

        return myProcess(w, v, 0, bag);
    }

    public static int myProcess(int[] w, int[] v, int index, int bag) {
        if (bag < 0) {
            return -1;
        }
        if (index == w.length) {
            return 0;
        }

        int p1 = myProcess(w, v, index + 1, bag);
        int p2 = 0;
        int next = myProcess(w, v, index + 1, bag - w[index]);
        if (next != -1) {
            p2 = next + v[index];
        }
        return Math.max(p1, p2);
    }
```

### Solution #2 Dynamic programming

```
public static int myDp(int[] w, int[] v, int bag) {
        int N = w.length;
        int[][] dp = new int[N + 1][bag + 1];

        for (int index = N - 1; index >= 0; index--) {
            for (int rest = 0; rest <= bag; rest++) {
                int p1 = dp[index + 1][rest];
                int p2 = 0;
                int next = rest - w[index] < 0 ? -1 : dp[index + 1][rest - w[index]];
                if (next != -1) {
                    p2 = v[index] + dp[index + 1][rest - w[index]];
                }
                dp[index][rest] = Math.max(p1, p2);
            }
        }

        return dp[0][bag];
    }
```
1423. Leetcode solution in CPP
Tags: cpp
Published: 2022-06-26 03:35:02

```
// Time: O(K)
// Space: O(1)
class Solution {
public:
    int maxScore(vector<int>& A, int k) {
        int ans = 0, N = A.size(), left = 0, right = 0;
        for (int i = 0; i < k; ++i) right += A[N - i - 1];
        ans = right;
        for (int i = 0; i < k; ++i) {
            left += A[i];
            right -= A[N - k + i];
            ans = max(ans, left + right);
        }
        return ans;
    }
};

```
Docker image layer
Published: 2022-06-26 02:03:12

Firstly, we need to understand about the docker image.

**What is a Docker image?**
A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker container, like a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.
Docker is used to create, run and deploy applications in containers. A Docker image contains application code, libraries, tools, dependencies and other files needed to make an application run. When a user runs an image, it can become one or many instances of a container.

**What is Docker image layer?**
Docker images have multiple layers, each one originates from the previous layer but is different from it. The layers speed up Docker builds while increasing reusability and decreasing disk use. Image layers are also read-only files. Once a container is created, a writable layer is added on top of the unchangeable images, allowing a user to make changes.
If you have a tagged image pointing to a chain of 5 images built on each other, that tagged image has 5 layers, or 5 (or 4? depending on how you see it) intermediate images if you prefer that notion.
The following instructions create a layer: RUN, COPY, ADD.
The other instructions will create intermediate layers and do not influence the size of your image.
Exploring circular text in CSS and SVG
Tags: css, design
Published: 2022-06-26 01:05:32

I decided I'm sick of the grid. I want to align some text to a circle.

As it turns out, it's not so hard to do this with SVG. You don't even need a complicated path element. Just grab yourself a `<circle>`, like so:

{% codepen https://codepen.io/ashleykolodziej/pen/XWpEdaJ %}

With this pen, I wanted to explore depth, so I adjusted the placement, opacity, and size of the text in each circle.

{% codepen https://codepen.io/ashleykolodziej/pen/poRLbeg %}

And of course, if you know me, you know I'm into my colors. So I thought, well, rainbows are sort of a circle too.

{% codepen https://codepen.io/ashleykolodziej/pen/gOgeMvJ %}

## Writing creative CSS

My best moments in CSS are when I find out something new, and just keep riffing on it endlessly. I've got a [whole site](https://www.bu.edu/cds-faculty/) dedicated to this rainbow situation here:

{% codepen https://codepen.io/ashleykolodziej/pen/VwYagVN %}

This is how you learn in design school. You take a piece of paper, and you cut it up and really focus on how the shapes or colors or just one piece of it is interacting with the rest. And then, you figure out the best bits.
Laravel 9 WhereNotIn Database Query Examples
Tags: laravel, php, beginners, tutorial
Published: 2022-06-26 00:07:48

Laravel framework has been in demand for some time now. Its expressive command line structure has mesmerized the coding world. The framework is also known for its robust scalability. Laravel is one of the most sought-after of frameworks for eCommerce solutions because of the sheer number of options it provides. One can use its vast library to create functionalities that will help the users. The best feature of Laravel is probably is its ability to provide the developer with myriad options for the same query. This makes the job of the developer that much simpler. Expressive queries lead to greater flexibility and a better understanding of the need of the user and the functionality.

This tutorial provides you simple examples of where Not In Laravel Query Builder. And as well as how to use Laravel Eloquent WhereNotIn with arrays.

## Laravel Eloquent "WHERE NOT IN" Query Examples
The wherenotin() database query method takes two parameters. In the first argument, you pass the column name, and the second value you supply is the array id.

Here is the whereNotIn query syntax that you can use in Laravel.
```
whereIn('column name', 'array')
```
- Column_name:- Your database table column name.
- Array: – The column’s value is not contained in the given array.
Let’s take look at some examples of whereNotIn() eloquent method in laravel.

## Example 1: whereNotIn Query Using Simple SQL Query:
```
SELECT *  FROM users  WHERE id NOT IN (1, 5, 9)
```
In this SQL query, the data will not be gotten from the DB table. Whose ids will be 1, 5, 9.

## Example 2: Eloquent WhereNotIn Query Using Query Builder
```
public function users()
{
    return DB::table('users')->whereNotIn('id', [1, 5, 9])->get();
}
```

## Example 3: Eloquent WhereNotIn Query Using Laravel Model
```
public function users()
{
    return User::whereNotIn('id', [1, 5, 9])->get();
}
```
So far you have seen in the given example. Have used ids for scaping and getting data into DB table. But now for example 4, we will fetch the data by using the DB table column name.

## Example 4: Eloquent WhereNotIn Query Using Laravel Model With Different Column Name
```
public function users()
{
    return User::whereNotIn('email', ["test@test1.com", "test@test2.com"])->get();
}
```
**Thank you** for reading this article.
Not A Beginner Ternary Statement
Tags: javascript, beginners
Published: 2022-06-25 23:50:36

I've begun planning a JS library that I hope that would be published on NPM. As a self-taught programmer, I'm continually learning that observing other peoples' code is incredibly important. As I take notes for similar JS libraries to inspire me, I stumbled on this interesting line of Javascript.

`debug = typeof value === 'boolean' ? value : debug`

Here's the function scope for full context:
```javascript 
Object.defineProperty(ScrollReveal, 'debug', {
	get: () => debug || false,
	set: value => (debug = typeof value === 'boolean' ? value : debug)
})
```

I use ternary statements constantly in my freelance web development, but the beginning part of the line is very interesting, as I've never seen this type of assignment/destructing in a ternary before. I didn't know that it was a thing, and it's brilliant. 

Left-to-right, the setter is returning (like all ternaries do) a value, but what makes this different is the `debug =` part, which is assigning `typeof value` to the lexical variable: `debug`. So, when using this setter function, if the parameter isn't a boolean, it makes a small referential loop to `debug`, which is whatever type the parameter is. 

I see this being useful for more concisely skipping type clauses in functions, but for when approaching an interface in a negating direction (instead of adding allowed types like `string | boolean`). If you want to make a type by remove types from `any`(in JS instead of Typescript world), perhaps this is a nice clean way of doing that. 

The beauty of Javascript (or just any programming): You'll always learn more.
Software Defined Video Sintesis.
Published: 2022-06-25 23:49:20

I will translate it to chinese, rusian and english soon i promise.

El mundo entero sera definido por software, mientras tanto, al menos el video lo podemos empezar a definir por software. 
Con HTML, CSS y javascript podemos crear animaciones, simuladores, fractales, en fin cualquier cosa generativa, ahora bien, para mostrarlo una forma es el video, como lo pasamos a video en alta o muy alta resolucion... para mi eso es la base de la tecnica del "Video definido por software" o la sintesis del video. 

Estaba investigando como convertir mis animaciones en Código a video con muy alta resolución a pesar de que mis equipos con trabajos llegan a un svga. 

Encontré al rededor de shotcut y la edicion de video, esto de la pareja Elusien  muy bueno. 

http://www.elusien.co.uk/shotcut/gl-transitions/index.html

http://www.elusien.co.uk/shotcut/resources/index.html#section_4

http://jsbin.com/yageyezabo/edit?html,js,output

http://www.elusien.co.uk/

---

### Otras links sobre el tema de video definido por software generacional.


https://forum.shotcut.org/t/html-css-animation-insert-into-shotcut-video/11293

https://www.bing.com/videos/search?q=shotcut+html+animation&view=detail&mid=E29C07D5BCCEA915189FE29C07D5BCCEA915189F&FORM=VIRE

https://www.bing.com/videos/search?q=shotcut+html+animation&view=detail&mid=E29C07D5BCCEA915189FE29C07D5BCCEA915189F&FORM=VIRE
If Copilot generates postcardware, where should you send the post card?
Tags: githubcopilot, ai, programming
Published: 2022-06-25 23:32:34

I was recently asked a question that stumped me: where should one send a postcard if an artificial intelligence coding assist tool accidentally generates license stating that the code it made is postcardware?

I'm not sure what the answer is, but I thought I'd share my thoughts on the matter.

It seems to me that there are two possible options. First, you could send the postcard to the company that made the tool. After all, they're the ones who released the code into the world, and they should be held responsible for its actions.

Alternatively, you could send the postcard to the person who wrote the code that the tool generated. They're the ones who actually created the code, so they should be the ones to get the credit (or blame) for it.

 Personally, I lean towards the latter option. It seems only fair that the person who created the code should be the one to receive the postcard. But ultimately, the decision is up to you.

So, where should you send your postcard? I'm not sure. But I hope this article has given you something to think about.
Código de Fin de Semana - Introducción
Tags: programming, productivity, spanish, motivation
Published: 2022-06-25 22:11:11

## De que se trata

Hablemos de situaciones reales que vivimos los devs, en alguna etapa de nuestra carrera:

😵 ¿Te encontraste alguna vez sin saber que hacer un fin de semana para calmar la ansiedad de tipear un poco de código? 
😵 ¿Te abruma tanta información disponible y no sabes por dónde empezar?
😵 ¿Viste un tutorial y queres empezar, pero sabés que eso va a seguir profundizando el agujero del tutorial hell? 
&nbsp;
&nbsp;
![Desarrollo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p4t8dxbai7cutc641zs2.jpg) 



&nbsp;
&nbsp;
**Proyectos en Fin de Semana** es una iniciativa propia que busca calmar esa ansiedad de aprendizaje y autorrealización proponiendo un proyecto que puedas realizar en unas pocas horas (no más de 1 día).


&nbsp;
Así, conseguimos dos objetivos claves: 
🎯 *Reducir nuestra ansiedad*: Desarrollando algo propio, nuevo y con diferentes enfoques, nos sentimos satisfechos y realizados. 
🎯 *Aprender y especializarnos*: Cada proyecto nos abre un poquito más la cabeza y nos deja nuevas herramientas, terminología, incluso skills que constantemente debemos reforzar.


&nbsp;
### ¿Qué necesitas? 
Ganas, un poco de tiempo y auto organización. La idea es que disfrutes cada proyecto y no pierdas tu valioso time-off de trabajo, código, debuggers, y demás tareas diarias a las que estás acostumbrado.


&nbsp;
### ¿Nivel de programación esperado? 
Dependiendo el proyecto. Trataré en lo posible de dejar links a herramientas que se utilizan en cada proyecto con una breve descripción (o tal vez a la propia web).
Aquí una realidad del mundo tech: 🚀 **¡Se aprende haciendo!**🚀 No te preocupes si no entendes la teoría la primera vez, preocupate si no tenes más ganas de aprenderla.
Bigg Boss 16: Will Salman Khan return as the host of the next season? Actor REVEALS
Published: 2022-06-25 21:58:18

[Bigg Boss 16](https://biggbossseason16.com/) is one of the most awaited reality shows of the year, and recently, Salman Khan revealed whether he will be returning as the host of the show or not. 

One reality show the audience eagerly waits for every year is Bigg Boss. Till now, we have seen 15 seasons of the show, and now, everyone is keen to know when Bigg Boss 16 will kickstart. The show usually starts in October and gets over by January or February. Already there are reports about which celebs will be seen in the next season, and fans of Bigg Boss also are waiting for their favourite host Salman Khan to return to the show. Also Read – Kiara Advani calls Varun Dhawan a ‘chauvinistic’ after he says as a man he’s taught to earn for his family [Saath Nibhaana Saathiya](https://saathnibhaanasaathiyadrama.com/)

Well, every year, Salman Khan gets angry with contestants due to some reason and says that he might not return as the show’s host in the next season. However, he comes back as we are sure no one can host Bigg Boss the way Salman does. Also Read – Pushpa star Allu Arjun gets massively fat shamed for his latest appearance; netizens call him, ‘vada pav’ [dramacool](https://dramacoolseries.com/)

Recently, on the green carpet of IIFA 2022, Salman confirmed that he is returning as the host in Bigg Boss 16. While talking about hosting IIFA and Bigg Boss, Salman said, “This is the first time I will be hosting IIFA so I don’t know how that’s going to be. But, Bigg Boss I have been hosting for the past many years.” When probed him that it’s safe to say that he is going to be hosting Bigg Boss this year as well, the actor said, “Yes, very safe.”
[Yeh Rishta Kya Kehlata Hai](https://yehrishtakyaakehlatahai.com/)

So, all the Salman Khan fans get ready to watch him as the host of Bigg Boss 16. While the makers have not yet confirmed which contestants will be seen in the show, a few days ago, there were reports that Anjali Arora and Munawar Faruqui, who were also a part of Lock Upp, will be seen on [Bigg Boss Season 16](https://biggbossseason16.com/category/bigg-boss-season-16/).

Talking about Salman’s movies, the actor will be seen in films like Kabhi Eid Kabhi Diwali, Tiger 3, and No Entry 2. Kabhi Eid Kabhi Diwali is slated to release this year in December, and Tiger 3 will hit the big screens on Eid 2023. No Entry 2 is yet to start rolling.[telemundo](https://watchtelenovelasonline.com/)
Day 78: I found a Tailwind CSS secret 😉
Published: 2022-06-25 21:58:06

Hi!
Today I found a secret in Tailwind 😎, actually is not a secret per se it's just something that I had no idea about and have fighting with with for some time. 
Let's say we have a React component that has some tailwind classes as styles, and you can call that component pass more style classes as props, what if you want to call the component and  override some default tailwind classes by sending the same classes values as props?
I thought by placing new classes (props) at the end they will override default styles and it worked in some case but I was surprised to find that it's not always the case.
and that's because of [CSS Cascade](https://developer.mozilla.org/en-US/docs/Web/CSS/Cascade).

Actually this issue is explained in more details in [this article](https://dev.to/diogoko/overriding-tailwind-classes-in-react-4po3)

after reading I used the [Tailwind-merge](https://www.npmjs.com/package/tailwind-merge) package and the issues I had with styles was solved but I have also found other alternatives that are worth looking into but I think this was something interesting to learn today.

Today I was mainly working with a friend on consuming a Graphql API on the frontend using apollo client and I learned some new content to and I later looked into phone authentication with Firebase which I plan to implement tomorrow.

So tomorrow will be for Firebase, maybe an article and some rest and that will be enough for the week

Signing off...
How to Receive Email from HTML Form using PHP | How to Connect Contact form to email in PHP
Tags: webdev, php, programming, beginners
Published: 2022-06-25 21:35:33


In this Tutorial you will learn the following:

How can I get the contact form from email in PHP?
How do I get form data to email?
How do you create a form in HTML and send it to email?
How do I link a contact form to an email in HTML?
How to Send Contact Form to Email Using PHP?

PHP mail is the built-in PHP mail function that is used to send emails from PHP scripts. It's a cost-effective way of notifying users of important events. Let users contact you via email by providing a contact us form on the website that emails the provided content.

## Full Video Tutorial:
{% youtube _bT-hcTsYhI %}

There are a few steps to send the HTML form submission directly to an email address:
1. Create a contact form using HTML and CSS
2. Host HTML form on the live web hosting server to write PHP script
3. Open your VS Code editor
4. Connect VS Code editor to live web server using FTP-Simple extension
5. Change your file extension from .html to .php
6. Write PHP code to send HTML form data to email using PHP

The first way to send a contact form directly from a PHP script is by using the built-in PHP mail() function. To use the PHP send mail feature, you need to host your PHP contact on a web server.
How will you send an email using PHP?
How do I send an email from the client side?,
Can I send email from localhost PHP?,
How do you check PHP mail () is working?,
How will you send an email using PHP,
Can I send email from localhost PHP,
how to send html form data to email using php
php code to send email from contact form download
sending html form data to an email address without php
php contact form send email template
php code to send email from website
php contact form send email w3schools
php contact form send email codepen
If you found this video helpful please share the video and SUBSCRIBE to this youtube channel. Please share your thoughts and queries in the comments below
How to Publish Website on Internet Free | How to Host a Website on Internet for Free
Tags: webdev, webhosting, html, beginners
Published: 2022-06-25 21:30:03


In this video, I will show you How to Publish a Website on the Internet Free of cost. if you want to run a test website, you’re not expecting much of it, and you don’t want to invest any money in the project at all, then free website hosting might indeed work for you! 

{% youtube XY1XET-B5Ok %}

There are many online sites which provide free webhosting services for your website project.
 Just keep in mind that There are some limitations of free website hosting service. 
For example: Free hosting providers may place restrictions on storage space and bandwidth, limiting your site’s growth and traffic capacity . Your personal website or business website may also have slow performance. There is a site named 000WebHost.com is a free web hosting platform where you can host your website for free.

How to create single page website (Source Code):  
{% youtube KDaGjYQTDF0 %}

how to host an HTML website on Liver server for free,
how to upload webpage on internet free 000webhost,
how to launch html website on internet free,
how to publish html website on internet free in hindi,
how to upload your website on internet for free,
how to host a website free on github,
how to host a website on google for free,
how to host a website for free in 000webhost,
how to host a wordpress website for free,
how to host a free website with infinityfree,
how to host a static website for free,
how to host a website for free code with harry,
how to host a html website for free in hindi,
WIP: Série Hoje Aprendi
Tags: todayilearned, hojeaprendi
Published: 2022-06-25 21:20:54

Este será um post com pequenas coisas do dia a dia que vou aprendendo e vou inserindo aqui, ele será um eterno WIP post (vamos ver até onde o Dev.to vai me permitir hehe):

##Docker
`docker build . --platform linux/amd64`
###Contexto: 
Estavam rodando uma build do docker no Macbook M1 e ele estava gerando coisas dentro da imagem com base ARM

_Referência:_ https://docs.docker.com/engine/reference/commandline/build/#options

##Systemd
`systemd-run --scope -p MemoryMax=5024M --user rspec spec/`
###Contexto:
Eu estava precisando limitar a quantidade de memória de um processo na máquina que estava usando, pois os testes que estava rodando consumiam MUITA memória :sweat_smile: 
ps: Adicionando o --user para usar o contexto o user e reduzir o escopo de acesso do processo
Dica adicionada por @lucas59356 - X

_Referência:_ https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html

##Rails - ActiveRecord
`User.attribute_types`
`User.columns`
`User.columns_hash`
###Contexto:
Estava apenas querendo saber os tipos de dados do model/tabela sem ter que sair do console do Rails

_Referência_
https://github.com/rails/rails/blob/main/activerecord/lib/active_record/model_schema.rb#L428

##Ruby - Object/Method
```
Time.method(:parse).parameters
 => [[:req, :date], [:opt, :now]]
```
###Contexto:
Estava querendo saber os paramêtros que uma classe esperava em seu construtor e eu não tinha acesso a tal arquivo pra ler  essa classe, dúvida sanada por @leandroico. 
 
_Referência_ 
https://ruby-doc.org/core-2.6.4/Method.html#method-i-parameters

##Rails - ActiveRecord/Reflections
```
3.0.4 :035 > Decidim::User.reflections.keys
 =>
["resource_links_to",
 "resource_links_from",
 "resource_permission",
 "follows",
 "followers",
 "organization"
...
```

###Contexto:
Estava apenas querendo saber as associations de um model (que usa ActiveRecord) sem ter que ficar percorrendo e vasculhando mil arquivos.
Ás vezes temos models e ou usamos classes que estão "escondidas" em gems ou nos internals do framework e não temos acesso fácil via editor.

_Referência_
https://api.rubyonrails.org/classes/ActiveRecord/Reflection/ClassMethods.html#method-i-reflections