teleren/devto huggingface dataset:
Python challenge_22🐍⚔️
Tags: python, challenge, beginners, programming
Published: 2023-02-22 19:07:33

##  Duplicate Encoder

- The goal of this exercise is to convert a string to a 
new string where each character in the new string is "(" 
if that character appears only once in the original string, 
or ")" if that character appears more than once in the original 
string. 

- Ignore capitalization when determining if a character is a duplicate.

#### Examples:

```
    "din"      =>  "((("
    "recede"   =>  "()()()"
    "Success"  =>  ")())())"
    "(( @"     =>  "))(("
```

###### Task URL: [Link](https://www.codewars.com/kata/54b42f9314d9229fd6000d9c/train/python)


## My Solution:

```
def duplicate_encode(word):

    return "".join(["(" if word.lower().count(x) == 1 else ")"
                    for x in word.lower()])


print(duplicate_encode("recede"))

```


### Connect with Me 😊

#### 🔗 Links

[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/mahmoud-el-kariouny-822719149/)

[![twitter](https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/Mahmoud42275)
Apache AGE Installation Process Part 1
Tags: apacheage, postgres, c
Published: 2023-02-22 18:57:30

Hi Guys!

Here's an easy installation process for environment setup of Apache AGE on MacOS.

Apache AGE adds graph database functionality to PostgreSQL, making it easy for developers to design and manipulate databases.

This blog will focus on setting up PostgreSQL for using Apache AGE.

The most suitable versions, to use with Apache AGE, of PostgreSQL are 11 & 12. So you can use anyone of these.

Download the desired version of PostgreSQL from this link.
https://www.postgresql.org/ftp/source/

Open up terminal or command prompt and unpack the downloaded archive using the following command.
tar xf postgresql-version.tar.bz2

This will create a new directory "postgresql-version" under the current directory with the PostgreSQL sources. Move into the new directory.

Now run the following commands in the same sequence.

./configure

make all

make check

make install


and that's it. Next part will explain and elaborate these commands and their purpose. Links for Apache AGE site and github repo are given below. Make sure to check them out.

https://age.apache.org/
https://github.com/apache/age


Thank You!
c ++ da cout cin
Tags: beginners, programming, tutorial, cpp
Published: 2023-02-22 18:53:55

Bugun sizlar bilan cout cin ni qanday ishlashini , nimalar yordamida ishlashini ko'rib chiqamiz . va ularni ma'nosi va farqlarini ham maqolam davomida aytib o'tib ketaman . 

cout - bu ekranga chiqarish . # output so'zidan olingan . 
cout yordamida biz o'zimiz hohlagan narsalarni hohlaganimizcha chiqarishimiz mumkin . bunda faqat biz yozgan narsalar chiqadi 
ammo uni  variables lar yordamida ham ishlatsa bo'ladi . 

cin - bu kirgizish . # input so'zidan olingan . 
cin ga biz shart bergandan keyin son yoki kiritilishi kerak bo'lgan matn kiritamiz . 

esda tut ! 
esda tutish kerak cin yani output orqali ko'da yozmoqchi bo'lsak yozadigan narsamizni tipi va o'zgaruvchisi bo'lishi kerak . 

biz ko'd yozayotganimizda ikkisi ham bizga kerak bo'ladi . 
ular bir biriga bo'g'liq tomoni ham mana shunda input output bittasi kiritsa ikkinchisi chiqarib beradi . 

farqi cin ga biz kiritamiz yana biz kiritgan son cindan katta bo'ladi . 
cout da esa oldindan yozib qo'yamiz unda esa biz yozib qo'ygan son cout dan kichik bo'ladi . 

Mavzuni tushundingiz degan umiddaman keyingi maqolalarimgacha hayr salomat bo'ling .
Sobre a comunicação...
Tags: beginners, career
Published: 2023-02-22 18:45:33

Ah a comunicação.
Quando bem feita e documentada, é um milagre.
Quando omitida, é poder de barganha.
Quando não entendida, gera complicações.
Quando não seguida, gera atrasos.
Quando não tem, é o puro ódio de quem precisa dela.
Top 5 ways to attract readers on DEV
Tags: writing, beginners, tutorial, productivity
Published: 2023-02-22 18:39:09

This is how my dev.to blog reader stats has changed over the last week:

![graph on readers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9u6aiu49dhliqutr48p.png)
So I’m here to share some tips on how to get this massive increase in readers.

---

# Write about topics that you are passionate about
This is arguably the most important point as whatever you write about should be a topic you enjoy. 
This will let you easily put your thoughts in words. 

# Write about what you are currently working on
The main reason why I’ve got this huge increase in readers is because I’ve started blogging about my journey with Next.js/React. 
People like reading about projects you are working on.
The community at DEV is very supportive and will encourage you all the way throughout your coding journey!
Make sure to include code snippets and how the code works.

# Don’t let the fact that you are bad at writing stop you
I’ve never been that great at writing, but I still tried blogging.
Remember that people prioritise content over SPaG, and as long as your article is interesting, people will read it.

# Don’t quit writing 
If you blog once a week, there is a less chance that someone comes across your article than if you blog once a day.
The more you write, the more likely it is that someone comes across your article, and that article might lead many users to following you.

# Use Markdown
Many people (like me) tend to not read article that don't use Markdown as those articles don't have clear headings or any highlighted words.
Use Markdown will let the reader know what your main points are about and will teach them the main facts, even if the reader is skimming through the article.

---

Thanks for reading, and I hope this article helps you in some way!
✨2023#7: AIcommits: Create Git Commit Messages With AI
Tags: javascript, typescript, webdev, node
Published: 2023-02-22 18:38:26

Hi JS developers👋
[JSTools Weekly](https://jstools.substack.com/) newsletter, issue [2023#7](https://jstools.substack.com/p/2023-newjstools-7) (new JS Tools) just released.


![new JS tools, issue 2023#7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8y07j82qa7zv2gs70ufx.png)


**[aicommits](https://github.com/Nutlope/aicommits): **A CLI that writes your git commit messages for you with AI



**[hotscript](https://github.com/gvergnaud/hotscript): **A lodash-like library for types, with support for type-level lambda functions

**[scribble-diffusion](https://github.com/replicate/scribble-diffusion): **Turn your rough sketch into a refined image using AI

**[tailwindcss-icons](https://github.com/egoist/tailwindcss-icons): **Use any icon (100,000+) from Iconify, for TailwindCSS


**[semantic-search](https://github.com/beerose/semantic-search): **🕵️‍♀️ An OpenAI-powered CLI to build a semantic search index from your MDX files.

**[toolformer-zero](https://github.com/minosvasilias/toolformer-zero): **React app implementing OpenAI and Google APIs to re-create behavior of the [toolformer paper](https://arxiv.org/abs/2302.04761).

**[openai-streams](https://github.com/gptlabs/openai-streams): **Tools for working with OpenAI streams in Node.js and TypeScript.

**[react-hook-form/core](https://github.com/react-hook-form/core): **Framework agnostic hook form core lib

**[mirrorful](https://github.com/Mirrorful/mirrorful): **Simple, open-source design system infrastructure.


**[vue-signals](https://github.com/johannschopplich/vue-signals): **📶 SolidJS-like reactive signals for Vue.js


**[vant-nuxt](https://github.com/vant-ui/vant-nuxt): **Vant module for Nuxt

**[nuxt-permissions](https://github.com/dystcz/nuxt-permissions): **Nuxt module for permission management

**[nonchalance](https://github.com/WebReflection/nonchalance): **The easiest way to augment DOM builtin elements.

-   No polyfills needed, all modern browsers just work™️

-   elements can be either created from scratch or upgraded on demand for graceful hydration

-   fits into 228 bytes (runtime) or 576 bytes (default) once served minified via default brotli settings (280 runtime or 666 via default gzip settings)

**[micro-ts](https://github.com/adevinwild/micro-ts): **A minimalist template to create packages with TypeScript and microbundle from @developit

-   Pre-configured `microbundle` repository 📦

-   Pre-configured `eslint` and `prettier` 🛠️

-   Pre-configured `jest` and `ts-jest` 🧪

**[nuxt-pre-hydrate](https://github.com/danielroe/nuxt-pre-hydrate): **Safely run pre-hydration steps on the client with Nuxt 3

-   💪 Prevents hydration mismatch on client

-   🏁 Fully configurable

-   ⚠️ Experimental and under developemnt

**[rollup-plugin-pure](https://github.com/danielroe/rollup-plugin-pure): **Annotate functions as pure for Rollup

-   ⚡️ avoids end-users bundling unused code


[See full list of new javascript tools](https://jstools.substack.com/p/2023-newjstools-7)
🔥2023#7: Craft prompts for LLMs by Prompt Engine
Tags: javascript, typescript, webdev, node
Published: 2023-02-22 18:38:19

Hi JS developers👋
[JSTools Weekly](https://jstools.substack.com/) newsletter, issue [2023#7](https://jstools.substack.com/p/2023-hotjstools-7) (hot JS Tools) just released.


![hot JS tools, issue 2023#7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/85b41ysqnsz28mxzroon.png)


**[prompt-engine](https://github.com/microsoft/prompt-engine): **A library for helping developers craft prompts for Large Language Models


**[envless](https://github.com/envless/envless): **OpenSource, frictionless and secure way to share and manage app secrets across teams.


**[jendeley](https://github.com/akawashiro/jendeley): **jendeley is a JSON-based document organizing software.


**[devalue](https://github.com/Rich-Harris/devalue): **Gets the job done when JSON.stringify can't

Like `JSON.stringify`, but handles

-   cyclical references (`obj.self = obj`)

-   repeated references (`[value, value]`)

-   `undefined`, `Infinity`, `NaN`, `-0`

-   regular expressions

-   dates

-   `Map` and `Set`

-   `BigInt`

-   custom types via replacers, reducers and revivers

**[QwikTape](https://github.com/4silvertooth/QwikTape): **Do calculations, annotate like you would on a paper "qwikly"


**[camome](https://github.com/camomeui/camome): **Light weight, accessible UI framework for React and CSS

**[helium](https://github.com/thoughtindustries/helium): **Helium is a frontend web development framework for building highly contextual, dynamic and personalized learning experiences.

**[pythagora](https://github.com/Pythagora-io/pythagora): **Generate integration tests for your Node.js app by recording server activity without writing a single line of code.

**[zenstack](https://github.com/zenstackhq/zenstack): **Supercharges Prisma ORM with a powerful access control layer and unlocks its full potential for web development.

**[graphql-http](https://github.com/graphql/graphql-http): **Simple, pluggable, zero-dependency, GraphQL over HTTP spec compliant server, client and audit suite.

**[solid-devtools](https://github.com/thetarnav/solid-devtools): **Library of developer tools, reactivity debugger & Devtools Chrome extension for visualizing SolidJS reactivity graph


[See full list of hot javascript tools](https://jstools.substack.com/p/2023-hotjstools-7)
1 year on DEV! 🥳
Tags: beginners, devjournal, writing, news
Published: 2023-02-22 18:18:45

### It's been *a year* since I joined dev.to!

I'd like to thank this community for being so supportive towards my developer journey, and especially my Next.js one.
Even though I'm not that great at writing, in the last month, I gained **4000 readers**, **200 reactions** and **350 followers**.
This has encouraged me to keep on writing and I will be writing even more better content this year, with lots of tutorials.

Things I want to learn this year:
- Next.js/React
- SQL
- Flutter or React Native

Thanks for reading my posts over the last year and I hope you continue reading them!
Insert a Node at Specific Position in Linked List HackerRank — Python Solution
Tags: insert, node, position, hackerrank
Published: 2023-02-22 18:15:42

Data manipulation tasks frequently include insert a node at a specific position in linked list. We must first determine the position in a linked list where we wish to insert the new node. After selecting the place, we must search the attached list for the node that precedes the required position. So, to add a new node to the list, we may update the pointers of the old node and the new node. HackerRank has given us this Problem to Solve.

Solution is here
https://hecodesit.com/insert-a-node-at-specific-position-in-linked-list-hackerrank-python/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1018o3r2xwynm9tj8gdh.png)
Why using OpenZeppelin's isContract() may be unsafe
Tags: solidity, evm, ethereum, hack
Published: 2023-02-22 18:08:17

---
title: Why using OpenZeppelin's isContract() may be unsafe
published: true
description: We are at risk if we do not use this consciously
tags: 'Solidity, EVM, Ethereum, hack'
cover_image: 'https://raw.githubusercontent.com/cloudx-labs/posts/main/posts/MigueTripi/assets/01.cover.png'
---

## Context

Most developers follow industry's standards to avoid re-creating the wheel and falling into common issues. Solidity world is not an exception of it.
One of the most popular standards is OpenZeppelin library which provides us several useful implementations such as ERC20 token, ERC721 token, Governor, etc.

## Issue

But well, not everything in the standards must be used without taking into account the risks we could face in the future. As far as we know, in public blockchains like Ethereum this could potentially lead to hackers draining funds from users and protocols.
Let my bring up a method provided by OpenZeppelin which was discussed several times last year.

```solidity
Address.isContract()
```

## Explanation

This routine returns true in case the provided address contains some code which makes sense. Well, actually there are some special situations where the condition gets broken:

- Because during contract creation the code of the contract is equal to zero, `isContract()` routine will return false in constructor scope.
- If you send an address where a new contract will be located in the future.
- If you send an address where some contract was previously located and then deleted.

## Risks

There is at least one common scenario where your protocol could get into trouble:
In case you just call some address assuming it is not a contract you could open a window for reentrancy attack.

So, how to correctly validate if an address is a contract?

## Proposed WA

Actually it is a sort of limitation placed in the EVM. I guess it would have several ways to be solved but it is not known when a solution will take place.

Some time ago I faced a misusage of this function during an audition in Code4rena platform. For this issue I proposed a sort of public whitelist of the addresses where the final user could:
Add the address as a whitelisted EOA with the current blocknumber.
Before doing the stuff we have to:

- Validate the whitelisting.
- Validate that currentBlock is higher than the whitelisting block number.
- Finally, validate Address.isContract() method from OZ standard.

These steps are not the most user friendly flow but it works if you want to avoid calling some contract.

## Next steps

As I mentioned at the beginning, this issue was discussed several times during last year resulting in the removal of `isContract()` method on OZ version 5.0. But be careful because this method will be marked as deprecated (but able to use) on previous versions.

<https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3682>
KLYNTAR Basics. Part 1: The idea of multistaking on KLY for the theoretical maximum security & decentralization😼
Tags: web3, blockchain, crypto, cloud
Published: 2023-02-22 17:54:42

Super hot article on our Medium blog about multistaking on KLYNTAR. Continue our articles marathon. Meet the multistaking mechanism on KLYNTAR - stake your bitcoins, ethers, ada, NFTs, etc. to make KLY the most decentralized ecosystem protected by trillions🏃

![Multistaking visualization by Midjourney](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d9xoex03llrnqcw6rusl.jpg)

{% embed https://medium.com/@klyntar/klyntar-basics-part-1-multistaking-for-the-theoretical-maximum-security-decentralization-2102dbec2c7 %}
Different ways of writing a function in Javascript
Published: 2023-02-22 17:47:33

Here are several ways to write functions in JavaScript:

**<u>Function declaration:</u>** This is the most common way of declaring a function in JavaScript. It uses the function keyword followed by the function name, parameter list in parentheses, and the function body in curly braces. For example:

```

`function addNumbers(x, y) {
  return x + y;
}`
```
**<u>Function expression:</u>** A function expression is created by assigning a function to a variable. It can be either an anonymous function or a named function. For example:

```
var addNumbers = function(x, y) {
  return x + y;
};
```
**<u>Arrow function:</u>** Arrow functions provide a shorter syntax for writing function expressions. They are denoted by a fat arrow => and do not require the function keyword. For example:

```
var addNumbers = (x, y) => {
  return x + y;
};
```
You can also omit the curly braces and return keyword for single-line arrow functions:

```
var addNumbers = (x, y) => x + y;
```
**<u>Function constructor:</u>** This method creates a function using the Function constructor. It takes a string of arguments and function body as parameters. For example:

```
var addNumbers = new Function('x', 'y', 'return x + y');
```
**<u>Generator function:</u>** A generator function returns an iterator object that can be used to iterate through a sequence of values. It is declared using the function* keyword and contains one or more yield statements. For example:

```

function* generateNumbers() {
  yield 1;
  yield 2;
  yield 3;
}
```
**<u>Immediately invoked function expression (IIFE):</u>** An IIFE is a function that is declared and invoked immediately. It is typically used to create a private scope for variables and functions. For example:

```
(function() {
  // code here
})();
```
These are some of the most common ways to write functions in JavaScript. Each has its own advantages and use cases, so it's important to choose the right method for your particular situation.
Scalable Data Management with Apache AGE: Tips for Optimizing Performance and Using Postgres Extensions part 2
Published: 2023-02-22 17:33:04

**Using Apache AGE with other Postgres extensions:**
Apache AGE can be used in conjunction with other Postgres extensions to provide additional functionality. For example, the PostGIS extension can be used to handle spatial data, while the TimescaleDB extension can be used to handle time-series data.
Apache AGE can also be used with the JSONB extension in Postgres to store and query JSON data within a graph structure.
By using Apache AGE with other Postgres extensions, you can build a powerful and flexible data management system that can handle a wide variety of data types and use cases.   what is suitbale title for this blog

**Summary**
In conclusion, Apache AGE is a powerful and flexible graph database that is built on top of the reliable and scalable Postgres infrastructure. It provides efficient storage and query capabilities for large and complex graph structures, making it an ideal solution for organizations with data-intensive operations. With its support for indexes, efficient query design, caching, and data partitioning, Apache AGE is optimized for performance and scalability. Moreover, by leveraging other Postgres extensions, Apache AGE can provide additional functionality for handling spatial, time-series, and JSON data. By integrating Apache AGE into their data management systems, organizations can gain powerful insights into their operations and make faster, more informed decisions.

[Apache-Age:-https://age.apache.org/](https://age.apache.org/)
[GitHub:-https://github.com/apache/age ](https://github.com/apache/age)
Hotword Activated Angular Application with Porcupine and Web Speech API
Tags: 100daysofcode, challenge, webdev, angular
Published: 2023-02-22 17:32:07

On day 36, Let's build an Angular app that is activated by a hotword to run the Web Speech API. We'll use [Porcupine Angular SDK](https://picovoice.ai/docs/quick-start/porcupine-angular/).

**1. Install the packages**
Set up a new Angular project and install the following packages:

```
yarn add @picovoice/porcupine-angular @picovoice/web-voice-processor
```
`web-voice-processor` accesses the microphone  and converts the stream of audio data into speech recognition format.
`porcupine-angular` provides the Angular `PorcupineService`.
2. Go to [GitHub and download](https://github.com/Picovoice/porcupine/tree/master/demo/angular-stt) the demo repository
and 
`git clone https://github.com/Picovoice/porcupine.git`
`cd porcupine/demo/angular-stt`
`yarn`
`yarn start`

This will start a server on `http://localhost:4200`. Upon loading, allow microphone permission. You will need to enter your `AccessKey` from the [Picovoice Console](https://console.picovoice.ai/login).

Now, the Angular app is able to start with the hotword “Okay Google" and transcribe speech to text with Web Speech API. Web Speech API is only available for Chrome. If you're looking for a transcription engine runs in all modern browsers, check out [Picovoice STT](https://picovoice.ai/platform/cat/)s.

Resources:
[Original Artcile on Medium](https://medium.com/picovoice/voice-enabling-an-angular-app-with-wake-words-dae4c9f26f9f)
[Picovoice Porcupine](https://picovoice.ai/platform/porcupine/)
[WebSpeech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API)
[GitHub Repository for the Tutorial](https://github.com/Picovoice/porcupine/tree/master/demo/angular-stt)
Scalable Data Management with Apache AGE: Tips for Optimizing Performance and Using Postgres Extensions part 1
Published: 2023-02-22 17:31:40

Performance and scalability are key considerations for any data management system, and Apache AGE is no exception. Here are some of the ways that Apache AGE handles performance and scalability, and some tips for optimizing query performance:

**Performance and scalability:**
Apache AGE is built on top of Postgres, which is known for its performance and scalability, so it inherits many of Postgres' benefits in this area.
Apache AGE is designed to handle large and complex graphs of data, so it can scale to handle very large data sets.
Apache AGE uses an efficient storage format for graph data that allows for faster query performance compared to other graph databases.
Apache AGE is optimized for read-heavy workloads, making it ideal for data analysis and exploration.


**Tips for optimizing query performance:**
Use indexes: Apache AGE supports the creation of indexes on nodes and edges, which can significantly improve query performance. Use indexes on frequently queried properties and relationship types.
Design efficient queries: Avoid overly complex queries that involve traversing large portions of the graph. Use the explain function to analyze query plans and optimize performance.
**Use caching:**
 Apache AGE supports caching of frequently accessed data, which can improve query performance by reducing the number of disk reads required.
Partition data: If you have very large graphs, consider partitioning the data into smaller subsets to improve query performance.

[click here for part 2](https://dev.to/moiz697/scalable-data-management-with-apache-age-tips-for-optimizing-performance-and-using-postgres-extensions-part-2-222p)



[Apache-Age:-https://age.apache.org/](https://age.apache.org/)
[GitHub:-https://github.com/apache/age ](https://github.com/apache/age)