teleren/devto huggingface dataset:
Kotlin Springboot -- Part 2 Driver に data class を定義して instance を作り、Usecase でまとめて Main で呼び出す
Tags: kotlin, springboot, cleanarchetecture
Published: 2022-08-28 09:59:00


## そもそもの main のフォルダ構成と方針

```php
~/source/springboot/src/main/
kotlin/com/example/springboot/
SpringbootApplication.kt
```

ここに

```kotlin
package com.example.springboot

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class SpringbootApplication

fun main(args: Array<String>) {
	runApplication<SpringbootApplication>(*args)
	println("main worked")
}
```

main が有る形。

ここを REST の一番外側として扱う？Driver として扱う？

とりあえず main を gateway として扱い、
インメモリで変数をデータとして扱う Driver を作成して import する

---

## SpringbootDriver の作成

SpringbootApplication と並列に
SpringbootDriver を作成

```kotlin
package com.example.springboot

data class Person(val name: String = "Taro", val age: Int = 0 ) {
    fun findName(): String {
        return name
    }
    fun findAge(): Int {
        return age
    }
}
val taro = Person("Taro", 12)
val hanako = Person("Hanako", 10)

```

Person クラスにデータを入れて初期化して
findName, findAge という getter を用意する
Person クラスを使って 太郎と花子のインスタンスを作成
export は必要なかった。

---

## main で Driver を呼び出す

```kotlin
import com.example.springboot.taro
import com.example.springboot.hanako

fun main(args: Array<String>) {
	runApplication<SpringbootApplication>(*args)
	println("main worked")
	val taroName = taro.findName()
	val hanakoName = hanako.findName()
	println(taroName)
	println(hanakoName)
}
```

SpringBootDriver で作ったインスタンスを importして 
main で直接呼び出せた。

(グローバルに宣言しているインスタンスなので
import しなくても呼べた)

これで Driver で作ったモノを main で呼び出した。

---

## Usecase で Driver を呼び出す

main でいきなり Driver を呼ぶのは不自然なので
せめて UseCase を介する形にする。

```kotlin
package com.example.springboot

import com.example.springboot.taro
import com.example.springboot.hanako

fun printAllName () {
    val taroName = taro.findName()
    val hanakoName = hanako.findName()
    println(taroName)
    println(hanakoName)
}
```

Driver を集約した UseCase を作って

```kotlin
import com.example.springboot.printAllName


@SpringBootApplication
class SpringbootApplication

fun main(args: Array<String>) {
	runApplication<SpringbootApplication>(*args)
	printAllName()
}
```

main で呼び出した。

```
2022-08-28 18:53:33.005  INFO 1430266 --- [           main] c.e.springboot.SpringbootApplicationKt   : Started SpringbootApplicationKt in 1.725 seconds (JVM running for 2.063)
Taro
Hanako
```

これでもいける。

Kotlin のファイルの値のやりとり完全に理解した

---

## まとめ

Kotlin/SpringBoot で CleanArchTechture っぽく

Driver -> Usecase -> main

って値をやり取りするなら

Driver で 
package でアプリ名を明示
データクラスとゲッターを作成
データクラスを使って実際のデータとなるインスタンスを作成

Usecase でアプリ名からインスタンスを直接インポート
ユースケースに基づいた形にして fun で定義

Main で アプリ名から(Usecaseでつくった)関数を直接インポーと
main の中で呼び出す

こうする。
Recommendation system #3 - Redis & Node Architecture
Tags: redishackathon, webdev, algorithms, javascript
Published: 2022-08-28 08:58:00

It is quite some time since the last time when I wrote about business requirements and goals of the recommendation system. That because I had busy private life recently. Thankfully, I am back and here is the next part of my Redis Hackathon journey.

You can find source code of this project on GitHub:
{% github pilotpirxie/recommendation %}

First of all, I set taxonomy for architecture. System is made of relations between four entities:
* Actor - decisive entity, for whom we try to match recommendations. In most cases this is a user or a group of users.
* Item - this entity represents what we try to match e.g. product in a store, article on a blog or video on a streaming platform.
* Event - are actor's actions used to calculate recommendation. It consist of tag with a score (weight).
* Recommendation - final verdict, how close certain actor and item are.

# Redis
Having domain entities I tried many different Redis data structures to find one suitable to store them. To store actor data the most useful was HashSet with key of actorId, field of tag and value of score but I wanted to add event expiration and it isn't possible to do that easily with this structure. So instead I decided to use basic String structure where key contains all such information and value is the score. Then using SCAN with wildcard I'm retrieving data. Item have set of unique tags so the Set structure seems perfect choice and Actor - just to point existence - are again simple Strings with create timestamps.

# Node
Node part of the application has been written using TypeScript and Express. System consists of app layer with recommendation mechanism run by controllers. Redis is hidden behind data access layer so can be easily replaced with different storage engine. High level architecture of recommendation system.

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

In the next part we are going look close at algorithm used to find recommendations.
Top 5 HTML Tricks and Tips
Tags: html, tips, tricks, beginners
Published: 2022-08-28 08:23:47

## 5 Useful HTML Tricks and Tips

1. Always close your HTML tags
When you type an opening HTML tag (e.g., b>, p>), always follow it with the corresponding closing tag. As an example:

<b>5 Useful HTML Tricks and Tips</b>
<p>5 Useful HTML Tricks and Tips</p>
<h2>5 Useful HTML Tricks and Tips</h2>
This ensures that your HTML pages work properly in all browsers and helps to prevent strange problems from occurring in your pages! This is especially true for tags like div>, span>, table>, tr>, and td>.

2. When possible, style HTML with style sheets.
Style sheets will greatly simplify your HTML coding. There will be no more font> tags everywhere! You also have much more control over the appearance of your pages, and you can change their appearance simply by editing one style sheet file.


3. Use an HTML validator
Before publishing your Web pages, it’s a good idea to run them through an HTML validator. These programmes will detect potential issues such as missing closing tags on tables and the use of tags that will not work correctly in all browsers. Remember that just because your page looks great in the browser you’re using doesn’t mean it will work in others!

HTML validators are also a good way to learn how to use HTML tags correctly – you can learn from your mistakes!

4. Use HTML comments wisely
You can add comments to your HTML code to make it clearer to you (and others). These are code snippets that Web browsers ignore, so they’re useful for adding short notes and reminders within the code:

<!-- Navigation area: Highlight a menu item with the "hi" class -->

```
<div id="nav">
  <ul>
    <li><a href="home.html">Home</a></li>
    <li class="hi"><a href="about.html">About</a></li>
  </ul>
</div>
```
5. Use widths and heights with HTML images
When using the img> tag, it’s a good idea to specify the width and height of an image. As an example:

`<img src="business.jpg" width="234" height="123">`

The benefit of doing so is that the Web browser can format the page faster as it loads because it knows how to lay out the images before they are downloaded. This means your visitors can begin browsing your page without having to wait for all of the images to load!

Source: [Top 5 HTML Tricks and Tips](https://diggdomain.com/top-5-html-tricks-and-tips/)
My RSS Cache Application
Tags: redishackathon, redis
Published: 2022-08-28 08:23:39

---
title: My RSS Cache Application
published: true
description: My submission to the Redis Hackathon on DEV!
tags: redishackathon, redis
---


### Overview of My Submission

- Creating the RSS Cache can help me to cache the source RSS feeds easily!
- It's my requirements for developing the RSS cache application.
- Here is the simple system architecture to describe how to build the App:

![App architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xdg0wpicwwyna7b5kk21.png)

### Submission Category: 

- It's the Wacky Wildcards category.

### Language Used

- Using the Python 3.8+ for developing the App.
- Using the Python Flask to developing the web application.

### Additional Resource info

- [MIT License](https://github.com/peter279k/my-rss-cache/blob/master/LICENSE)

### Collaborators

@peter279k

### Link to Code

{% embed https://github.com/peter279k/my-rss-cache %}
Implement Trie
Tags: python, leetcode
Published: 2022-08-28 07:47:04


A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.

Implement the Trie class:

Trie() Initializes the trie object.
void insert(String word) Inserts the string word into the trie.
boolean search(String word) Returns true if the string word is in the trie (i.e., was inserted before), and false otherwise.
boolean startsWith(String prefix) Returns true if there is a previously inserted string word that has the prefix prefix, and false otherwise.


```py

class TrieNode():
    def __init__(self):
        self.children = {}
        self.endOfWord = False

class Trie:
    def __init__(self):
        self.root = TrieNode()
        
    def insert(word):
        cur = self.root
        for c in word:
            if c not in cur.children:
                cur.children[c] = TrieNode()
            cur = cur.children[c]
        cur.endOfWord = True
    
    def search(word):
        cur = self.root
        for c in word:
            if c not in cur.children:
                return False
            cur = cur.children[c]
        return cur.endOfWord
    
    def startsWith(prefix):
        cur = self.root
        for c in prefix:
            if c not in cur.children:
                return False
            cur = cur.children[c]
        return True
        


```
Encryption and Decryption in Node Js with Express and mongoose.
Tags: saran, nodej, javascript, tutorial
Published: 2022-08-28 07:18:35

**Introduction**
Learning NodeJS is a great opportunity for every web developer: Tons of jobs, easy to learn and, as Javascript is a MUST on web developing for the FrontEnd, you already know the language!

**### Overview of Encryption and Decryption**
Encryption is the process of translating plain text data (plaintext) into something that appears to be random and meaningless (ciphertext). Decryption is the process of converting ciphertext back to plaintext. To encrypt more than a small amount of data, symmetric encryption is used.

->
Install all package.Json file like this image

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

->
Create a app.js file...
ecncyption
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucuf24lbad6pl7ulnk1c.png)

decryption 

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

## -> Simple Schema/Model
**

const mongoose=require('mongoose');

const userSchema = new mongoose.Schema({
name: String
})

module.exports= mongoose.model("User", userSchema)



Now run the server and check in Postman.
One minute tip to all freelancers #shorts
Tags: programming, javascript, webdev, tutorial
Published: 2022-08-28 07:13:37

## Under the Hood

Hello, and welcome people, if you are new here, this section or publication is more about sharing information in an easier format that is easy to read, grasp, understand and implement.

[To all the freelancer in the world]
(https://www.youtube.com/shorts/M6LtTEYmsqE)

Conclusion
Until next time, have a good day.Keep developing!!
Our website [iHateReading](www.ihatereading.in) || [Youtube](https://www.youtube.com/channel/UC6I-Tz6QwYbJpoIK7l0NtXA) || [Twitter](https://twitter.com/treyvijay)
BUG: iOS Safari renders long digits as telephone link
Published: 2022-08-28 06:51:23

## iOS Safari renders long digits (e.g. 1111111111) as a telephone link that breaks hydration.

To avoid, add `<meta name="format-detection" content="telephone=no">`. Maybe can be a common thing as any dynamic content may run into it.


![hydration image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uy2mgn1qj460xtqdiyn7.jpeg)
1329. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-08-28 05:40:46

```
class Solution {
 public:
  vector<vector<int>> diagonalSort(vector<vector<int>>& mat) {
    const int m = mat.size();
    const int n = mat[0].size();

    unordered_map<int, priority_queue<int>> count;

    for (int i = 0; i < m; ++i)
      for (int j = 0; j < n; ++j) count[i - j].push(mat[i][j]);

    for (int i = m - 1; i >= 0; --i)
      for (int j = n - 1; j >= 0; --j)
        mat[i][j] = count[i - j].top(), count[i - j].pop();

    return mat;
  }
};

```
#leetcode
#challenge
 Here is the link for the problem:
https://leetcode.com/problems/sort-the-matrix-diagonally/
Browser extensions - Modify images on the page
Tags: javascript, webdev, beginners, html
Published: 2022-08-28 05:25:37

This article will examine how we can modify images on the active page.

If you'd like to follow along with the article, use the following [GitHub branch](https://github.com/rebelchris/popup-extension/tree/messaging) as your starting point.

Below is a video of today's article code in action. You can see we replace all images on an IMDB page with kittens.

![Browser extensions - Modify images on the page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3f3yho8bzwsbmwoc3o8j.gif)

## Modify all images on the page

As usual, we must register a new button in our popup menu.
This button will be the invocation for changing all the images on the page. Open up the `src/App.jsx` file and add the following content:

```js
<button onClick={imageSpoof}>Change images</button>
```

We'll need to use the scripting we learned about in the [previous article](https://daily-dev-tips.com/posts/browser-extensions-messaging/) to inject a function on the page.

```js
const imageSpoof = async () => {
  const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
  chrome.scripting.executeScript({
    target: { tabId: tab.id },
    function: spoofImages,
  });
};
```

With this in place, we can create the actual `spoofImages` function we defined.

```js
const spoofImages = () => {
  const images = document.getElementsByTagName('img');
  for (const image of images) {
    image.removeAttribute('srcset');
    image.src = 'http://placekitten.com/300';
  }
};
```

This will replace all images on the page with a kitten placeholder.
I also decided to remove the `srcset` simply because it would take higher priority.

> Note: This will currently place the same kitten image everywhere.

And that's it, and we can now replace images on every website we visit.

You can find the completed code on [GitHub](https://github.com/rebelchris/popup-extension/tree/image-spoof).

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
How to stop having disappointing moments in life
Tags: watercooler, productivity, motivation
Published: 2022-08-28 05:16:07

How many time have you been let down by your expectations?

Seriously, “expecting” anything from anyone is the root cause of disappointment in your life. You start leveling up your hopes in dream of “getting X” but in reality you don’t. Its sad but that’s how life works, its yin-yang remember?

Consider your average common scenario that can occur in everyone’s life:

- Didn’t get the reply from crush?
- Didn’t get that job?
- Didn’t get that promotion?
- Didn’t get that scholarship?

… the list goes on.

Consider a real-life absurd example which recently happened with me, I am a big MCU (Marvel Cenamatic Universe) buff, so I go to every Marvel movie that comes up next.

- A lot of folks are excited about the release of _Spiderman No Way Home_, me on another hand has no expectations from this movie (probably not a big fan). I went to go this movie, and there you go in the first 20 minutes or so Daredevil pops up (I love this character, I would recommend watching the Daredevil TV series on Hotstar to understand why this was a big moment in the movie), nobody knew about this and honestly this moment made the movie 10x for me. No disappointment whatsoever.
- Now consider the release of _Doctor Strange in Multiverse of Madness_, my hopes for this were high because we knew so much could happen in this movie but Marvel decided to go lightweight this time (I mean yes, it was a good storyline) but I was a little “disappointed” thinking a “lot of things” could happen.

I know this is very circumstantial & personal, but I encourage you to have a look at moments from your life on how many times have your felt something similar.

Getting disappointed with something can lead you to demotivation and self-doubt. Now this doesn’t mean to not do anything when expectations are not met. Let’s say you ordered _chicken biryani_ using a food delivery app and if on arrival you don’t see any chicken in biryani then definitely raise a complaint to the app instead of letting it go.

My point is to do things that are in your control. Don’t overload it, Don’t overthink it.

## What to do then?

Now I am not a life-coach but I believe simple changes in your thinking capacity can eliminate disappointment from your life.

- Just give your best effort on things you can control. Whatever the results may be, positive or negative, accept them and move on. And ofc make a mental note on what things to improve on future.
- Another thing that I like to practice nowadays is whenever I start raising my hope levels, I try to ground my thoughts back to reality, Just realising you are thinking to much helps.

Try to adapt a similar practice in your life as well, Say avoid overthinking things like

- _Oh God, If I had this much money I would buy …_
- _If I get my dream job, I would do this and this …_

I hope this helps the reader to atleast ponder over eliminating disappointing thoughts, until next time 👋
Almost time to go live on my MMORPG Empire Of Sight
Tags: blockchain, web3, mmorpg, gamedev
Published: 2022-08-28 04:48:27

Would really love your guys feedback over our trailer and website! Def need other devs to throw in some criticism <3333

https://youtu.be/STs-EEqMcg4

https://www.empireofsight.com/
How and Where to contribute to the ECE Notes Project?
Tags: ece, srmist, btech, github
Published: 2022-08-28 04:13:00

The project is live and open for anyone to contribute to. Ever since the project went live, I’ve made various pieces of information on how anyone can contribute to the project efficiently, but I’ve missed out on where to contribute to!

A contribution request or an issue is as simple as noticing that there are some pieces of the project that are missing or are not in sync with each other.

All that’s needed to be done, is to open an issue in the GitHub project about what’s missing, with the appropriate title and description and someone will have a look at it. This is given that you don’t have the notes currently with you and are in need of it.

For a more detailed approach check out this video.

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

If you have some notes, but don’t know how to contribute using GitHub, you can check out this playlist where I guide you on how to create a fork, upload your notes and open a pull request.

{% embed https://youtube.com/playlist?list=PLevNch38Bx4FTPFRpq9pppJzDsPZs7h2Z %}

If you’re not up to using GitHub, then you can fill out the form below, with the drive links to your notes, and I’ll help you add them to the project from my end.

{% embed https://forms.gle/8mnyZY3X6soUbMQZ8 %}

---

Here are some other articles I've written that you will interested in:

{% embed https://dev.to/kunalkeshan/the-best-collection-of-ece-notes-youll-ever-find-5e5d %}

{% embed https://dev.to/kunalkeshan/should-i-learn-wordpress-or-full-stack-development-23fp %}

---

## Who am I?

I’m Kunal Keshan, currently, a student at SRMIST, KTR, pursuing Electronics and Communication Engineering. I have a passion for Computer Science and Development and have been exploring it for a while now. I’m far from an expert and I’m always eager to learn something new.

Here are my profile links if you’re interested in connecting!

Instagram: https://www.instagram.com/kunalkeshan/
LinkedIn: https://www.linkedin.com/in/kunalkeshan/
Twitter: https://twitter.com/_kunalkeshan_
GitHub: https://github.com/kunalkeshan
Understanding Time Complexity For Beginners
Tags: dsa, timecomplexi, java, algorithms
Published: 2022-08-28 03:02:00

The Basic Definition of time complexity is, In computer science, the time complexity is the computational(_involving the calculation of answers, amounts, results, etc_) complexity that describes the amount of computer time it takes to run an algorithm.

E.g **Consider the below simple code**

`class Demo {
   public static void main(String[] args) {
   System.out.println("Hello There Good Morning");
   }
}`

In the above example the output prints only one time so its time is number 1, in and its denotes by Big Oh of 1 (O(1)) that is constant time, **The above O -> is called Big – Oh which is an asymptotic notation.**

E.g **Consider The Below Simple code**

`class Demo2 {
public static void main(String[] args)
    {
        int i, n = 8;
        for (i = 1; i <= n; i++) {
            System.out.println("Hello Good Evening");
        }
    }
}`
**so the output of the above code is Hello Good Evening will print 8 times in console**
so thats means the time complexity of above code is O(n) where n = 8 and as the value of n can changes according to programmer so thats why its time complexity is O(n).
why do we need 10 minute mail?
Published: 2022-08-28 02:29:24

**Why do you need anonymous [10 minutes mail](https://email10min.com/),[free temp mail](https://email10min.net/)?**

To download different programs, take advantage of certain websites, make new friends, and gain confidence in the network, you need an email. But who guarantee that your data won't fall into the hacker's hands? We made the right decision to protect your privacy - a [disposable email](https://email10min.com/) address. Emails created by our service will be automatically deleted 10 minutes after being generated. You can create unlimited new accounts, getting activation keys and other things that require an email address. By using 10 Minute Mail, you will remain anonymous. IP-addresses and other personal data will be permanently destroyed and no one will be able to trace the true owner of the mailbox. All inbox messages will also be deleted by the service. You don't have to pay anything for this great tool that helps get letters anonymously. All you need is to generate a free email address.

If you need to register some websites (only email verification is required), but there is no guarantee for the security of some unknown websites. The following security issues may occur when registering with a real email address:

1) Personal passwords are leaked,especially our friends who use one password for multiple accounts.

2) Disclosure of personal information.

3) Subject to spam attacks.

**4 "10 minute mail" websites:**

1 10 minutes mail,refresh to get more time https://email10min.com/

2 10 minutes mail https://www.mailtemp.net/

3 10 minutes mail https://email10min.net/

4 10 minutes mail https://tenminutesmail.net/
AWS EC2 Tutorial — Running a Node.JS Application the Easy Way
Tags: aws, node
Published: 2022-08-28 01:34:01

In this article i will guide you to run your nodejs application in AWS EC2 Instance

article link: https://aravindkumarvemula.medium.com/aws-ec2-tutorial-running-a-node-js-application-the-easy-way-2b179b6e9d0