Skip to content

Instantly share code, notes, and snippets.

Hex ChainId (Decimal) Network
0x1 1 Ethereum Main Network (Mainnet)
0x3 3 Ropsten Test Network
0x4 4 Rinkeby Test Network
0x5 5 Goerli Test Network
0x2a 42 Kovan Test Network
0x89 137 Polygon Main Network
0x13881 80001 Mumbai Test Network
0xA86A 43114 Avalanche C-Chain Main Network
0xA869 43113 Fuji Test Network
import 'package:a_simple_authentication_flow/practicing/flutter_autodispose/secondPage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() {
runApp(const ProviderScope(child: MaterialApp(home: SimpleAuthFlow())));
}
class SimpleAuthFlow extends StatelessWidget {
const SimpleAuthFlow({Key? key}) : super(key: key);
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'riverpod_select.freezed.dart';
// part 'riverpod_select.g.dart';
void main() {
runApp(const ProviderScope(child: MaterialApp(home: Home())));
}
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'riverpod_select.freezed.dart';
part 'riverpod_select.g.dart';
void main() {
runApp(const ProviderScope(child: MaterialApp(home: Home())));
}
Future<void> main() async {
await for(var value in production().map((event) => event*event)){
print(value);
}
}
Stream<int> production() async* {
int i = 0;
while (true) {
await Future.delayed(const Duration(seconds: 2));
@patzu
patzu / intellij_default_branch_fix.md
Last active May 22, 2024 13:16
Solution to set default branch name to 'main' instead of 'master' in IntelliJ IDEA when creating a new Git repository.

When Git was first created by Linus Torvalds in 2005, the default branch name was simply "master". This convention was widely adopted across various Git repositories and became a standard practice in many version control systems. However, as awareness grew around the potentially exclusionary or loaded nature of certain terms like "master" and "slave", there has been a shift in recent years towards more neutral or inclusive language.

The naming convention for default branches in version control systems like Git has garnered attention recently due to its historical connotations and the push for more inclusive language in the tech industry. While it's possible that different software teams have their own reasons for sticking with certain defaults, such as familiarity or compatibility with existing systems, it's also true that changes in industry standards and community feedback can influence these decisions over time.

Whether it's a "battle" or simply a matter of inertia and differing priorities might depend o

@patzu
patzu / isolation-levels-in-databases-with-spring-boot.md
Created May 23, 2024 12:41
Understanding Isolation Levels in Databases with Spring Boot

Understanding Isolation Levels in Databases

Introduction: Isolation levels in databases determine how transactions interact with each other when accessing and modifying data concurrently. Different isolation levels provide different levels of consistency and concurrency control. In this tutorial, we'll explore four common isolation levels: Read Uncommitted, Read Committed, Repeatable Read, and Serializable. We'll discuss each level, provide examples, and clarify any ambiguities.


1. What are Isolation Levels?

Isolation levels define the degree to which transactions are isolated from each other's effects when accessing and modifying data concurrently in a database.

@patzu
patzu / dirty-checking-transactions-acid.md
Created May 23, 2024 13:20
A comprehensive tutorial exploring the integration of dirty checking with transactions and ACID principles in Hibernate and Spring applications.

Mastering Dirty Checking, Transactions, and Data Integrity with Hibernate and Spring

Introduction:

In this tutorial, we'll delve deep into the concepts of dirty checking, transactions, and data integrity in Hibernate and Spring. We'll explore how these mechanisms work together to ensure the reliability and consistency of database operations, especially in the context of concurrent transactions.

Section 1: Understanding Dirty Checking

@patzu
patzu / data consistency vs integrity.md
Created May 23, 2024 13:28
what is the difference between data consistency and integrity in database?

Data consistency and integrity are essential aspects of database management, particularly in systems like core banking where accuracy and reliability are critical.

Data Consistency: Data consistency refers to the correctness, validity, and reliability of data stored in a database. In other words, it ensures that data remains accurate and valid throughout its lifecycle, despite any changes or operations performed on it. Consistency guarantees that the data meets all specified constraints, rules, and standards set by the database schema.

For example, in a core banking system, consider a scenario where a customer transfers money from one account to another. Data consistency ensures that the transaction is processed accurately and that the balances of both the sender's and receiver's accounts are updated correctly. If, due to a system error or failure, the transaction is only partially completed, data consistency mechanisms would ensure that the database is restored to a consistent state, either by completi

@patzu
patzu / synchronizedMapVSConcurrentHashMap.md
Last active May 28, 2024 20:25
What are the performance differences between using Collections.synchronizedMap(HashMap) and ConcurrentHashMap in Java?

What are the performance differences between using Collections.synchronizedMap(HashMap) and ConcurrentHashMap in Java?

  1. Collections.synchronizedMap(Map):

    • This method returns a synchronized (thread-safe) map backed by the specified map. It achieves thread safety by synchronizing all access to the backing map.
    • Performance-wise, while it provides thread safety, it can suffer from performance bottlenecks under high concurrency because it uses a single lock for all operations, potentially leading to contention among threads.
    • It's suitable for situations where you need thread safety with relatively low concurrency or where you need to use legacy code that expects a Map interface.
  2. ConcurrentHashMap:

    • This class is designed for high-concurrency scenarios. It provides thread safety without a significant performance penalty by using a different approach than Collections.synchronizedMap.
  • It achieves thread safety by dividing the map into segments, each of which can be locked