teleren/devto huggingface dataset:
Here's How To Create Your First PostgrSQL Extension Part 3
Tags: postgressql
Published: 2023-07-27 06:22:19

After [part2](https://dev.to/mghrabi/heres-how-to-create-your-first-postgrsql-extension-part-2-30g5) we should have one file so far in our directory (**Makefile**), now we will get into the .control file which provides metadata about the extension, also we will be going through the .c file:

### Starting by `add_two_numbers.control` file:

```
comment = 'Simple number add function'
default_version = '0.0.1'
relocatable = true
module_pathname = '$libdir/add_two_numbers'
```

`comment`: a brief description for extension functionality

`default_version`: as the name suggests, it specifies the default version of the extension

`relocatable`: if set to **true** it means that this extension can be moved to another location or server without causing issues, some extension crashes once they are moved to a different location, they require a different setup, but in the case of our extension it doesn't.

`module_pathname`: specifies the location to the shared library contains the extension code (the .so file in specific), which in my case will be found in `/usr/local/pgsql-13/lib`, and you can specify it manually up above by replacing `$libdir` with `/usr/local/pgsql-13/lib`.


## Creating `add_two_numbers.c` file:

The c file contain the actual functionality of the extension, which is the addition operation between two numbers, Here's how we create a extension function in postgres according to docs:
```
#include "postgres.h"
#include "fmgr.h"

PG_MODULE_MAGIC;

PG_FUNCTION_INFO_V1(add_two_numbers);

Datum
add_two_numbers(PG_FUNCTION_ARGS)
{
int32 arg1 = PG_GETARG_INT32(0);
int32 arg2 = PG_GETARG_INT32(1);

PG_RETURN_INT32(arg1 + arg2);
}
```

So far if we `ls` in the following files should be shown:

```
Makefile  add_two_numbers.c  add_two_numbers.control
```

In the next part we will create the last file, build the extension and run it together!.
5000 Followers on DEV
Tags: watercooler
Published: 2023-07-27 06:18:51

I'm so grateful to share that I've just reached 5,000 followers on dev.to! This community has helped me grow so much as a developer, and I'm thankful for each and every one of you.

The people who take the time to interact, comment, and provide feedback have made this journey so rewarding.

Reaching this milestone wouldn't have been possible without dev.to as a platform that connects developers from around the world. The ability to share knowledge, ask questions, and learn from each other is truly special.

To all my followers - thank you! Your support, feedback, and insights have helped me improve my articles and skills. I hope I've been able to give back and provide some value along the way.

This is just the beginning - I'm excited to continue learning and growing together on this platform. If you have any suggestions for future articles or topics, please feel free to leave a comment below.

Once again, thank you for helping me reach 5,000 followers on dev.to. I appreciate each and every one of you!
Ruby Basics - Arrays & Intro to Hashes
Tags: beginners, ruby
Published: 2023-07-27 04:20:03

An array is an object that can hold multiple items (pieces of info, including other arrays).

To access the array use its index starting from 0 (use -1 to get the last item).

        
array   | 5 | 7 | 9 | 2 | 0 |
        
index     0   1   2   3   4


A hash is an object similar to an array, but a hash as both a key and a value.

When creating a hash, use Hash.new and then add to it by using the hash name next to brackets with the key equal to the value.

```ruby
pets = Hash.new

pets['Cash'] = 'cat'

puts pets['Cash']
```

To iterate over a hash, it is the same as an array except add a second parameter to get the value of the key

```ruby
lunch_order = {
  "Ryan" => "wonton soup",
  "Eric" => "hamburger",
  "Jimmy" => "sandwich",
  "Sasha" => "salad",
  "Cole" => "taco"
}

lunch_order.each { |x, y| puts y }


Output:
wonton soup
hamburger
sandwich
salad
taco
```

**Mini Project**

Creating a program that will analyze how many words are used in a block of text and the frequency.

```ruby
puts = 'Analyze this phrase'
text = gets.chomp

words = text.split

frequencies = Hash.new(0)

words.each { |word| frequencies[word] += 1}

frequencies = frequencies.sort_by do |word, count|
  count
end
frequencies.reverse!

frequencies.each do |word, count|
  puts "#{word} #{count.to_s}"
end

 He walked down the steps from the train station in a bit of a hurry knowing the secrets in the briefcase must be secured as quickly as possible. Bounding down the steps, he heard something behind him and quickly turned in a panic. There was nobody there but a pair of old worn-out shoes were placed neatly on the steps he had just come down. Had he past them without seeing them? It didn't seem possible. He was about to turn and be on his way when a deep chill filled his body.Then came the night of the first falling star. It was seen early in the morning, rushing over Winchester eastward, a line of flame high in the atmosphere. Hundreds must have seen it and taken it for an ordinary falling star. It seemed that it fell to earth about one hundred miles east of him.

the 6
a 5
he 3
in 3
his 2
on 2
was 2
and 2
possible. 2
quickly 2
as 2
be 2
of 2
steps 2
down 2
He 2
body. 1
filled 1
chill 1
deep 1
when 1
way 1
turn 1
to 1
about 1
seem 1
didn't 1
It 1
them? 1
seeing 1
without 1
them 1
past 1
Had 1
down. 1
come 1
just 1
had 1
neatly 1
placed 1
were 1
shoes 1
worn-out 1
old 1
pair 1
but 1
there 1
nobody 1
There 1
panic. 1
turned 1
him 1
behind 1
something 1
heard 1
steps, 1
Bounding 1
secured 1
must 1
briefcase 1
secrets 1
knowing 1
hurry 1
bit 1
station 1
train 1
from 1
walked 1

```
Why VPN losing its relevance in the world of sophisticated Cyber Attacks ? VPN vs ZTNA Outcome based Approach
Published: 2023-07-27 06:11:45

Many enterprises have adopted Zero Trust Network Access(ZTNA) during COVID-19 WFH times considering the broad Zero Trust Architectures virutes. Are they clear on the possible outcomes from the initiatives?

we're not sure, from our varied interactions with CIOs & CISOs. Here is a jargon-free take on ZTNA Outcomes compared to VPN.

![Outcome Parameters VPN Vs ZTNA Table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xr42fkjf4xp82p7cozxo.png)

Comments and inputs are most welcome!
Building Open Source for 100 days
Tags: 100daysofcode, opensource
Published: 2023-07-27 06:02:53

I'm overwhelmed, I just made an announcement on Twitter about my intention to embark on the 100 days of code challenge starting 1st August. I intend to build fully functional open source projects during the course of the challenge .

**Why?**
Why not?

I  found myself feeling demotivated of recent due to high levels of unproductivity, then I  stumbled upon a post talking about the 100 days of code challenge. Honestly, this is not the first time I'm learning about the challenge, but it hit different this time around because I thought "why not?"; My social media presence is very low. In fact, my total online presence is low; [My Github ](https://github.com/Radi-dev) activity is below inspiring. This, I  thought, is the best time to start. See how far I go.

https://twitter.com/radi_dev/status/1684422490678759429?s=61&t=XKS8vD5JNdx3m6lFOsrGIQ
Most common Junior JS Developer interview questions
Published: 2023-07-27 06:01:15

As a junior JavaScript developer, you can expect to be asked a variety of questions during interviews, covering both technical and non-technical aspects. Here are some of the most common questions that you might encounter:

1. Basic JavaScript Concepts:
   - What is JavaScript, and what is it commonly used for?
   - Explain the difference between var, let, and const.
   - What are data types in JavaScript?
   - How do you declare and call functions in JavaScript?
   - What is the difference between null and undefined?
   - How does hoisting work in JavaScript?

2. DOM Manipulation and Events:
   - What is the DOM (Document Object Model) in the context of web development?
   - How do you access and modify elements in the DOM using JavaScript?
   - Explain event delegation and its benefits.

3. Asynchronous Programming:
   - What is asynchronous programming in JavaScript, and why is it important?
   - How do you handle asynchronous operations using callbacks, promises, or async/await?

4. Array Manipulation and Higher-Order Functions:
   - How do you loop through an array in JavaScript?
   - What are some common array methods like map, filter, and reduce, and how are they used?

5. ES6+ Features:
   - What are some new features introduced in ES6 and later versions of JavaScript?
   - How do arrow functions differ from regular functions?
   - What are template literals, and how do you use them?

6. Common Libraries and Frameworks:
   - Have you worked with any JavaScript libraries or frameworks like React, Vue, or Angular?
   - What are the advantages and disadvantages of using a framework?

7. Debugging and Tools:
   - How do you debug JavaScript code?
   - Have you used any developer tools like Chrome DevTools?

8. Testing:
   - Have you written unit tests for JavaScript code?
   - What testing frameworks have you used?

9. Code Organization and Best Practices:
   - How do you organize your JavaScript code to make it maintainable and scalable?
   - What are some best practices you follow while writing JavaScript code?

10. Project Experience:
    - Can you describe a JavaScript project you worked on?
    - What were the most significant challenges you faced during the project, and how did you overcome them?

Remember that the specific questions can vary depending on the company and the interviewer's preferences. It's crucial to review JavaScript concepts, practice coding exercises, and be prepared to discuss your own experiences and projects to demonstrate your skills and enthusiasm for the field.
Ruby Basics - Methods and Sorting
Tags: beginners, ruby
Published: 2023-07-27 06:00:02

**Methods**

A method is very similar to a function in JavaScript. You start off by using def and then the name of the method. 
Parentheses follow the method name is it requires a parameter. Then you insert your reusable code and end it with the word 'end'. 

It should look like this...

```ruby
def cubertino(n)
  puts n ** 3
end
```

To call it (use it) just use the name of the method with an argument in parentheses 

```ruby
cubertino(8)

# 512
```

To make multiple arguments just put an asterisk in front of the parameter

```ruby
def what_up(greeting, *friends)
  friends.each { |friend| puts "#{greeting}, #{friend}!" }
end

what_up("What up", "Ian", "Zoe", "Zenas", "Eleanor")

Output: 
What up, Ian!
What up, Zoe!
What up, Zenas!
What up, Eleanor!
``` 

Using _return_ inside your method will give you back a value, this value can be used for another method.

**Sorting**

Using _sort_ will reorganize your string data from A-Z or your numerical data from 1-n.

To get the opposite order, use arrow notation to set which order you would like.


```ruby
books = ["Charlie and the Chocolate Factory", "War and Peace", "Utopia", "A Brief History of Time", "A Wrinkle in Time"]

# To sort our books in ascending order, in-place
books.sort! { |firstBook, secondBook| firstBook <=> secondBook }

# Sort your books in descending order, in-place below

books.sort! { |firstBook, secondBook| secondBook <=> firstBook }
```
Use JookDB to migrate Oracle Database to Mysql
Tags: mysql, oracle, database, developer
Published: 2023-07-27 05:53:30

[JookDB](https://jookdb.com/) is a multi-platform database development management tool, such as SQL input prompts, import and export, table design, data editing and other powerful functions, and the interface of C++ development is very smooth and smooth. It can support Oracle, Mysql, and SqlServer database management for free.
To migrate Oracle databases to MySQL via JookDB, you need to first add data sources that connect to both databases. Select the menu [File/New Data Source/Oracle, Mysql], and then enter the IP port, username, password and other information to be repeated here.

1, Create a new database on Mysql.
Right-click the MySQL data source and select Create Database.

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

2, Synchronization table mechanism.
Right-click on the newly created database and select Synchronize Table Structure. Enter the source and target databases.

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

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

3, Synchronize data
Right-click on the MySQL database and select Synchronize Data, and select Oracle for the source database. Complete the data synchronization.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuhnq7w8cju8cazxb9of.png)
Digitalization
Tags: refitools, cryptocurrency, 4threvolution, climatechange
Published: 2023-07-27 05:32:38

The Developer is in a unique position and can responsibly do our share to minimize climate change while progressing digitization and preparing for quantum computing. Electronics and Industrial technology, otherwise known as simple digitization (the Third Industrial Revolution) have transformed into combinations of technologies and digitalization (the Fourth Industrial Revolution). It is forcing companies to reexamine the way they do business. Business is evolving exponential instead of at a linear pace. It is disruptive to almost every industry such as production, management, and governance.We want to minimize this disruption and it's effect on climate change. Climate change affects every facet of our universal ecosystem. Leading to medical conditions such as allergies or asthma exacerbation, pollution, lack of food for humans and resources for animals, deforestation at the rate of 80,000 acres a day. 
 The emergence of Web3 technology, values and ideas inherent to the Regenerative Finance (ReFi) or Decentralized Finance (DeFi) movement can mobilize capital to fund the climate crisis solutions.Web 3 technology such as Block chain are role models to decentralized thinking and the decrease in waste
 that comes with this. Using Web3 tech to reverse ecosystem degeneration. And while blockchain and cryptocurrencies have been hailed as revolutionary means to securely store data and financial information, they were built on existing public key encryption - which may not be a match for quantum computers. It is crucial that the development of **quantum-resistant cryptosystems** is transparent and the Web3 climate tools and services share values inherent to ReFi and are positively correlated to the scale of global coordination needed to tackle climate change.
**This is my first comment. I welcome your ideas and discussion on ways to improve our existing crucial climate issues, and combating quantum computing algorithms.**
How to add pg_embedding extension to PostgreSQL
Tags: langchain, python, postgres, linux
Published: 2023-07-27 05:32:07

The new `pg_embedding` extension was recently released, bringing exciting advancements by boosting graph-based approximate nearest neighbor search speed by 20x with 99% accuracy for your Postgres databases.

Open-source extensions like `pgvector` and `pg_embedding` facilitate vector similarity search within Postgres, making it a robust choice for storing vectors and executing similarity searches. However, their indexing methods vary, so it's essential to explore their differences and choose the most suitable one for your needs more on that [here](https://neon.tech/blog/pg-embedding-extension-for-vector-search). The installation process for both extensions remains the same.

You can also install this on Postgres running on Docker, skip to the section below.

Let's get started.

Step 1: Begin by cloning `pg_embedding` from its repository and move it to `/tmp` directory:
   ```
git clone https://github.com/neondatabase/pg_embedding.git
mv pg_embedding /tmp
   ```

Step 2: Navigate to the `pg_embedding` directory:
   ```
cd /tmp/pg_embedding
   ```

Step 3: To ensure smooth compatibility with your PostgreSQL version, install the required dependencies:
   ```
sudo apt install postgresql-server-dev-XX
   ```
   (Replace XX with your PostgreSQL version. For example if you're using Postgres 15.3 use 15)

Step 4: Next, build and install the project using make command:
   ```
make
sudo make install
   ```

Step 5: Now, let's add the extension using `psql`.
   Note: You need login as superuser to be able to add    extensions.
   ```
sudo su postgres # Login as super user
psql
   ```

Step 6: Following command creates the extension
   ```
create extension embedding;
   ```

Step 7: Verify the installation by checking the extensions with the `\dx` command and `\q` to quit `psql`.

If you'd like to add the extension to Postgres running on Docker, 

Obtain the name or ID of your Postgres container:
   ```
docker ps
   ```

Once you have it, let's dive into the container to do some shell scripting:
   ```
docker exec -it <NAME | ID> sh
   ```

Voila! You've gained access to the Docker realm. Execute the same commands used on the mainland to work your magic within Docker.

But, heed this warning! 🚨 Your Docker installation may be hampered by missing additional packages like git, make, gcc, and g++. To sail smoothly, install them with:
   ```
sudo apt-get install git make gcc g++
   ```

Pro Tip: Clone the repo and copy the `pg_embedding` directory to docker container and skip git installation using:

```
docker cp pg_embedding <CONTAINER_ID>:/tmp
```

Continue from Step 2 to finish the installation.

There you have it! 🌟 You've successfully installed the `pg_embedding` extension. Happy coding and may your endeavors be magical! 🧚‍♀️

Credits:
Photo by <a href="https://unsplash.com/@sickle?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Sergey Pesterev</a> on <a href="https://unsplash.com/images/nature/landscape?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Random normal distribution
Tags: random, normal, distribution, boxmuller
Published: 2023-07-27 05:19:23

JavaScript by default don't have randomness with normal distribution.

We can use for that pretty simple Box-Muller implementation that I showed below.

```js
// Box-Muller implementation:
const randNormal = (mean, sigma) => {
  const y1 = Math.random();
  const y2 = Math.random();
  return (mean + sigma *
    Math.cos(2 * Math.PI * y2) *
    Math.sqrt(-2 * Math.log(y1))
  );
};
```

It can be useful to solve this [codewars kata](https://www.codewars.com/kata/525b71926080a49789000185/javascript).

You can see example use of this [code here](https://instacode.app/run/FAehAICEHsA8FoCyBXANqgpgJ3ASwLYAOm+GAdgC4CGFu0ZAXMAMb0DOF4WVZAJgHLQs+KqnABecAApSPADTg2uAOYiAlBIB84AN7Bw4VmQ7gAngEYJ4RDQAWAOm59o+KWoDc+w+06mATFY2FA5OvC5ungZYGBTIWGTgsgkA1IoqIuAAVNZ29qxsUn6ZQQ4ACgCSmf5qxblsAI5YFFLwRSX2qNDKUhZqHsAAvp6gEBiwVESYTCw+4FRYOJJkGADu4ACCC1SmUgAsAAxq9gBmuOhSh8NGJuUAKgCiAErrt+UA8vwAylbmGABsnmOQmkmE4uCs+3ceHAAB5wHcni93l8oclkrgNHoDNdOKErKFBMJRIV9go-v1sbMsNBkHxArlqbTeFJQhS8MdpIy6XD9uAAD58rg0umaSTzLAdcjKYIaIy0MjIDCROYLADaXN4AF00Z4BsAZsZOCJYPTgvZjVJ7Fbxf0cWkAF4YKwAVkhwHF5qohCkCXE2naGp94AgxqyDowfU93t92ixXBicQSAHIAMRJxwYQgYGg+-oDfpAA).
Cloud Computing
Tags: cloudcomputing, talentserve
Published: 2023-07-27 05:17:07

The on-demand delivery of IT resources through the Internet is known as cloud computing. Cloud computing uses a network of remote servers hosted on the internet to store, manage, and process data instead of depending on local servers or individual devices to handle data and applications.

Types of Cloud Computing:

Infrastructure as a Service (IaaS): IaaS offers virtualized computing resources, such as virtual machines, storage, and networking, through the Internet. Users can handle and configure these resources according to their needs.

Platform as a Service (PaaS): Developers can build, launch, and maintain applications using the platform and environment provided by PaaS without having to worry about the complexity of the underlying infrastructure.

Software as a Service (SaaS): SaaS eliminates the requirement for installation and maintenance on individual devices by delivering fully working software programs over the Internet.

Benefits of Cloud Computing:

Cost Savings: The requirement to purchase and maintain physical equipment and infrastructure is removed by cloud computing. Pay-as-you-go business models allow for much lower capital expenditures.

Enhanced Security: Cloud companies make significant investments in security measures, frequently using access controls, firewalls, and encryption to make it difficult for unauthorised users to access critical data.

Flexibility and Scalability: Cloud services enable businesses to scale resources up or down as needed, assuring optimal performance during peak times while lowering expenses during slower periods. They can rapidly adjust to changing workloads.
Xóa tham số “?i=1” trên URL WordPress
Published: 2023-07-27 04:48:00

Tham số “?i=1” xuất hiện trên URL là gì?
Website WordPress miễn phí hoặc thiết kế từ các dịch vụ bên ngoài đôi khi sử dụng dịch vụ lưu trữ InfinityFree (Dịch vụ lưu trữ web miễn phí được sử dụng phổ biến). Có lúc sẽ xuất hiện tham số “/?i=1” hay “/?i=n” trên URL của bạn. Đây là những hậu tố hoàn toàn vô hại và ngược lại còn giúp bảo vệ website của bạn khỏi các BOT độc hại. Hầu hết người dùng không tin rằng trang web của họ cần hệ thống bảo mật, họ chỉ cảm thấy bất tiện vì nó. Nhưng các tập lệnh lỗi thời có thể bị tấn công và bắt đầu phát tán phần mềm độc hại, gửi thư rác,…

Nhưng tất nhiên không ai muốn trang website của mình xuất hiện là `digital-fullstack.com/?i=1` thay vì `digital-fullstack.com` và sau đây là cách khắc phục: https://digital-fullstack.com/xoa-tham-so-tren-url-wordpress/

Mở file .htaccess và chèn đoạn code này ở đầu file:
`<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
</IfModule>`
if/else if
Published: 2023-07-27 04:37:48

Currently doing a lesson on these, honestly it took me awhile to figure out how to use else if before using else. Then having to learn that I can use multiple else if, honestly ternary/switch statements just feels so much easier for my brain to create code for. I sat down for 30 minutes contemplating my entire existence before I could get back into figuring it out. lesson learned though use 

if(){
}else if(){ //however many you like
}else{//use this last
}
rumus-vlookup-excel
Published: 2023-07-27 04:25:30

Berikut adalah rumus VLOOKUP Excel dasar:
=VLOOKUP(lookup value; table array; col_index_num; [range_lookup])

Agar Moms tak bingung, berikut adalah arti dari masing-masing variabel di rumus tersebut:

Lookup value
Sel yang dijadikan patokan.

Table array
Tabel yang ingin diambil datanya.

Col_index_num
Urutan kolom di tabel yang ingin kamu ambil datanya.

Range_lookup
Sifat data yang ingin Moms cari (Akurat atau estimasi).



Pada kasus ini, kita ingin mengisi kolom gaji berdasarkan posisi dari masing-masing karyawan.

Jadi, di sini rumus yang digunakan adalah:

=VLOOKUP(C4;$F$4:$G$6;2;0)

Berikut adalah arti dari masing-masing variabel:

Lookup value (kotak orange)

Di sini, sel yang dijadikan patokan adalah C4. Karena kolom gaji diisi berdasarkan kolom posisi, dan sel teratas di kolom posisi adalah C4.

Table array (kotak biru)
Kita akan mengambil data nominal gaji dari kotak ini (sel F4:G6).

Nah, agar datanya tak berubah, Moms bisa klik tombol F4. Sehingga angkanya akan berubah jadi “$F$4:$G$6”.

Col_index_num
Di sini, kita memasukkan angka 2. Sebab, kolom gaji merupakan kolom kedua di kotak biru.

Range_lookup
Karena ini adalah contoh sederhana dari VLOOKUP Excel, kita bisa masukkan angka 0 saja. 

Setelah itu, rumus VLOOKUP Excel akan mengambil data dari kotak biru secara otomatis dan mencocokkannya dengan informasi yang ada di sel C4.

Karena di sel C4 informasinya adalah Manager, jadi data yang ditampilkan adalah 10 juta.

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

https://www.orami.co.id/magazine/rumus-vlookup-excel