teleren/devto huggingface dataset:
Minima, Mastodon, and rel="me"
Tags: webdev, socialmedia
Published: 2022-11-06 08:26:06

In this short article I noted down what I needed to do in order to get the `rel="me"` attribute on my *Minima* themed Jekyll homepage.

Since quite a few years you can add the usernames of your social media accounts to your *_config.yml* file. This is also true for Mastodon. However, current Minima releases seem to not include the `rel="me"` attribute - which would be desiderable because then your website gets the green checkmark.

![A verified homepage on Mastodon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb6532mqwo99bhyg57go.png)

So, let's investigate. The current Minima 2.x release is 2.5.1 from August 2019.

![Screenshot if the Minima project on GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e0gblu1bjx028062p5ui.png)

Now let's check the history of *social.html* file (this file includes the social media links). 


![Screenshot of a part of social.html](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hp7kazw5ygeybe9zag5x.png)

So, the corresponding code is already on GitHub. Here's how to use it.

1. Download the latest version of *social.html*. You'll find it [here](https://github.com/jekyll/minima/blob/master/_includes/social.html)

2. In your Yekyll project, create an *_includes* folder and put *social.html* there. Please note that I also have a local version of *footer.html* because I wanted to apply changes there, too. But you don't need it for the `rel="me"` attribute.

    ![Screenshot showing the _includes folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wlc2q3thnzmnowktj3e.png)

3. Make sure to update your *_config.yml* file

    ```yml
    title: "Thomas K\u00fcnneth"
    email: thomas@thomaskuenneth.eu
    description: >- # this means to ignore newlines until "baseurl:"
      Developer. Speaker. Listener. Loves writing. 
      Confessing mobile computing addict
    baseurl: "" # the subpath of your site, e.g. /blog
    url: "https://www.thomaskuenneth.eu"
    author:
      email: thomas@thomaskuenneth.eu
      name: "Thomas K\u00fcnneth"

    minima:
      social_links:
        twitter: tkuenneth
        github: tkuenneth
        mastodon:
          - username: tkuenneth
            instance: snapp.social
    ```

That's it.
Building Immersive Communities in public - What do you want to see next?
Tags: programming, devops, community, webdev
Published: 2022-11-06 07:57:19

I've taken into account some of the feedback I got recently and gave Immersive Communities a facelift. From now on, I'll start adding new features based on what the public wants to see next. :)

Feel free to let me know what would you like to see next and what feature would convince you to start using Immersive Communities to build your own community?

Things I've done last week on https://immersive.community

- You can now access the articles from the homepage.

- Increased the font size of the article title, so its easier to read.

- Added a preview of the article text under the title so the readers will get a gist of what the article is about without needing to click on it.

- Community banner replaced with a small logo and a title.
CSHARP (C#) ..OLD AND OUTDATED??
Tags: programming, csharp, dotnet, news
Published: 2022-11-06 07:49:28


CSHARP (C#) - OLD AND OUTDATED???

For a language created to rival Java cross platform capabilities and functions ,with it modern , innovative and object oriented programming approach . Since It's inception and  creation by Microsoft in 2002 ,C# has witnessed immense growth . Created for Windows application but it continued development of it value types , properties ,events , OOP functionalities and also noticeably the advent of Lambda expressions explains why it is a great general purpose programming language to get your hands on . If you have any experience in Java , JavaScript ,C and C++ ,then C# syntax and principles won't be any hard to comprehend..

But why learn C# and what can you build with it???

- Native Mobile applications (with Xamarin)
-Distributed and cloud application (with Azure)
-AI applications (ML.NET)
-Games using Unity
- Desktop applications (Windows forms ,WPF)

With the likes of Slack, the World Bank and Cinemark written with C# and Microsoft Office , Visual Studio , SQL server being windows application built with thesame programming language tells how powerful the C# language is becoming.

Having stated this with it potential growing immensely everyday ,alongside being  ranked   5th  on the TIOBE index for July 2021 ,and  also taking the 4th position at PYPL Index ( Popularity of Programming Language Index) . Though they are still doubts C# only favours windows application but remains one of the prominent language with one great potential . Learning C# is an amazing step into an amazing tech world to learn ,earn and gain some basic and fundamental programming experience ,This actually debunks the claim it is outdated in the modern day, given the stats given above.

Just like a famous Saying:

"Programming languages are like wine ,some turn into Vinegar , but the best improve with age."

The development done over two decades on C# makes it one to look out for now and in  future . 


© Jalalgorithm
Most Common Word
Tags: leetcode, python
Published: 2022-11-06 07:32:13

Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique.

The words in paragraph are case-insensitive and the answer should be returned in lowercase.



```py

import re

class Solution:
    def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
        #List words in paragraph, replacing punctuation with ' ' and all lower case
        paragraph = re.subn("[.,!?;']", ' ', paragraph.lower())[0].split(' ')
        
        #Remove any '' or words in banned from paragraph list
        paragraph = list(filter(lambda x: x not in banned + [''], paragraph))
        
        #Return most common word in filtered list
        return Counter(paragraph).most_common(1)[0][0]
    
    
    

```
How to Add Custom CSS in Elementor Free
Tags: elementor, css, wordpress
Published: 2022-11-06 07:19:28

In the [previous article](https://dev.to/sunawang/how-to-use-css-selector-in-elementor-4m1p), I have covered how to find and use a widget selector in Elementor. A widget selector itself is used to target a specific Elementor widget to apply a custom CSS to.

Naturally, you need to use the pro version of Elementor to add custom CSS. Even so, you still be able to add a custom CSS if you use Elementor Free although the process is not as smooth as on Elementor Pro.

To add a custom CSS in Elementor Free, you need to use both class selector and ID selector.

## Adding Custom CSS in Elementor Free

First, let's recall again that each Elementor widget has a unique class selector. So logically, you can use the selector to target a widget you want to apply the custom CSS to. About the CSS code placement itself, you can place it to the **Additional CSS** block on theme customizer (**Appearance -> Customize**) or the _style.css_ of your theme.

However, if you only use the class selector to target the widget, the CSS code will apply to the entire site.

Let's take an example.

Say you want to add a gradient effect to a Button widget via custom CSS (whereby the selector of the Button widget `.elementor-button`). If you type the following code to the **Additional CSS** block on the theme customizer, the code will apply to all the Button widgets on your website -- including the ones already added to a page.

`.elementor-button {
  background: linear-gradient(to left, #f4e784, #f24389,#a478f1); 
}`

In addition, the code will also apply to the Button widgets on a pre-made template in case you want to insert one of the premade templates from the template library.

If you want the code above to apply to a specific Button widget, you can add an ID selector. So, the code would be:

`#pastel-gradient .elementor-button {
  background: linear-gradient(to left, #f4e784, #f24389,#a478f1); 
}`

`#pastel-gradient` is the ID selector for the CSS code above.

After updating the code, you need to add the CSS ID to the Button widget you want to apply the CSS code to. Go to the **Advanced** tab on the settings panel and paste the CSS ID to the CSS ID field.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8aa7rjkh6wh6vqaunax.png)
Minimum Hours of Training to Win a Competition
Tags: javascript, leetcode
Published: 2022-11-06 06:16:48

[Minimum Hours of Training to Win a Competition](https://leetcode.com/problems/minimum-hours-of-training-to-win-a-competition/)

```js
/**
 * @param {number} initialEnergy
 * @param {number} initialExperience
 * @param {number[]} energy
 * @param {number[]} experience
 * @return {number}
 */
var minNumberOfHours = function(initialEnergy, initialExperience, energy, experience) {
      let extraEnergyNeeded = 0;
  let extraExpNeeded = 0;
  let totalExp = initialExperience;
  let totalEnergyNeeded = energy.reduce((acc, i) => acc + i, 0);
  if (totalEnergyNeeded >= initialEnergy) {
    extraEnergyNeeded = totalEnergyNeeded - initialEnergy + 1;
  }
  let index = 0;

  while (index < experience.length) {
    if (totalExp > experience[index]) {
      totalExp = totalExp + experience[index];
      index++;
    } else {
      extraExpNeeded++;
      totalExp++;
    }
  }
  return extraEnergyNeeded + extraExpNeeded;
};
```
Everything about Ethereum Blockchain
Tags: blockchain, web3, ethereum
Published: 2022-11-06 06:04:52

I am writing this article in question and answer format. Please do feel free to leave feedback and I will make necessary changes accordingly.

Let's dive in.

## What is Etherium?

It's a Blockchain used to create smart contracts. 

To understand this better we need to understand this two terms 
1. Blockchain
2. smart contract

## What is Blockchain?

Blockchain is a ledger(database) residing on decentralised peer-to-peer network.

Unlike traditional databases these database resides on multiple systems called as nodes(more on this later). This database is more secure and any transaction done on this can not be reverted.

Since this is residing on multiple systems it is called decentralised.

Once any change is made to this database it will be propagated to all the nodes maintaining this database in peer-to-peer manner.

## What is Peer-to-Peer network (P2P)?

In p2p, interconnected nodes ("peers") share resources amongst each other without the use of a centralised administrative system. Torrent is an example application for P2P network.

## Why should we go for P2P network?

Suppose we have to transfer 100GB file to 1000 systems. For one system with 10gbps throughput(speed), let's calculate the time to transfer this file.

File size is 100GB i.e 800 giga bits (8bits per byte)

Throughput is 10gbps i.e 10 giga bits per one second. 

To transfer the file to one system it takes 80 seconds.

To transfer to 1000 systems it takes 80000 seconds (22hours approximate)

This can be drastically improved by using P2P network. Let’s see how.

Suppose let's say we have five systems named A, B, C, D and E. All these systems are inter connected to each other as shown below
![P2P Network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dg6dr3yjoe5fiale9mto.png)
> This way of connecting the systems is called Mesh topology
 
Let's calculate the amount of data transferred for every second

**1st Second**
A -> B 10gb

Total: 10gb 

**2nd Second**
A -> B 10gb 
B -> C 10gb

Total: 20gb 

**3rd Second**
A -> B 10gb 
B -> C 10gb 
C -> D 10gb

Total: 30gb
  
**4th Second**
A -> B 10gb 
B -> C 10gb 
C -> D 10gb 
D -> E 10gb 

Total: 40gb 

**5th Second**
A -> B 10gb 
B -> C 10gb 
C -> D 10gb 
D -> E 10gb

Total: 40gb 

From 4th second maximum data that can be transferred in one second is 40gb since we have only five systems in the network.

So it took four seconds to reach the maximum potential of the network.

Let's do the same math for previous example

It requires 999 seconds to reach the maximum network potential.

Amount of data transferred in 999 seconds is

1 + 2 + 3 + 4 + --- +999

This can be calculated using the formula

{% katex %} \frac{n*(n+1)}{2} = \frac{999 * 1000}{2} = 499500 {% endkatex %}
How to seperate number with commas in Javascript
Tags: javascript, html, webdev, beginners
Published: 2022-11-06 05:48:30

When working with numbers in Javascript, you may need to format them to make them more readable.  
  
 You can convert a number value to a comma-separated string. Here are two approaches: 
 - [using toLocaleString()](#using-tolocalestring) 
 - [using Regex](#using-regex) 
 - [Conclusion](#conclusion) 
  
  
### using toLocaleString() 
 The `toLocalString()` is a default built-in browser method of the `Number` object that returns the number (in string) representing the locale. 
  
 You can pass any [locale](https://links.dhairyashah.dev/2225269751) inside the parantheses as a parameter. 
 ```js 
  const number = 14500240 
  const formatedNumber = number.toLocaleString("en-IN") 
  console.log(formatedNumber) 
   
 ``` 
  
### using Regex 
 ```js 
 function numberWithCommas(num) { 
   return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); 
 } 
  
 const number = numberWithCommas(234234.555); 
 console.log(number); 
 ``` 
  
### Conclusion 
 After reading this article, you'll be able to use either of these two techniques to format numbers in Javascript: 
  - [using toLocaleString()](#using-tolocalestring) 
  - [using Regex](#using-regex) 
  
 Thanks for reading!
Migrate from render to Supabase
Published: 2022-11-06 05:35:14

I used PostgreSQL from render.com and I paid $7 per month for Starter plan.
This DB was for own project.
There was no revenue and It was in the red.

So, I migrate from render to Supabase.
Because Supabase's free plan was sufficient.
Nothing was difficult, it was simple.

1. Execute pg_dump in redner's DB
Execute the following code on the command line
`pg_dump --clean --if-exists --quote-all-identifiers \
 -h $RENDER_HOST -U $RENDER_USER -d $RENDER_DATABASE \
 --no-owner --no-privileges > render_dump.sql`

2. Import dump files into Supabase's DB
Execute the following code on the command line
`psql -h $SUPABASE_HOST -U postgres -f redner_dump.sql`

3. Change the Web Application's DB URI to that of Supabase
The URI of Supabase can be found in
"Project Settings" → "Database" → "Connection string".
Verifying my OpenPGP key
Published: 2022-11-06 05:13:26

This is an OpenPGP proof that connects my OpenPGP key to this dev.to account.

For details check out https://docs.keyoxide.org/advanced/openpgp-proofs/

[Verifying my OpenPGP key: openpgp4fpr:74b07ae5ffb55bfc2fb8b25e8dbe5f9a6519d396]
How to Choose the Best Professional Cleaners for Your Home or Office
Tags: cleaner, cleaning
Published: 2022-11-06 05:00:50

**How to Choose the Best Professional Cleaners for Your Home or Office**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0mv82a63qvtbazjhan72.jpg)
Lately people are striving for the best possible living experience and are investing great sums of money in their homes or offices. Having a clean and healthy environment is one of the keys to this experience.

So why not use your hard-earned money to get some [professional cleaners](https://www.localexpertcleaning.co.uk/biohazard-cleaning-birmingham/)? They might be expensive at first, but think about all the money you save on groceries and dry cleaning.

There are three factors that you should consider when choosing a professional cleaner:

-Their rates and prices. Sometimes the cheapest cleaner is not the best one.


- The quality of their work. You want a cleaner that is professional and pays attention to detail.

 The length of their references. You want a cleaner that has been in business for a while, not just one or two years.In choosing the best professional cleaner, you should consider the following:-

The rates and prices: Some cleaners will charge more per hour than others for the same type of cleaning. It is beneficial to find out how much other people have paid for this service so you know what your best option is.-

The reputation of the company: This includes reviews from past customers, as well as professional and personal referrals. Additionally, you can look up the provider's licenses to find out if they are in good standing with the relevant authorities.-

The type of service that the company offers: Some companies offer services such as carpet cleaning or tile cleaning; others offer more specialized services such as drain cleaning or oven cleaning. If a cleaner offers a wide range of options for jobs, their prices may be lower than a company that offers more specific services.-

The type of materials a cleaner will use. For example, some cleaners use water and detergents while others use chemicals- The hours of operation: Some cleaners may offer extended hours such as 24/7 while others may offer fewer hours that make it difficult to get the job done at a certain time.

 The company's location is also important to note, as those in residential areas or neighborhoods may charge less than those in commercial areas.-How long the service has been around: A company with a longer history and more experience may be worth the investment of your time and money.
Change the DB as you wish | Repository Pattern 📦
Tags: javascript, typescript, database, codequality
Published: 2022-11-06 04:54:58

# 📦 Repository Pattern

This is a practical and real-life example of how to use the `Repository Pattern` with `Dependency Injection` to manipulate with the database like a **PRO**. 😎

## What is a Repository Pattern? 🤔

Repositories are `classes` or `components` that encapsulate the logic needed to access data sources. They centralize common data access functionality, providing better maintainability and decoupling the infrastructure or technology used to access databases. This allows us to change the Database used at any time, either from a `MySQL` to a `MongoDB` without further complexity.

![Repository Patteern Diagram UML](https://user-images.githubusercontent.com/64434514/200150833-2a0d4d65-b176-4556-ace7-e05ff067911f.png)

As you have to visualize `Repository` corresponds to the interface, that is, the contract that the specific implementations have to fulfill. In this case `MongoRepository`, `MySQLRepository`, `PostgreRepository`.

> **Note**: Whenever we want to add a new implementation (another database) we must implement this interface.

## What is a Dependency Injection? 💉

Dependency Injection allows objects to be supplied to a class instead of the class itself creating those objects. These objects fulfill contracts ([Interfaces](https://www.typescriptlang.org/docs/handbook/typescript-tooling-in-5-minutes.html#interfaces)) that our classes need in order to function.

![Dependencies Injection](https://user-images.githubusercontent.com/64434514/200151676-40359e1c-4237-43d6-a70e-406c387fd681.png)

**Define our interface**.

```ts
// Define our interfaces/contract
interface Repository<T = any> {
  create(data: T, query?: Query): Promise<T>
  // Other methods...
}
```

**Define our implementations**.

```ts
class MongoRepository implements Repository {
  async create(data: any, query?: Query): Promise<any> {
    // Do something...
  }
}

class MySQLRepository implements Repository {
  async create(data: any, query?: Query): Promise<any> {
    // Do something...
  }
}
```

**Define our client**.

```ts
class Controller {
  constructor (repository: Repository) {}
}

// Using MongoDB 🍃
new Controller(new MongoRepository())

// Using MySQL 🐬
new Controller(new MySQLRepository())
```

As you may have noticed, in this way we can change the database quite easily, since our `Controller` client does not depend on its specific implementations, but on a `Repository` interface.

## Follow me ❤️

- 🐦 [Twitter](https://twitter.com/thebug404)
- 🐙 [Github](https://github.com/thebug404)
899. Leetcode Solution in Python3
Tags: challenge, python, chiki1601
Published: 2022-11-06 04:44:47

```python
class Solution:
  def orderlyQueue(self, S: str, K: int) -> str:
    return ''.join(sorted(S)) if K > 1 else min(S[i:] + S[:i] for i in range(len(S)))

```

#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/orderly-queue/description/
Kotlin 基礎 Part 6 -- ブロック内部でスコープ関数を使って処理する
Tags: kotlin
Published: 2022-11-06 04:39:00


## why

ブロック処理は Kotlin の基礎であり、必須だと気づいたから

---

## 参考

https://www.amazon.co.jp/gp/product/B091PGXHJY/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Kotlin サーバーサイドプログラミング実践開発

Page 100 of 495

https://www.digitalocean.com/community/tutorials/kotlin-let-run-also-apply-with

Digital Ocean 
// Tutorial //
Kotlin let, run, also, apply, with

---

# 5 つのスコープ関数

with
run
let
apply
also 

これらの 5 つのスコープ関数が有る。

これは関数やインスタンスに追加したり、引数として取ることで拡張できる。

---

## let

https://blog.mindorks.com/using-scoped-functions-in-kotlin-let-run-with-also-apply

一番シンプル。関数に追加すると、その関数の結果を it として扱えるブロックを作成できる。

```kotlin
	fun get1(): Int{
		return 1
	}
	val letTest = get1().let { it + 1 }
	println(letTest)

```

> 2

ここでは 1 を返す関数に let をつけたので
it が 1 として扱われ、1 + 1 で 2 が返ってくる。

前の記事に書いたように、?.let を使うことで null ではない場合のみ実行できる。これによって nullable な値もぬるぽの心配なく安全に扱える。

---

## run 

run では it ではなく this で元の関数の返り値が扱える。

```kotlin
	fun get1(): Int{
		return 1
	}
	get1().run { println(this+1)}
```

> 2

```kotlin
	fun get1OrNull(): Int?{
		return null
	}
	get1OrNull()?.run { println(this+1) }
```

こちらも Null 安全な実行ができる。

---

## with

```kotlin
	fun get1(): Int{
		return 1
	}
	val withTest = with(get1()) { this + 1 }
	println(withTest)
```

> 2

with は引数で関数の結果をレシーバーとして受け取る。
そして次のブロックで this として扱い処理し、返り値とする。

どうみても run の方が使いやすい。

---

## apply

```kotlin
	fun get1(): Int{
		return 1
	}
	val applyTest = get1().apply { this + 1 }
	println(applyTest)
```

> 1

apply はブロックの結果を返さない。
let や with とはそこが違う。

apply を当てた関数が返って来ている。

```kotlin
	data class Dog(var name: String)
	val pochi = Dog("Pochi")
	val applyTest = pochi.apply { this.name = "Hachi" }
	println(applyTest)
```

> Dog(name=Hachi)

しかし、レシーバーで apply 元のインスタンスのプロパティなどを変更した新しいインスタンスを作成できる。

name プロパティを Pochi として作成した Dog のインスタンスを
apply を使って name プロパティを Hachi に変更した新しいインスタンスを作成することができた。

---

## also 

also も apply と同じく本体を返す。
apply と違っていくつでもつなげていくことができる。

also では it を使う。

```kotlin
	data class Dog(var name: String, var age: Int)
	val pochi = Dog("D",3)
	val alsoTest = pochi.also { it.name = "E" } .also { it.age = 10 }
	println(alsoTest)
```

> Dog(name=E, age=10)

Dog クラスから pochi というインスタンスを作って
also でインスタンスの中身にアクセスして、name と age を変えられた。

```kotlin
	val alsoTest = pochi.also { dog ->
		dog.name = "E"
	}
```

let と同じく、it に名前をつけて扱うこともできる。