teleren/devto huggingface dataset:
Relational Databases vs Graph Databases
Tags: postgres, apacheage
Published: 2023-05-14 21:10:48

## Introduction
Databases are an essential part of modern computing, used to store and manage vast amounts of data. Two of the most common types of databases are relational databases and graph databases. While both types are effective at storing and retrieving data, they differ significantly in their design, functionality, and intended applications.

## Structure
Relational databases use tables with fixed columns and rows to hold data, with keys or foreign keys used to build associations between entities. This structure is ideal for data that can be represented in a tabular format with predetermined columns and relationships. Graph databases, on the other hand, employ an adaptable graph structure that supports dynamic interactions between elements. As a result, graph databases are more suited for data with intricate and dynamic interactions, such as social networks, recommendation engines, or fraud detection.

## Functionality & Usage
Relational databases are excellent at handling structured data with well-defined schemas and are efficient at maintaining a lot of transactional data. They are perfect for applications like online banking or e-commerce. Graph databases, on the other hand, are excellent at handling linked data with changing relationships. They are ideal for applications that require an in-depth understanding of relationships, including social media analysis, recommendation engines, or fraud detection. Real-time applications can benefit from graph databases' quick and scalable graph-based queries, which enable real-time traversal of expansive graphs.

If you have a well-defined schema and a good idea of what your transactions and data querying looks like, a relational database is probably the best choice. However, if your data has complex relationships, such as social networks or user data based on recommendations, a graph database is likely to be a better fit.


## Conclusion
In conclusion, both relational databases and graph databases have their strengths and weaknesses, and the choice between them depends on the nature of the data being stored. While relational databases are ideal for structured data with well-defined schemas, graph databases are better suited to data with complex relationships. Apache AGE is a powerful tool that allows users to take advantage of both types of databases, making it an excellent choice for many applications.
Classifying blockchain tech
Published: 2023-05-14 21:00:00



Discussions in crypto, when civilized, are around scalability (ie. tx fees) and security. Hidden behind these high level properties are some fundamental underlying properties that are so central they can be found in any blockchain.

This properties are:

1. Data availability guarantees
2. Compute or execution guarantees

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


## Classifications

#### 1. Part of consensus
When Bitcoin was release data availability was not a topic of discussion. That's because data can be expected to be stored for nodes that are part of consensus. If nodes omit any blockchain data then they might not being able to compute the blockchain state and risk losing their consensis rewards.

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

#### 2. Storage deals
A completely different approach is Filecoin deals. To be clear that is different from Filecoin consensus which follows a conventional pBFT leader-based consensus. Filecoin deals are essentially a marketplace with storage providers, each provider has a reputation based on their history and data is usually stored in multiple operators for better resilience.

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

#### 3. Slashable DAS
If there's agreement on the blockchain data you can run a node to provide an execution environment. That means that data can be safeguard with "cheaper" methods but still have the same security guarantees.

One such method is data availability sampling (DAS) where a blockchain stores data and does not care about execution. The data are guarantee to be available by random sampling or in other words by continuously requesting random pieces so nodes cannot omit any to not lose rewards.

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

#### 4. Optimistic DAS
A similar method is optimistic data availability sampling. This method still employs succinct proofs to ensure node's store the data but does not enforce slashing for nodes that do not provide the proofs.

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

## More options

#### 1. Sharding
Data sharding is a method to split data or execution in "committees" that only process part of the blockchain. Near protocol is focusing on sharding its mainnet that is expected to split the network in 4 and hence improve its scalability by 4x.

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

## 2. Expiry
State expiry is way to store non-permanent data in a blockchain. Storing data temporarily means that the blockchain size grows in a slower pace and hence nodes will eventually be able to store more data.

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

Read more on:
https://www.tzionis.com/classifying-blockchain-tech
Divine Wisdom: Understanding the Four Types of Vedas in Hinduism
Tags: upveda, aibodhaks, vedas, ai
Published: 2023-05-14 20:57:52

The Rigveda is the oldest and most important of the four Vedas. It consists of a collection of hymns, prayers, and mantras dedicated to various gods and goddesses. The Rigveda is composed in Vedic Sanskrit and contains 10 mandalas or books, 1028 hymns, and 10,600 verses. The hymns contained in the Rigveda are addressed to various deities such as Agni, Indra, Varuna, Soma, and Mitra.

[Visit for more info](https://www.upveda.in/blog/10/unveiling-mysteries-vedas-journey-hinduisms-oldest-texts)
Simple snake game created with React js.
Tags: react, snake, game, beginners
Published: 2023-05-14 20:15:02

React is a popular JavaScript framework that makes it easy to build interactive user interfaces. It's a great choice for building simple browser games with javascript because it allows you to easily manage the state of your application, which is critical for game development.

The snake game is a classic game that many people have played. It involves controlling a snake that grows in length as it eats food, while avoiding obstacles like walls and its own tail.

This is my take, using react and typescript. 

Repository: https://github.com/kle-pra/react-snake
Demo: https://react-snake-rho.vercel.app/
The 10 Day Ship : Day 2 - Switching gears #GitHubHack23
Published: 2023-05-14 20:13:54

The idea on Day1 was to build a github action, which will update the jira statuses automatically. Yes, its a pain point on my day job.

 - To Update (To Do -> In progress -> Done)
 - To update back, (well, when i sent a PR for review, reviwer asked for changes, The PR is not in review any more. it should be back to in progress? ) 
 - Change between Merge vs Deployed


Just realized, there are  already github actions, and i cannot expose or share the work for my day-job in public. So switching gear.

New Idea? Do summaries for PRs per repo to Slack. A Daily job, do a report, with Open PRs, expecting next step from which person, a summary.

May be just top10 PRs? may be least 10? need to think more while building or iterating.


lets see.
PHP 8: The joy of named arguments
Tags: php, beginners, programming
Published: 2023-05-14 20:12:11

Prior to PHP 8, devs used to struggle sometimes with some helpers or built-in utilities, as the only way to pass inputs correctly was to write them in the exact same order as defined by the method signature.

## Forget the current order

You can now use the name of the arguments instead, and it works with objects and classes too:

```PHP
class Post
{
    public function __construct(
        public string $title,
        public string $desc,
    ) {}
}

$post = new Post(
    desc: "My desc",
    title: "My title",
);
```

## Don't mix the syntaxes

Don't use both positional and named arguments in your calls, as it's prone to errors.

PHP won't understand what you're trying to achieve if your named argument comes before a positional argument.

Note that, theoretically, you can mix both as long as you put named arguments **after** positional arguments, but, still, I would not recommend such usage.

## The benefits in short

* the code is more readable, as, unlike positions, names are meaningful
* methods are "self-documented"
* you can skip default arguments
* named arguments are pretty helpful in annotations and attributes too
* _no more confusion between the haystack and the needle_

_N.B.: the last point is a private joke, as many built-in PHP utilities use similar names but in different order (legacy code)_

## The big caveat

Named arguments are pretty cool in my experience. The only caveat is that it could encourage a bad practice that consists of creating unnecessary long helpers, with sometimes more than 8 parameters!

Even if named arguments can ease the pain with such "_monsters_," I would still recommend splitting them into several helpers with less parameters.

Too much parameters usually indicates the helpers handles too much tasks.
Tips for Scheduling Job Interviews
Tags: interview, timemanagement
Published: 2023-05-14 20:11:42

## Are you trying to figure out when to schedule your job interviews? Here are a few things to consider that could help you make a good impression:

- Avoid scheduling interviews on Fridays if possible. People are often busy wrapping up their work for the week, and they may not be as focused during the interview.

- Consider scheduling interviews earlier in the week, such as on Monday or Tuesday. This is when people are more likely to be refreshed and focused, and you may have a better chance of standing out.

- Alternatively, consider scheduling interviews midweek, such as on Wednesday or Thursday. By this time, the interviewer has settled into the workweek, but they're not yet distracted by the approaching weekend.

Remember, the goal of an interview is to showcase your skills and qualifications. So, select a time that works best for you and that will give you the best chance of making a good impression. Good luck!
Making Four-In-A-Row Using JavaScript - Part 5: Reorganisation
Tags: javascript, games, gamedev, tutorial
Published: 2023-05-14 20:10:56

---
title: Making Four-In-A-Row Using JavaScript - Part 5: Reorganisation
published: true
description: Making changes to the work you've done so far in preparation for your four-in-a-row game's HTML5 Canvas front-end
canonical_url: https://www.colinkiama.com/blog/making-four-in-a-row-part-5/
series: Making Four-In-A-Row
tags: javascript, games, gamedev, tutorial
---

## Intro

In the previous blog post, you checked for wins and draws in `FourInARowGame`.

Now you'll be reorganising the work you've done so far in preparation the the HTML5 Canvas front-end that you'll be creating for the game.

## Creating The Game Logic Directory

First, create a new directory in the `src` directory called `gameLogic`.

Now move the `src/constants` directory and `src/FourInARowGame.js` to `src/gameLogic`.

Lastly, create a file under `src/gameLogic` called `index.js` with the following contents:

```js
import FourInARowGame from "./FourInARowGame.js";
import * as Constants from "./constants/index.js";

export { Constants, FourInARowGame };
```

From now on the core game logic will be stored in and referenced from `src/gameLogic`. The outside of `src/gameLogic` will be for the front end.

## Importing From The Game Logic Module

You're now exporting your core game logic as a module from `src/gameLogic/index.js`. You'll now need to fix outdated imports of the `FourInARowGame` class.

To do this, fix the import statement in `src/index.js` so that you import the `FourInARowGame` class from the game logic module:

```js
import { FourInARowGame } from "./gameLogic/index.js";

window.fourInARowGame = new FourInARowGame();
```

If you test the code in your web browser's console, you should still be able to interact with `window.fourInARowGame` just like before.

If not, please make sure that you've followed the instructions in this post correctly!

Great! Now, you're ready to start working on the front end in the next post.

Thanks for reading!
Lessons while building a static website
Tags: webdev, performance, devnotes, shortposts
Published: 2023-05-14 19:54:49


I loved designing & developing websites in my free time. One place, I always experiment with new web tools is on [my profile](https://vidyasagarmsc.github.io/). Recently, I started designing and coding another personal website for an event and here are some important take ways from the effort

### Tools

Whenever you are designing or developing a website, [lighthouse](https://developer.chrome.com/docs/lighthouse/overview/) is your performance buddy. The tool gives you invaluable metrics and best practices. 

![vidyasagarmsc.github.io](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1yxn32ga6obcbynuvzl.png)

### Minification
CDN is a good to have but if you are building a static website, I would recommend minifying the CSS, Javascript, and compress the images. 

- [Online Javascript minifier & compressor ](https://www.toptal.com/developers/javascript-minifier)
- [Online CSS minifier & compressor] (https://www.toptal.com/developers/cssminifier)

### Webp
`.webp` is an image format that gives you looseless compression for your images. My websites loading time increased by 40% after moving from jpeg,png —> webp

### Resource hints

Try using resource hints - preload, prefetch, preconnect to improve your website’s performance. Check this [awesome article](https://nitropack.io/blog/post/resource-hints-performance-optimization) on Nitropack to understand when to use preload vs prefetch vs preconnect.

### Lazy load 

Lazy load your images, fonts, iframes (embed), Javascript, CSS if and only when needed. Check [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading)

Embedded Tweet:

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">I have been designing and coding a personal website and here are some important take ways <a href="https://twitter.com/hashtag/thread?src=hash&amp;ref_src=twsrc%5Etfw">#thread</a> <a href="https://twitter.com/hashtag/CSS?src=hash&amp;ref_src=twsrc%5Etfw">#CSS</a> <a href="https://twitter.com/hashtag/performance?src=hash&amp;ref_src=twsrc%5Etfw">#performance</a></p>&mdash; Vidyasagar Machupalli (@VidyasagarMSC) <a href="https://twitter.com/VidyasagarMSC/status/1657594052957667331?ref_src=twsrc%5Etfw">May 14, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

### Short posts

Check my other short posts and shower your love - [#shortposts](https://dev.to/t/shortposts)
Ensuring Secure User Sessions: A Guide to Logging Out Users Due to Inactivity in PHP
Tags: webdev, php, security, architecture
Published: 2023-05-14 19:52:32

Securely logging out users from your web app due to inactivity is an important security measure to prevent unauthorized access to sensitive data. Here are some steps you can take to securely log out users due to inactivity:

## Step 1: Set session timeout

In your PHP code, set the session timeout using the `session.gc_maxlifetime` setting. This setting determines the maximum lifetime of a session in seconds.

```php
// Set session timeout to 30 minutes (1800 seconds)
ini_set('session.gc_maxlifetime', 1800);

// Start session
session_start();
```

## Step 2: Display warning message

Create a JavaScript function to display a warning message to users before logging them out due to inactivity. This function will be called after the session timeout has expired.

```javascript
function showTimeoutWarning() {
  // Display warning message to user
  alert('Your session will expire soon. Please click OK to continue.');
}
```

## Step 3: Confirm logout

Create a logout page to confirm that the user wants to log out. This page will be displayed after the session timeout has expired.

```php
<?php
// Check if user clicked logout button
if (isset($_POST['logout'])) {
  // Invalidate session
  session_unset();
  session_destroy();

  // Clear cookies
  setcookie('PHPSESSID', '', time() - 3600, '/');

  // Redirect to login page
  header('Location: login.php');
  exit();
}
?>

<!DOCTYPE html>
<html>
<head>
  <title>Confirm Logout</title>
</head>
<body>
  <h1>Are you sure you want to log out?</h1>
  <form method="post">
    <input type="submit" name="logout" value="Log Out">
  </form>
</body>
</html>
```

## Step 4: Invalidate session and clear cookies

In your PHP code, invalidate the user's session and clear any cookies associated with the session when logging them out due to inactivity.

```php
// Check if session has timed out
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > ini_get('session.gc_maxlifetime'))) {
  // Invalidate session
  session_unset();
  session_destroy();

  // Clear cookies
  setcookie('PHPSESSID', '', time() - 3600, '/');

  // Redirect to logout page
  header('Location: logout.php');
  exit();
}

// Update last activity time
$_SESSION['LAST_ACTIVITY'] = time();
```

## Step 5: Redirect to login page

In your PHP code, redirect the user to the login page after logging them out due to inactivity.

```php
// Redirect to login page if user is not authenticated
if (!isset($_SESSION['user_id'])) {
  header('Location: login.php');
  exit();
}
```

By following these steps, you can securely log out users from your web app due to inactivity, and help prevent unauthorized access to sensitive data.
Quick Progress in Software Development
Tags: career, productivity, programming, leadership
Published: 2023-05-14 19:40:14

Great software engineers are known for their ability to learn quickly and consistently deliver impressive results.

A distinguishing factor among senior software developers is their incredible capacity to tackle massive amounts of work efficiently. To join their ranks, you must strive to avoid idle states and ensure you're making steady progress in your projects.

This mindset pushes you directly into 1% of best software engineers.

In the world of software development, your progress speed is directly linked to your ability to learn, adapt, and overcome challenges.


_By delivering a constant stream of results, you'll demonstrate your value and enhance your reputation as a capable engineer._


The key to achieving this level of productivity is to minimize periods when you're stuck or not making progress:

1. **Stagnant Progress**: When you feel like you're not making any headway, it could indicate that you're facing a problem that needs resolving. It's crucial to recognize this signal and act on it.

2. **Uncertainty about Next Steps:** If you're unsure about what needs to be done, it's time to pause and assess the situation. You might be overlooking an essential step or feature.

3. **Difficulty Solving Problems:** Even the simplest issues can feel overwhelming when you're just starting in software development. Don't let this discourage you.

In all three cases, the solution can be straightforward: ask for help. Reach out to colleagues, mentors, or even AI tools like ChatGPT. By seeking guidance every 10 minutes when you're not moving forward, you can maintain momentum and ensure you're on the right track. Right track will lead you to becoming senior software engineer much quicker than reading guidelines.

I'm building a [game specifically build for software engineers](https://devmanager.carrd.co) to master such mindset.

The best way to progress in software development is by continually feeling a sense of accomplishment. Keep pushing yourself, learning from challenges, and seeking assistance when needed. This approach will ensure you are well on your way to a successful career in software development.

If you are not completely satisfied with the article, leave a comment below so I can adjust the next one to meet your needs.

Read More:
[Who is Force multiplier software engineer](https://mitrapunk.com/software-engineer-as-a-force-multiplier/)
All types of loop in JavaScript
Tags: javascript, webdev, beginners, programming
Published: 2023-05-14 19:27:48

## For Loop
## While loop
## Do while loop

Apart from this three traditional loop, there two shortcut loop in newer javaScript.

## Useful shortcut loop (for of, for in)
### For of loop
To loop over an array we can use the `for of` loop.

```js
let nums = [2,3,4,5,6,7];
for (const num of nums){
   console.log(num);
}
```
### For in loop
To loop over an object, we can use `for in` loop

```js
let info = {
    name : "rajo",
    id : 124,
    isAlve : true
};
for (const key in info){
   console.log(info[key]);
}
```
The Most Familiar Stranger - JavaScript - 陣列
Tags: javascript, beginners, chinese
Published: 2023-05-07 07:36:40

[分享記錄檔 YouTube](https://www.youtube.com/watch?v=3nKhVZVvV1c&list=PLal-nRIQU5sunSCOSeZZEzUrXUXF22gep&index=7)

JS 的陣列是一種有序的數據集合，其內部存儲的元素可以是任意類型的數據。

它有以下的特點：

1. 有序性：陣列中的每個元素都有一個索引，可以通過索引來訪問和修改其中的元素。
2. 長度可變：陣列的長度是可變的，可以動態添加或刪除元素。
3. 可存儲不同數據類型：JS 的陣列可以存儲任何數據類型，包括字串、數字、物件等。

### 創建陣列

直接創建：使用方括號[]，在其中添加元素，每個元素之間用逗號隔開

```jsx
const arr = [1, 2, 3, 'four', {name: 'John'}];
```

使用Array()構造函數創建：

```jsx
const arr = new Array(1, 2, 3, 'four', {name: 'John'});
```

### 操作陣列

push()：在陣列的末尾添加一個或多個元素

```jsx
const arr = [1, 2, 3];
arr.push(4);

console.log(arr);   // [1, 2, 3, 4]
```

pop()：從陣列的末尾刪除一個元素

```jsx
const arr = [1, 2, 3];
arr.pop();

console.log(arr);   // [1, 2]
```

shift()：從陣列的開始刪除一個元素

```jsx
const arr = [1, 2, 3];
arr.shift();

console.log(arr);   // [2, 3]
```

unshift()：在陣列的開始添加一個或多個元素

```jsx
const arr = [1, 2, 3];
arr.unshift(0);

console.log(arr);   // [0, 1, 2, 3]
```

splice()：在陣列的任意位置添加或刪除元素

```jsx
const arr = [1, 2, 3];
arr.splice(1, 1, 4);

console.log(arr);   // [1, 4, 3]
```

reverse()：將陣列元素順序反轉

```jsx
const arr = [1, 2, 3, 4, 5];
arr.reverse();

console.log(arr);   // output: [5, 4, 3, 2, 1]
```

<aside>
⚠️ 以上的操作都會直接異動原始陣列

</aside>

<aside>
💡 在 forEach() 執行中異動 array 會怎樣呢?

1. 減少陣列元素：部分元素將不會被遍歷到
2. 增加陣列元素：在執行 forEach 前要執行的長度就已經被設定了，所以在陣列後面加入的元素將不會被遍歷到

</aside>

slice()：回傳一個新陣列，其中包含原陣列的指定部分，可傳入兩個參數，第一個為起始索引 ( 包含 )，第二個為結束索引 ( 不包含 )

```jsx
const arr = [1, 2, 3, 4, 5];
const newArr = arr.slice(1, 4);

console.log(newArr);   // [2, 3, 4]
```

concat()：回傳一個新陣列，其中包含原陣列和傳入的陣列或元素

```jsx
const arr1 = [1, 2];
const arr2 = [3, 4];
const newArr = arr1.concat(arr2, 5);

console.log(newArr);   // [1, 2, 3, 4, 5]
```

map()：回傳一個新陣列，其中包含將原陣列每個元素經過回調函式處理後的結果

```jsx
const arr = [1, 2, 3, 4, 5];
const newArr = arr.map((item) => item * 2);

console.log(newArr);   // [2, 4, 6, 8, 10]
```

<aside>
⚠️ 以上的操作都會回傳一個新陣列

</aside>
Composer use global binaries
Published: 2023-05-14 19:23:59

---
title: Composer use global binaries
published: true
description: When you need to execute php script in your console 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-05-14 19:18 +0000
---

When you install composer, you need to link the vendor/bin folder for use script when you need run a script. 

```bash 
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
```

after 

```bash
source ~/.bashrc
``` 

That's it!