teleren/devto huggingface dataset:
Flutter Clean Code
Tags: flutter, cleancode, architecture, programming
Published: 2023-02-25 20:46:50

Clean code is essential in software development as it helps in enhancing code readability, maintainability, and scalability. Writing clean code is a philosophy that emphasizes on making the code simple, elegant, and easy to read. It is a set of principles and practices that can be applied to any programming language or framework, including Flutter.

In this article, I will explore some of the best practices for writing clean code in Flutter.

**1- Consistent Code Structure**

The structure of the code is the backbone of the application. It is essential to have a consistent code structure for easy maintenance and readability. In Flutter, this can be achieved by organizing the code into small, reusable components. Each component should have a clear responsibility, and the naming convention should be consistent.

**2- Use Descriptive Naming Convention**

The naming convention plays a vital role in making the code readable and easy to understand. Descriptive and meaningful names should be used for variables, classes, and functions. Avoid using single-letter names and abbreviations as they can make the code hard to understand. Use camel case for variable and function names and use Pascal case for class names.

**3- Write Readable Code**

Readable code is essential for easy maintenance and scalability. Code should be self-explanatory, and the comments should be used sparingly. Code should be written in a way that anyone can understand it without referring to the comments. Use descriptive variable names, avoid nested conditions, and use white space to make the code easy to read.

**4- Keep the Code Simple**

Simplicity is key to writing clean code in Flutter. The code should be concise and easy to understand. Avoid writing complex code that is hard to read and maintain. Keep the code modular and use small functions and classes to break down complex tasks.

**5- Use Proper Error Handling**

Proper error handling is crucial for creating robust applications. The code should be written in a way that it can handle errors gracefully. Use try-catch blocks to handle exceptions, and use meaningful error messages to help the user understand the issue.

**6- Follow the SOLID Principles**

- Single Responsibility Principle (SRP): A class should have only one responsibility.

- Open-Closed Principle (OCP): A class should be open for extension but closed for modification.

- Liskov Substitution Principle (LSP): A subclass should be able to replace its parent class without affecting the program’s correctness.

- Interface Segregation Principle (ISP): A client should not be forced to depend on methods it does not use.

- Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules. Both should depend on abstractions.

**7- Test the Code**

Testing the code is essential to ensure the application works as expected. Use test-driven development (TDD) to write test cases for the code. TDD involves writing the test cases first and then writing the code to pass the test.
Optimize Your Gas Costs with eth-gas-reporter for Hardhat
Tags: hardhat, javascript, tutorial, productivity
Published: 2023-02-25 20:40:47

Hey everyone! In this video, I’m going to be talking about the eth-gas-reporter plugin for hardhat. Hardhat is a popular development environment for Ethereum developers. It allows you to compile and deploy smart contracts, as well as interact with them using a Javascript API.

The eth-gas-reporter plugin is a tool that can help you optimize the gas cost of your transactions. It collects data from the Ethereum network and generates reports on how much gas is being used in different areas of your project. This information can be used to identify where improvements can be made, such as reducing the amount of gas used for a certain function or optimizing the order of operations.

The eth-gas-reporter plugin also allows you to set up custom gas price thresholds. This can be useful if you want to make sure that all of your transactions are being done at an optimal cost. You can also use it to track changes in the gas market, such as sudden increases or decreases in prices.

Overall, the eth-gas-reporter plugin is a great tool for Ethereum developers who want to optimize their gas costs and ensure that their transactions are being done at the most efficient rate. If you’re an Ethereum developer and you’re looking for a way to reduce your gas costs, then this plugin is definitely worth checking out!

{% embed https://youtube.com/watch?v=f4r2zyIZ58s&feature=shares %}

## Resources

[TradeCoin Demo](https://xrcswap.com/)
[TradeCoin github repository](https://github.com/AlexFedotovqq/TradeCoin/)
[Dspyt DAO Website](https://dspyt.com/)
[Dspyt DAO GitHub](https://github.com/dspytdao)
How to increase your Hedera staking rewards with 0.2%
Tags: hedera, staking, aws, javascript
Published: 2023-02-25 19:52:51

Hedera native staking currently provides a 6.5% annualized percentage yield (APY) on your staked tokens. As per definition, APY takes into account the effect of compounding interest. However, the rewards you get from Hedera native staking don’t compound automatically. To compound your staking rewards, you must redeem the rewards daily, either manually by pressing "collect rewards" or triggered through transactions you make.[1] 

If you redeem your rewards only once a year, your rewards don’t compound, meaning that you get rewards over your rewards. Instead you’ll get rewards over your staked tokens only, which is defined as the annualized percentage rate (APR). If we know the APR, we can compute the APY as follows: 

APY = (1 + (APR / Number of Periods))^(Number of Periods) – 1

Knowing that Hedera native staking provides a 6.5% APY on staked tokens, we can use the formula to compute Hedera’s APR from the APY: 

 (1 + (6.3 / 365.25))^(365.25) – 1 ≈  6.5

The formula above shows that Hedera currently provides an APR of 6.3%. In other words: by claiming your staking rewards on a daily basis instead of only once a year the total staking rewards you get in a year will increase from 6.3% to 6.5%! 

## How to claim your rewards daily

Any form of activity that involves your staking wallet triggers the staking mechanism to transfer your pending staking rewards to your staking wallet. In other words, you can (for example) collect your pending rewards by sending some hbar to your staking wallet every day. However, doing this manually costs a lot of time and unfortunately Hedera or Hashpack currently do not offer a tool to automate this.

Therefore I created a tool myself. First I created a JavaScript module that uses the Hedera Javascript SDK to create a transaction that transfers 1000 tinybar from my second wallet to my staking wallet. Next, I uploaded the script to AWS Lambda and attached an AWS Cloudwatch rule (CRON job) that triggers the script every day at 9pm (UTC). And that’s it!

Feel free to use [my code](https://github.com/louweal/hedera-daily-staking-rewards) or just contact me to receive a daily transaction to claim your pending staking rewards!

[1] https://www.hashpack.app/post/hedera-staking-rewards-faq-hashpack-web3-wallet
These Well Known Companies Were Backed By Y Combinator
Published: 2023-02-25 19:32:05

Startups are everywhere today solving various business and consumer problems. Did you know the following companies received funding from [Y Combinator](https://ycombinator.com)?

##[Stripe](https://www.ycombinator.com/companies/stripe)
Payments infrastructure for the internet.

##[Airbnb](https://www.ycombinator.com/companies/airbnb)
Book accommodations around the world.

##[Reddit](https://www.ycombinator.com/companies/reddit)
The frontpage of the internet.

##[Gitlab](https://www.ycombinator.com/companies/gitlab)
A complete DevOps platform delivered as a single application.

##[Twitch](https://www.ycombinator.com/companies/twitch)
A global community creating the future of live entertainment.

##[Zapier](https://www.ycombinator.com/companies/zapier)
The easiest way to automate your work.

Hopefully, this post gives you some inspiration to keep building and one day your startup could be on a similar list!
Project #3: Create a CI/CD pipeline for an existing Django project
Published: 2023-02-25 19:22:35

I finished this project [here](https://dev.to/sean_learns_devops/project-2-dockerdjango-project-from-testdrivenio-3e66) taking a project from testdriven.io and then re-writing it to use GitHub Actions to deploy to my Linode server.

I have a previous Django project I built about a year ago and a particular way I like to structure my projects. So I'll be re-writing the actions to work with that project.
go:generate 102
Tags: go, github, metaprogram, beginners
Published: 2023-02-25 19:09:31

Like everything in existence, a *generator* is a function that (eventually) takes input and (eventually) returns output.

[support code](https://github.com/didof/go-generate/tree/main/102)

## Setup

> I will assume from this post on that `go mod init` have been executed (if not see 101).

`terminal`
```bash
touch main.go division.generator.go
```

`main.go`
```go
package main

//go:generate go run division.generator.go 12 4

import "fmt"

func main() {}
```

> NOTE: Adding the suffix `*.generator.go` it's not part of the convention it's something I do.

`division.go`
```go
//go:build ignore

package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	args := os.Args

	invoker := os.Getenv("GOFILE") // injected since it is executed via go:generate

	numerator, _ := strconv.Atoi(args[1])
	denominator, _ := strconv.Atoi(args[2])

	fmt.Println("args", args)
	fmt.Println("invoker", invoker)
	fmt.Printf("%d / %d = %d\n", numerator, denominator, numerator/denominator)
}

```

## Usage

`terminal`
```bash
go generate ./...
```

`output`
```bash
args [path/to/exe/division.generator 12 4]
invoker main.go
12 / 4 = 3
```

### A lot of env variables

`GOFILE` is not the only env variable provided.

```go
for _, ev := range []string{"GOARCH", "GOOS", "GOFILE", "GOLINE", "GOPACKAGE", "DOLLAR"} {
	fmt.Println(ev, os.Getenv(ev))
}
```

`terminal`
```output
GOARCH arm64
GOOS darwin
GOFILE main.go
GOLINE 3 // lineno of //go:generate 
GOPACKAGE main
DOLLAR $
```

### Reuse across different projects

It is necessary to build the *generator* and place it in the `GOPATH`.

`terminal`
```bash
go build -o division division.generator.go
mv ./division $GOPATH/bin
```

`main.go`
```go
package main

//go:generate division 12 4

import "fmt"

func main() {}
```

> NOTE: No `go run`, just the name of the **executable**.

## References
- [support code](https://github.com/didof/go-generate/tree/main/102)
- [https://eli.thegreenplace.net/2021/a-comprehensive-guide-to-go-generate/](https://eli.thegreenplace.net/2021/a-comprehensive-guide-to-go-generate/)
- [https://github.com/golang/tools/blob/master/cmd/stringer/stringer.go](https://github.com/golang/tools/blob/master/cmd/stringer/stringer.go)
Easy Installation of PostgreSQL, AGE & Age-viewer on Mac
Tags: apacheage, postgres, agensgraph, age
Published: 2023-02-25 19:04:39

Follow below steps to install age correctly on macbook pro m1 or any other mac:

- 
Create a folder where you want to store all source code. In this folder, you need 3 source code such as: (i) postgresql version 11/12 source code (ii) age source code (iii) age-viewer source code

- 
(i) download postgresql from this [link](https://www.postgresql.org/ftp/source/v11.17/) and store it on that folder.
(ii) download age from this [link](https://github.com/apache/age) and store on that folder
(iii) download age-viewer from this [link](https://github.com/apache/age-viewer) and store on that same folder.
goto postgresql folder & open terminal on it & run command like as:

```
./configure --enable-debug --enable-cassert --prefix=$(pwd) CFLAGS="-glldb -ggdb -Og -g3 -fno-omit-frame-pointer"
make install
```

those are the two command to install postgresql.

- 
after that goto age folder & open terminal on it & run command like as:


```
sudo make PG_CONFIG=~/Your_base_folder_path/postgresql/bin/pg_config install
make PG_CONFIG=~/Your_base_folder_path/postgresql/bin/pg_config installcheck
```

- 
goto postgresql folder & open terminal on it & run command like as:

> `bin/initdb demo`

- 
goto demo folder inside postgresql folder and open postgresql.conf file & we need add three words here such as:

> 1. `port = 5432 /remove # from port number/`
> 2. `#search_path = 'ag_catalog,"$user", public' // addding 'ag_catalog' to this path`
> 3. `#shared_preload_libraries = 'age' //add age in inverted commas.`

- 
Now start the server and make a database named demodb

> 1. `bin/pg_ctl -D demo -l logfile start`
> 2. `bin/createdb demodb`

- 
AGE added to postgresql successfully. Now we can enter in to pg_sql console to start testing.

> `bin/psql demodb`

thats the process.

- To install age-viewer, goto age-viewer folder and open terminal & run below command:

> `npm run setup`

> `npm run start`

- then fill up the connection data like below:

```
url: localhost;

port: 5430;

username: sakibadnan; //use your username

# radom pass as password is not set for this user.
pass: 1234;

dbname: demodb;
```

![installation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2s3yx99qro42vtv5hfc.png)

References:

1. https://age.apache.org/ 
2. https://github.com/apache/age 
3. https://github.com/apache/age-viewer
Ruby Turns 30!
Tags: ruby, webdev, programming
Published: 2023-02-25 19:01:14

30 years ago Ruby programming language was born. Interesting to read that it could have been named coral instead by Ruby. But "coral has worse impression than perl" and Ruby is Matsumoto's birthstone.

Ruby is a programming language I love because of its simplicity and community. It doesn't hinder me from building what I want, and I can do it easily.

Check out the original conversation Matz and Keiju had when deciding the code name for what will be know as Ruby today.

https://blade.ruby-lang.org/ruby-talk/88819

How has your experience been with Ruby?
How to learn Swift in 2023 ?
Tags: beginners, swift, ios, mobile
Published: 2023-02-25 18:58:11

## Introduction

Hi folks, I currently learning iOS Development and the Swift Programming Language, and I like to share with yous more about Swift and how I'm studying and practicing.

So if you are interested to learning Swift, come with me 👨🏻‍💻

## What's Swift ?

Swift is an open source programming language created by Apple in June/2014.

Is a consistent and intuitive language for make apps to Apple Ecossystem (iPhone, Mac & Macbook, Apple TV, Apple Watch)

Swift combines powerful type inference and pattern matching with a modern, lightweight syntax, allowing complex ideas to be expressed in a clear and concise manner. As a result, code is not just easier to write, but easier to read and maintain as well.

_Hello World in Swift_:

![Xcode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tjjvtix2hfn60unlbd1k.png)

## Great places to Learning Swift

I'm listing some places that I use to learn Swift, which might be useful for you too.

- [Apple Swift](https://www.apple.com/swift/)
- [Swift Playgrounds](https://www.apple.com/swift/playgrounds/)
- [Apple Swift Tutorials](https://developer.apple.com/swift/)
- [Hacking with Swift](https://www.hackingwithswift.com/100)
- [iOS Academy](https://www.youtube.com/@iOSAcademy)
- [Swift Documentation](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/)
- [The Definitive Book
](https://itunes.apple.com/us/book-series/swift-programming-series/id888896989?mt=11)

## Why learn Swift ?

Swift is a fast and efficient language, we can write safer and more reliable codes with type inference, we save time, and it is a modern and interactive language.

It's really cool to create Apps, it's amazing to see applications that we create being used by people and making a difference in their lives.

## Conclusion

Swift is cool.
If you learn this language, I believe you won't regret it, both for your evolution as a professional and the job opportunities that may arise for you.

### My links

- [Github](https://github.com/iamdevmarcos)
- [Website](https://www.marcosmendes.com.br/)
- [LinkedIn](https://www.linkedin.com/in/iamdevmarcos/)
Optimizing performance with Apache AGE Part 2
Tags: postgres, javascript, postgress
Published: 2023-02-25 18:44:30

We can use following method to optimize performance of Apache AGE:

**Memory Configuration:**

1. One often overlooked factor in performance tuning with Apache AGE  is memory configuration. 
2. Apache AGE is a memory-intensive database system, and the amount of memory allocated to the system can significantly impact performance. 
3. It's important to carefully configure the memory settings to ensure that there is enough memory available to handle the size of the dataset and the complexity of the queries.

**Monitoring and Profiling:**
Finally, it's important to regularly monitor and profile the performance of Apache AGE to identify potential bottlenecks and areas for optimization. This can be done using a variety of tools and techniques, including query profiling, system monitoring, and performance benchmarking.

In summary, optimizing performance with Apache AGE (incubating) involves a combination of indexing strategies, data partitioning, query optimization techniques, memory configuration, and monitoring and profiling. By carefully tuning these factors, it's possible to achieve high performance and throughput in even the most complex graph databases.
Optimizing performance with Apache AGE
Tags: postgres, apacheage, database
Published: 2023-02-25 18:38:55

**Introduction:**


Apache AGE is an open-source, distributed graph database built on top of PostgreSQL. It provides high performance and scalability for handling large-scale graph datasets. In this blog post, we will provide a step-by-step tutorial on using Apache AGE (incubating) to solve a particular problem.


**Importance of optimizing performance**
Apache AGE is a powerful graph database that can handle large amounts of data and complex queries. However, like any database system, performance can be a concern, especially as the size of the dataset grows. In this blog post, we'll explore some tips and best practices for optimizing performance with Apache AGE .

**Indexing Strategies:**

1. One of the most important aspects of optimizing performance in Apache AGE is choosing the right indexing strategy. 
2. Indexing can help speed up queries by allowing the database to quickly locate the relevant data without having to search through the entire dataset. 
3. There are several types of indexes available in Apache AGE including B-tree, Hash, and GiST indexes. Choosing the right index for your data and queries can significantly improve performance.


**Data Partitioning:**

1. Another way to improve performance in Apache AGE  is through data partitioning. Data partitioning involves dividing the dataset into smaller, more manageable chunks. 
2. This allows queries to be executed in parallel across multiple nodes, improving both query speed and overall system throughput. 
3. Apache AGE supports several different types of data partitioning, including hash partitioning and range partitioning.


**Query Optimization Techniques:**

1. In addition to indexing and data partitioning, there are several other techniques that can be used to optimize queries in Apache AGE (incubating). 
2. One common technique is to minimize the amount of data that needs to be processed by the query. 
3. This can be done by filtering data at the earliest possible stage, for example, by using index-based lookups. Another technique is to optimize the structure of the query itself, by reorganizing the query plan or breaking down the query into smaller, more manageable steps.

For part 2 [here](https://dev.to/farakhshahid/optimizing-performance-with-apache-age-part-2-57b3)
My Data Science Journey
Tags: beginners, datascience
Published: 2023-02-25 18:30:56

Currently I'm an intern at Equest technical services. Studying Data Science: using Python as the programming language.
Started three weeks ago and it has been intriguing to say the least.
Getting started with python in Data Science, (lIke every other language) there were concepts that includes:
Variables
Data types
Data Structures
Control structures and conditional statement etc
Started off with the basics: Data Structure and algoritms. 
Data structure comprises of the List [], tuple (), dictionary () and string. Then moved on to algorithms. 
Before solving a problem, there should be concrete steps that should lead us to our answer. These steps should be well thought through, so as to leave no room for leakages in the code. These steps called Algoritms keeps a check mark on necessary things to be done in problem solving. 

With this knowledge I've been able to write a code on various problems:
1. A code to check if a word is a palindrome or not (without using the pre-defined fucntions)
2. Code to compare if two words are anagrams (without using pre-defined functions)
3. An insertion sort code that arranges numbers on a list. 
4. A pascal triangle, factorial and combination code 
5. A code to find the longest prefix. 
6. and many more...

Hopefully before my next post I should've improved.
Makefile Tip for Efficient Productivity
Published: 2023-02-25 18:29:05

**Makefile** is a script that defines a set of rules to build a target, such as an executable program, or a library, from a set of source files.

### Basic Structure of a Makefile
- **Rules**: The rules define the targets and the commands to build them. A rule consists of a target, dependencies, and a set of commands to build the target.

- **Targets**: The targets are the files or actions that we want to build or execute. They can be executables, libraries, object files, documentation files, or any other type of output.

- **Dependencies**: The dependencies specify the files that the target depends on. If any of the dependencies are modified, the target needs to be rebuilt.

- **Commands**: The commands are the set of instructions that are executed to build the target. They can be shell commands, compiler commands, or any other type of command that is required to build the target.

![Basic Structure of a MAkefile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uqu9m6pblqsqr8kdekzb.png)

When building C programs with multiple source files, it is best to compile each source file (.c) into an object file (.o) first before linking them into an executable.

#### Why?

Compiling before linking them into an executable can help improve build efficiency and save time. This allows for incremental compilation meaning that when only one source file has changed, we only need to recompile that one source file into a new object file instead of recompiling all source files each time the program is built. This significantly reduces build time especially for large projects.

![Programming Humor Meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6iqot47jkuw67vcw6674.jpg)

It also provides flexibility in the build process. Object files can be compiled with different compiler flags or optimization levels, and then linked together into an executable. This can help optimize the build process and allow for better control over the final executable.

Here is a Makefile snippet I worked on with a team for a **[Monty](https://github.com/ajipelumi/monty/blob/7ba7b1bdc5d6bc66682e9e9072c11bfc7076a792/makefile)** project.

```makefile
OFILES = .monty.o .push.o .pall.o
flags = -Wall -Werror -Wextra -pedantic -std=c89

# OFILES variable hold the object files which are prerequisites
# to the executable "monty"
monty: $(OFILES) monty.h
	gcc $(OFILES) -o monty

# The source files (.c) are compiled to object files (.o)
.monty.o: monty.c monty.h
	gcc -c $(flags) monty.c -o .monty.o

.push.o: push.c monty.h
	gcc -c $(flags) push.c -o .push.o

.pall.o: pall.c monty.h
	gcc -c $(flags) pall.c -o .pall.o

# Clean up
clean:
	rm -rf *.o
```

Overall, compiling C source code to object files first before linking them into an executable can improve build efficiency, save time, and provide flexibility in the build process.