teleren/devto huggingface dataset:
Managing Postgres extensions
Tags: edb, database, postgres, functions
Published: 2023-10-25 09:31:35

Big Animal supports many Postgres extensions. Some of the extensions can be viewed over [here](https://www.enterprisedb.com/docs/pg_extensions/)

## Extensions in BigAnimal:
Extensions are available when you use your cloud account.
Installing Postgres extensions requires superuser privileges.
If you use your cloud account you can grant superuser privileges to edb_admin so that you can install these extensions on your cluster.

## List of extensions:
A list of extensions that can be installed using your cloud account is given below:
- auth_delay
- bloom
- btree_gin (PostgreSQL v12 only)
- btree_gist (PostgreSQL v12 only)
- citext (PostgreSQL v12 only)
- cube (PostgreSQL v12 only)
- earthdistance
- fuzzystrmatch
- hstore (PostgreSQL v12 only)
- hstore_plperl
- intagg
- intarray (PostgreSQL v12 only)
- isn (PostgreSQL v12 only)
- jsonb_plperl (PostgreSQL v12 only)
- ltree (PostgreSQL v12 only)
- old_snapshot (PostgreSQL and EDB Postgres Advanced Server v14 and v15 only)
- pageinspect
- pg_buffercache
- pg_freespacemap
- pg_prewarm
- pg_stat_statements
- pg_surgery (PostgreSQL and EDB Postgres Advanced Server v14 and v15 only)
- pg_trgm (PostgreSQL v12 and EDB Postgres Advanced Server v15 only)
- pg_visibility
- pgaudit (PostgreSQL only)
- pgcrypto (PostgreSQL v12 only)
- pglogical3 (PostgreSQL v12 and v13 only)
- pgrowlocks
- pgstattupple
- postgres_fdw
- seg (PostgreSQL v12 only)
- sslinfo
- tablefunc (PostgreSQL v12 only)
- tcn (PostgreSQL v12 only)
- tsm_system_rows (PostgreSQL v12 only)
- tsm_system_time (PostgreSQL v12 only)
- unaccent (PostgreSQL v12 only)
- uuid-ossp (PostgreSQL v12 only)
- xml2
- spi - autoinc
- spi - refint
- spi - insert_username
- spi - moddatetime

## Installing extensions:
Use the create_extension command to install extensions. You can enable edb_pg_tuner on the DB configuration tab of the Create or Edit Cluster page of the big animal portal. The following example shows how you can install multiple extensions simultaneously.
### Step 1:
Create a text file containing the create extension command for each of the extensions you want to install. In this example, the file is named createExtension.sql

```
CREATE EXTENSION <extension_name_1> SCHEMA <schema_name>;
CREATE EXTENSION <extension_name_2> SCHEMA <schema_name>;
CREATE EXTENSION <extension_name_3> SCHEMA <schema_name>;
CREATE EXTENSION <extension_name_4> SCHEMA <schema_name>;
```
### Step 2:
Use your Postgres client of choice to load the extensions.
```
psql <biganimal_connection_string> -f createExtension.sql
```

## Removing Extensions:
You can remove extensions using _Drop Extensions_ command. 

## Retrieving list of extensions:
You can view the list of all Postgres extensions using _pg_available_extension_

## Pg extension catalog:
The *Catalog_pg_extension* catalog stores all the information about the installed extensions. 


## References:

1. https://www.enterprisedb.com/docs/biganimal/latest/using_cluster/extensions/
2. https://www.postgresql.org/docs/
25 Years of IT Marvels: Milestones that Transformed the Industry! 🌟🖥️
Tags: webdev, development
Published: 2023-10-25 09:24:21

*The last quarter-century has been a monument to human ingenuity and the never-ending quest of innovation, as the #IT sector has evolved into a global powerhouse! 💡🚀 *

💻 **The Dawn of a New Era **
In the late '90s, the IT landscape underwent a seismic shift. The emergence of the World Wide Web in 1991 and the widespread adoption of personal computers set the stage for a #digital revolution that would shape the course of history. 🌐💻 

🚀 **The Rise of Tech Titans **
As the new millennium dawned, #tech behemoths emerged as titans in the industry. Microsoft's Windows XP, released in 2001, became an operating system standard, while Google's search engine dominance revolutionized how we navigate the web. Apple, with its sleek Mac OS X, captured hearts and minds. 🪶🌍 

📱 **The #Mobile Revolution **
Then, in 2007, came a seismic event: the release of the first iPhone. This iconic device revolutionized mobile technology, setting off a race to develop sleek, powerful devices that could fit in the palm of our hands. 🚀 The subsequent years witnessed an explosion of applications. From the launch of Apple's App Store in 2008, which featured a mere 500 apps, to today's staggering diversity of applications numbering in the millions, the digital landscape transformed into an ecosystem of endless possibilities. 📲🎉

👨‍💻 **The #Developer Dilemma **
As the industry burgeoned, so did the demand for skilled developers. The pursuit of qualified talent became a challenge in itself, and a gap emerged between the need for expertise and its availability. 💼 

**Devler: Bridging the Gap** 🌉👷 
In response to this challenge, Devler.io emerged as a groundbreaking #platform in 2021.This innovative space matches Top European Developers with clients from all over the world, fostering a dynamic global #community of technological excellence. Businesses around the world gain access to a curated pool of top-tier #talent, while developers find unparalleled opportunities to showcase their #expertise on a truly international stage. 🌐🌍 

🚀🔮 Invest in the future of your project - hire a team of developers on the [Devler.io](http://Devler.io) platform🌟💪
Explaining A/B testing algorithm
Tags: algorithms, development, go
Published: 2023-10-25 09:16:16

We are developing a crypto news aggregator [Bitesapp.co](https://bitesapp.co?utm_source=dev). A few days ago, we implemented A/B testing tool to test different scenarios for delivering news to users.

In this article, I will explain the A/B testing algorithm in the simplest possible way.

## Main concepts
**Inputs**
- User attributes (such as user_id, email, device_id,...)
- Experiments
- Weight for each experiment

**Requirements**
- The experiment variant must always be the same with a set of input attributes
- The user's probability of participating in the experiment is relative to the weight of the experiments (the higher the weight, the more users will be assigned to this experiment).


## Idea
This algorithm shares some similarities with the Weighted Random algorithm I explained in the previous article ([Link](https://dev.to/jacktt/understanding-the-weighted-random-algorithm-581p)).

To better understand this algorithm, let's imagine it as a space where each region represents the weight of an element. This space is analogous to a line, and the length of each segment on this line corresponds to the weight of an Experiment. If you throw a stone into this space, the probability of the stone landing in a specific area is directly proportional to the weight of that segment, regardless of the order of areas

In the `Weighted Random algorithm`, we likened the process to randomly throwing the stone. However, in the A/B testing algorithm, we need to find a way to consistently land in the same area for the same user with specific attributes.

## Implemenation
We will implement the above idea by the following steps:
- Scale the weights to a specific range, corresponding to fitting the areas into a specific space. The sum of the output weights will be equal to the maxScale.
- Hash the input attributes to a number between 1 and maxScale.
- Determine the area which this hashing value belongs.

#### 1/ Scale the weights to a specific range
```go
// golang
func scaleWeights(weights []float32, maxScale int) []float32 {
	var total float32 = 0.0
	for _, weight := range weights {
		total += weight
	}
	for i, weight := range weights {
		weights[i] = weight / total * float32(maxScale)
	}
	return weights
}
```

#### 2/ Hash the input attributes to a number between 1 and maxScale

```go
func hash(userID string, maxScale int) (int, error) {
	h := fnv.New32a()
	if _, err := h.Write([]byte(userID)); err != nil {
		return 0, err
	}
	hashValue := int(h.Sum32())
	return hashValue % maxScale + 1 , nil
}
```
To return the value between 1 and maxScale, we take a modulus for maxScale.

This is why we scale the weights into maxScale.

### 3/ Determine the area which this hashing value belongs

```go 
func getExperimentIndex(weights []float32, maxScale int, hashValue int) int {
	weights = scaleWeights(weights, maxScale)
	var cursor float32 = 0
	for i, weight := range weights {
		cursor += weight
		if cursor >= float32(hashValue) {
			return i
		}
	}
	return -1
}
```
SvelteKit + supabase 세션 만료 처리
Tags: sveltekit, supabase, session
Published: 2023-10-25 09:14:16

supabase 라이브러리에서는 https://supabase.com/docs/reference/javascript/auth-exchangecodeforsession 이런 식으로 `auth가 변경됐다`라는 것을 받을 수만 있다. 
그래서인지 탭을 계속 열어놓은 상태거나 심지어 pc를 종료하고 며칠 후에 켜도 자동으로 세션을 업데이트 해버린다. 

다행히 Svelte를 좀 아는 분의 도움을 받아서 브라우저가 종료됐을 때는 처리가 됐으나 여전히 탭을 계속 열어놓은 상태에서는 세션이 유지된다. 보통의 사이트처럼 `세션이 만료 됐습니다. 다시 로그인하세요` 같은 걸 띄워야 하는데... 

이리저리 찾아봐도 딱히 방법이 없는 것 같아서 원시적인 방법으로 처리하기로 했다. 

```js
// app.d.ts
declare global {
  namespace App {
    interface Locals {
      sb: SupabaseClient;
      getSession(): Promise<Session | null>;
      user_last_activity_at: Date | null;
      ...
    }
  }
}
```

```js
// hooks.server.js
import { DateTime } from "luxon";

export const handle = async ({ event, resolve }) => {
  event.locals.user_last_activity_at = DateTime.now().toISO();
  ...
}
```

hooks.server.js 는 화면이 호출될 때마다 호출이 되기 때문에 여기서 마지막 활동 시간을 저장한다.



```js
// +layout.server.js
return {
  user_last_activity_at: locals.user_last_activity_at,
  ...
}
```

```js
// +layout.js
return {
  user_last_activity_at: data.user_last_activity_at,
  ...
}
```
  
```js
// +layout.svelte
<script>
  import { beforeUpdate } from "svelte";
  import { goto } from "$app/navigation";
  import { DateTime } from "luxon";
  
  export let data;
  $: ({ supabase, session } = data);

  let wasCallGoToLogin = false; // beforeUpdate가 여러 번 호출돼서 회피용

  beforeUpdate(async () => {
    const userLastActivityMinute = DateTime.fromISO(data.user_last_activity_at).diffNow("minutes").minutes;
    // 마지막 활동이 30분 이상 지났을 경우 로그아웃 시킨다.
    if (!wasCallGoToLogin && $page.route.id != "/login" && userLastActivityMinute < -30) {
      alert("로그인이 만료되었습니다. 다시 로그인해주세요.");
      wasCallGoToLogin = true;
      await supabase.auth.signOut();
      goto("/login");
    }
  });
</script>
```

SvelteKit은 기본 설정이 `data-sveltekit-preload-data="hover"`라서 링크에 마우스 커서만 올려도 백그라운드에서 호출을 해버린다. 그래서 다른 걸 하기 전에 세션 만료 처리를 할 수 있다. 

다만 여전히 문제는 있는데, 작성에 30분 이상 걸리면 저장하기 전에 로그인이 종료된다. 사용자들이 잘 알아서 써주겠지...
Difference between == and === in JavaScript
Tags: webdev, javascript, programming, productivity
Published: 2023-10-25 09:12:24

Hello, Dev.to community! As we traverse the realm of JavaScript, we often come across two seemingly similar comparison operators: == (loose equality) and === (strict equality). While they appear to be twins, they differ in some fundamental ways. Let's dive in to uncover the differences.

## Loose Equality (`==`)
The **`==`** operator checks for equality after performing any necessary type conversions. This means it will try to convert the values being compared to a common type before making the comparison.

**Examples:**

```
"5" == 5  // true, because the string "5" is being type-coerced to the number 5
null == undefined  // true, because null and undefined are considered equivalent
false == 0  // true, because false is type-coerced to 0
```

## Pitfalls:
Due to type coercion, unexpected results can arise:

```
"" == 0  // true
" \t\r\n" == 0  // true
```

## Strict Equality (`===`)
The **`===`** operator, also known as the identity or strict equality operator, checks for equality without performing type conversion. If the values being compared have different types, the comparison will always return false.

**Examples:**

```
"5" === 5  // false, no type coercion is performed
null === undefined  // false, they are of different types
false === 0  // false, different types
```

## Sorry for interruption :- 
follow  US on WhatsApp For regular updates - [WhatsApp ScriptSquad ](https://www.whatsapp.com/channel/0029Va61UMd6BIEnLZAppO0L)
YouTube Channel - [ScriptSquad 01](https://www.youtube.com/@AlgorithmAtlas/featured)


## Advantages:
Using **`===`** can prevent unexpected results due to type coercion, making it a safer choice for most comparisons in JavaScript.

## Which One to Use?
If you're certain about the types of variables you're comparing and want to allow type coercion, **`==`** might be acceptable.

However, in most scenarios, it's recommended to use **`===`** to avoid unforeseen results caused by type coercion.

## Conclusion
Understanding the difference between **`==`** and **`===`** in JavaScript is vital for writing predictable and bug-free code. As a best practice, lean towards using **`===`** for your comparisons unless there's a specific reason to allow type coercion.

Happy coding!
I've been making dev comics for years. Here are some!
Tags: programming, development, softwaredevelopment, watercooler
Published: 2023-10-25 09:01:23

I just joined the community and this is my first post!

I've been a software dev for more than a decade and I started drawing comics when the COVID started. I decided that for my first post, I'll be sharing a few ones. Some were shared a lot. Some fell flat. Hope you'll enjoy them!

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

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

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

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

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

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

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

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

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

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

You can find them all on my website: [https://vincentdnl.com/drawings](https://vincentdnl.com/drawings)

Hope you enjoyed these comics, see you around!
Luyện thi toeic online
Published: 2023-10-25 09:01:02


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1r786jho1tkhiqq46px.png)📣 Thông báo quan trọng cho các bạn muốn nâng cao điểm TOEIC của mình! 🎉

🌟 Chúng tôi xin giới thiệu đến các bạn khóa học ""Luyện thi TOEIC online tại Anhle Toeic"" - giải pháp hoàn hảo để bạn đạt được kết quả cao trong kỳ thi TOEIC sắp tới.

📚 Khóa học của chúng tôi được thiết kế bởi đội ngũ giảng viên giàu kinh nghiệm, sẽ giúp bạn cải thiện cả 4 kỹ năng ngôn ngữ: Nghe, Đọc, Nói và Viết. Chúng tôi cam kết mang đến cho bạn những bài học chất lượng và phương pháp học hiệu quả.

💻 Với hình thức học online linh hoạt, bạn có thể học bất kỳ lúc nào và ở bất kỳ đâu. Không còn giới hạn về thời gian và không gian, bạn có thể tiếp cận kiến thức và rèn luyện theo tốc độ của riêng mình.

🔑 Hãy chuẩn bị cho mình một chứng chỉ TOEIC với điểm số ấn tượng, mở ra cơ hội nghề nghiệp mới và nâng cao sự tự tin trong giao tiếp tiếng Anh.

⏰ Đừng chần chừ nữa! Hãy truy cập ngay website của chúng tôi hoặc liên hệ với chúng tôi để biết thêm thông tin chi tiết về khóa học ""Luyện thi TOEIC online tại Anhle Toeic"".

📞 Số điện thoại: 0967403648
🌐 Website: [https://anhletoeic.com/khoa-hoc/toeic-online](https://anhletoeic.com/khoa-hoc/toeic-online)

📢 Hãy chia sẻ thông tin này với bạn bè và người thân của bạn để cùng nhau đạt được mục tiêu TOEIC thành công! 💪

#TOEIC #luyệnthitoeic #anhletoeic #họconline #chungchitoeic #giaiphaptoeic #tăngdiemtoeic #giaoitiengAnh"
Solving GitHub Sync Issue in VS Code on Mac: A Quick Fix
Tags: vscode, macbook, githubsync, macos
Published: 2023-10-25 09:00:00

Have you recently made the switch to a Macbook and decided to use Visual Studio Code for your coding adventures? If so, you might have encountered a rather annoying issue, as I did. Every time I opened VS Code, it insisted that I sign in to my GitHub account to sync. It was driving me crazy, and for days, I scoured the internet looking for a solution, but to no avail.



In my quest to put an end to this GitHub sign-in nagging, I stumbled upon a simple solution that's easy to overlook. It turned out that my VS Code installation was in the wrong place all along – in my Downloads folder. Once I moved it to the Applications folder, the issue magically vanished.



Here's how to do it in a few simple steps:



**Step 1: Locate Your VS Code Installation**

- Go to your Downloads folder or the location where you initially installed VS Code.



**Step 2: Move VS Code to the Applications Folder**

- Click and drag the VS Code application icon to your Applications folder. Alternatively, you can right-click on the icon and select "Move to Applications."



**Step 3: Open VS Code**

- Now, open VS Code from the Applications folder. You'll notice that the incessant GitHub sign-in requests are gone!



It's astonishing how such a minor change can make such a major difference. So, if you're pulling your hair out over VS Code constantly pestering you to sign in to GitHub, try this quick fix, and you'll be free from the annoyance.



I hope my little adventure can help other Mac users who might be facing this same issue. It's a simple solution, but sometimes the simplest ones are the hardest to find. Let's code in peace and harmony, leaving those GitHub sign-in pop-ups behind!



If you found this post helpful, don't forget to share it with your fellow Mac users who code. We're all in this together!
Trouble with Blaze Orange Hats – Let's Discuss!
Tags: blazeorangehats
Published: 2023-10-25 08:51:24

Hey there fellow outdoor enthusiasts and hunters,

I hope you're all doing well. I wanted to start a discussion today about a rather unusual problem I've been encountering recently – my **[blaze orange hats](https://ballandbuck.com/upland-snapback-hat-in-blaze-orange/)**. As someone who spends a lot of time in the great outdoors, particularly during hunting season, these hats are a crucial part of my gear. However, I've been having some issues, and I'm wondering if anyone else has experienced similar challenges or has any advice to offer.

Issue 1: Fading

One of the main problems I've noticed is that my blaze orange hats seem to fade quite quickly. This is concerning because the high visibility of blaze orange is vital for safety while hunting. Has anyone else experienced this issue, and if so, how do you combat it? Is it just a matter of investing in higher-quality hats, or is there a particular maintenance routine that can help preserve the color?

Issue 2: Durability

The second problem I've been dealing with is the durability of my blaze orange hats. With all the trekking through the woods, sudden weather changes, and other outdoor elements, they tend to wear out pretty fast. I'd love to hear if anyone has found brands or models that are more long-lasting, or if there are any clever tricks to keep them in good shape for longer.

Issue 3: Finding the Right Fit

Blaze orange hats come in various styles and sizes, and it can be challenging to find one that fits just right. What's your experience with sizing, and do you have any go-to brands or models that provide an excellent fit? Or perhaps you've discovered any handy hacks to make hats more comfortable?

Cleaning and Maintenance Tips

Lastly, let's talk about cleaning and maintenance. How do you take care of your blaze orange hats to make them last? Do you have any recommended washing techniques or advice on storage to keep them in top condition?

I'd love to hear from you all about your experiences with blaze orange hats. Whether you've encountered these issues or have your own insights to share, please feel free to join the conversation. Let's pool our collective knowledge to help each other out and ensure we stay safe and visible in the great outdoors.

Looking forward to your input and suggestions!
C/C++ 算符/字符的替代表示法
Tags: cpp
Published: 2023-10-25 08:42:37

今天第一次看到, 為了在某些僅支援 [ISO/IEC 646 編碼](https://en.wikipedia.org/wiki/ISO/IEC_646)的環境上撰寫 C/C++ 程式碼, 所以有些算符以及字符有替代的表示方法, 例如 `&&` 可以改用 `and`, `||` 可以改用 `or`, 或是用 `<%` 與 `%>` 替代 `{` 和 `}` 等等, 所以以下的 C 程式碼是可以編譯執行的：

```c
#include<stdio.h>
#include<iso646.h>

int main()
<% // {
  int a = 10, b= 20;
  if(a and b) // a && B
    printf("OK");
  return 0;
%> // }
```

同樣的道理, 以下的 C++ 程式碼也是可以執行的：

```cpp
// Online IDE - Code Editor, Compiler, Interpreter

#include<iostream>

int main()
<%
  int a = 10, b= 20;
  if(a and b)
    std::cout << "OK";
  return 0;
%>
```

如果想知道有哪些替代表示法可用, C 可以[參考這裡](https://en.cppreference.com/w/c/language/operator_alternative), C++ 可以[參考這裡](https://en.cppreference.com/w/cpp/language/operator_alternative)。要注意的是, C 是採用巨集定義的方式提供算符的替代表示法, 所以要先引入 iso646.h 表頭檔才能使用, 不然編譯會出現語法錯誤。

當然, 這只是為了特殊環境下的設計, 如果用這些替代表示法撰寫程式, 應該絕大多數人都看不懂。
Toeic 4 kỹ năng
Published: 2023-10-25 08:37:52

"📣 Bạn muốn cải thiện kỹ năng Toeic của mình? Đến với Anhle Toeic để thực hiện mục tiêu của bạn! 🚀

🎯 Chương trình Toeic 4 kỹ năng tại Anhle Toeic sẽ giúp bạn:
🔸 Nắm vững kiến thức và cách áp dụng trong bài thi Toeic.
🔸 Phát triển kỹ năng nghe, đọc, nói và viết một cách toàn diện.
🔸 Tự tin giao tiếp và hiểu rõ ý nghĩa các đoạn hội thoại, bài đọc trong tiếng Anh.

💡 Với đội ngũ giảng viên giàu kinh nghiệm và phương pháp giảng dạy hiệu quả, Anhle Toeic cam kết mang lại cho bạn những bước tiến đáng kể trong việc nâng cao điểm số Toeic của mình.

📅 Đặt lịch học và trải nghiệm buổi học thử miễn phí ngay hôm nay! Hãy liên hệ với chúng tôi qua số điện thoại: 0967403648 hoặc truy cập website: https://anhletoeic.com/khoa-hoc/toeic-4-ky-nang để biết thêm thông tin chi tiết.

🌟 Hãy đạt được mục tiêu Toeic của bạn cùng Anhle Toeic! Hãy comment hoặc inbox cho chúng tôi ngay để bắt đầu hành trình thành công! 💪✨

#Toeic #AnhleToeic #NangcaoKyNangToeic #GiaoTiepTiengAnh"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vb39rjdvxk5hpgrg6r94.png)
Usage of method reduce in Ruby
Tags: ruby, beginners, programming, tutorial
Published: 2023-10-25 08:35:43

Usage of reduce in ruby and a task: 
Write a program that displays the sum of predecessors for the next 10 natural numbers. Expected result: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55.

My solution: 

```
def counter(n)
  sum = 0 
  letters = []
  (1..n).each do |number|
    sum += number
    letters << sum
  end
  letters.join(", "). #remember to create an array first and then to join letters inside
end 

puts counter(10) #result: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55
```

Tests: 

```
require './training1'

RSpec.describe '#counter' do
  subject { counter(n) }

  context 'It gives partial sums of the numbers' do
    let(:n) { 10 }

    it "should return a line of numbers" do
      expect(subject).to eq("1, 3, 6, 10, 15, 21, 28, 36, 45, 55")
    end
  end
end
```

But if we don’t need to display all numbers and we need just a sum of them, we may use the method reduce:

```

def counter(n)
  (1..n).reduce(:+) 
end 

puts counter(10) #result: 55
```

https://apidock.com/ruby/Enumerable/reduce

Enjoy :)