You don't need maximum length for PostgreSQL columns
In PostgreSQL unlike SQL Server or some other databases, we don't need to specify the max length for varchar or char data types. Based on the Postgres official documentation, in most cases we can use text field that is identical to nvarchar(MAX) in other database systems.
Read Large Files in .NET
If the file we want to process from a network location is huge and doesn't fit in the memory, we can read just the header of the file and read the body as stream. We can either pass the HttpCompletionOption to the GetAsync method or use GetStreamAync method:
Delete duplicate files in a folder using PowerShell
If you have a folder with duplicate files that you want to delete, one way to do this is by using PowerShell. This involves computing the hash of each file, comparing the files based on their hash value, and deleting the files that have identical hash values.
Rename pictures in a folder to date taken using PowerShell
To rename all the pictures in a folder to their date taken value, run the following script in a PowerShell in that folder:
Python package manager
Python package managers are tools that allow you to install, manage, and update third-party Python libraries and dependencies in your Python environment. Using a package manager can help simplify the process of installing and managing dependencies for your Python projects, ensuring consistency and reproducibility across different environments.
Regex can be a powerful tool for working with text, but it can also be complex and difficult to master. This cheat sheet provides a quick reference for some of the most common regex patterns and syntax.
Basic Regular Expression vs Extended Regular Expression
POSIX or "Portable Operating System Interface for Unix" is a collection of standards that define some of the functionality that a UNIX operating system should support. One of these standards defines two flavours of regular expressions. Commands involving regular expressions, such as grep and egrep , implement these flavours on POSIX-compliant UNIX systems.
Environment-specific config in React
If we want to have different settings based on the environment (development, test, production) we can leverage environment variables. However, if we bootstrapped our React application using "Create-react-app" command, we don't have access to the Webpack for the fully customised build. Instead, we can define variables in our NPM scripts and in our code we can test those variables and implement different functionalities.
Hooks are a new way of creating stateful components without classes. you can use hooks only on the body of the components or the body of other hooks and you cannot use them on helper functions or inside other functions.
Update NPM packages to the latest version
If you want to update all of your application's packages to their latest version, you first need to identify the packages that are out of date. To do this, run the following command to discover any out-of-date packages:
In 2006, Google released a paper that described its Bigtable distributed structured database. Bigtable is a distributed storage system for managing structured data that is designed to scale to a very large size: petabytes of data across thousands of commodity servers.
Command and Query Responsibility Segregation (CQRS)
CQRS stands for Command and Query Responsibility Segregation, a pattern that separates read and update operations for a data store. Implementing CQRS in your application can maximize its performance, scalability, and security. When the number of reads on the database is higher than the writes which is the case for most of the applications we can separate the read and write databases.
SQL server index
If we have a composite non-cluster index, the order of columns is important. For example, if I create an index on columns A,B,C and I query database filtering based on A,B,C columns, this index will help my query to run faster but if I want to query on B, C columns and not A, this index will not be used by SQL because the index has been created first on column A and if column A is not in the filtering criteria then SQL cannot use this index. If I query on A, B columns and not C because the starting column exists in the where clause then SQL can partially use the index.
Android Debug Bridge (ADB)
ADB is a command-line tool that lets you communicate with an Android device. It includes three components: Client, Daemon (adbd) and Server. The client is the adb.exe file in the platform tools folder. The daemon runs the command on a device and it's a background process on the device. The server manages communication between the client and the daemon and runs as a background process on your development machine.
There are many different sorting algorithms, each with its own set of advantages and disadvantages depending on the type of data being sorted and the desired outcome.
Fast and slow pointer technique
The fast and slow pointer technique (also known as the tortoise and hare algorithm) uses two pointers to determine traits about directional data structures. This can be an array, a singly-linked list, or a graph. It is often applied to determine if there are any cycles in the data structure and is therefore also known as Floyd’s Cycle Detection Algorithm.
Greedy algorithm vs dynamic programming
Greedy algorithms and dynamic programming are both techniques used in computer science for solving optimization problems, but they differ in their approach to finding the optimal solution.
Check variables value in RAM
If you want to check the value of a variable in your RAM, get the address of that variable using the following code:
Atomicity is a concept in computer science that refers to the property of a transaction or operation being treated as a single, indivisible unit. It means that either the entire transaction succeeds or fails, and there is no partial execution or data loss.
Caching is a technique to improve the performance of applications by storing frequently accessed data in a temporary storage area. Caching reduces the time required to access data by retrieving it from the cache instead of the original source, such as a database or a remote server. Here are some common caching techniques:
RESTful APIs are designed to be simple, lightweight, and scalable, making them a popular choice for building web applications and services. One of the key benefits of RESTful APIs is that they are stateless, meaning that each request contains all the necessary information to complete the request, and the server does not need to maintain any session information. This makes RESTful APIs highly scalable and allows them to handle a large number of requests from multiple clients simultaneously.
Strategy design pattern
With design patterns, instead of code reuse, we get experience reuse. For this pattern, we need to identify the aspects of our code that are changing with every new requirement and we need to pull it out and separate it from all other stuff that doesn't change.
Throttling design pattern
Control the consumption of resources used by an instance of an application or service. This can allow the system to continue to function and meet service level agreements (SLA), even when an increase in demand places an extreme load on resources.
Messaging patterns help in connecting services in a loosely coupled manner. What it means is that services never talk to each other directly. Instead, a service generates and sends a message to a broker (generally a queue) and any other service that is interested in that message can pick it up and process it. We can use Bus or Queue for implementing the messaging pattern.
What is connection pooling
Connecting to a database server typically consists of several time-consuming steps. A physical channel such as a socket or a named pipe must be established, the initial handshake with the server must occur, the connection string information must be parsed, the connection must be authenticated by the server, checks must be run for enlisting in the current transaction, and so on.
Concurrency is the ability of a system to perform multiple tasks simultaneously, without blocking or delaying the execution of other tasks.
How compiling code works
In pre-.NET applications like VB6, the code are being converted to Native Code or Machine Code (.dll, .exe) via compiler and these codes will be run by the operating system. The problem with these languages is that they are not portable. This means that they can only run on a specific operating system that the compiler has designed for, so we cannot run these applications on different operating systems.
Reference type vs value type
Imperative vs Declarative Languages
Imperative means giving an order or command. In imperative languages, we give orders to the computer and it performs the orders for us. Imperative programming focuses on describing how a program operates step by step.
.NET memory management
The summary and highlights of the book "Under the hood of .NET memory management" which I enjoyed reading it. Some of the contents might be outdated but I think it gives you a good understanding of how the languages memory management work.
Web authentication types
There are several types of web authentication, each with its own strengths and weaknesses:
Cross-Site Request Forgery (CSRF)
Cross-Site Request Forgery (CSRF)[pronounced see-surf] is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated.
Cross-site scripting attack (XSS)
Cross-site Scripting attack is a type of injection which is possible whenever a web application accepts an input from users without validating or encoding the input. For example if I enter scriptalert(0)/script in the search field of a website and the website is not encoding the special characters like or , then this script will be injected in raw format in the HTML and browser will execute it and diplay an alert box.
Windows credential manager
We can store credentials in Windows Credential Manager instead of hard-coding them into our code. If we want to use a service or a PowerShell script that requires some form of credentials/secrets we can use this feature. Navigate to Windows Credential Manager by:
View saved wifi passwords in Windows
If you're connected to a WIFI network but you've forgot what was your password and you don't want to reset your router's passwod, you can follow the following steps:
Windows "PATH" environment variable
When we type a command in windows terminal, it automatically searches the PATH variables and if it could find a match, it'll execute it otherwise it'll display an error that couldn't find the command. All the locations that windows searches for the commands are listed in PATH variables in the following location:
Postgres timestamp with timezone breaking change update
I was using DateTime.UtcNow in .Net to store the current time in a Postgres database. However, after updating to the latest version of the Postgres I noticed that my application doesn't run anymore.
Entity Framework many to many relationship using Fluent API
In Entity Framework you don't need to manually insert an entry into the join table. Even you don't need to define the join table in your setup. Whenever you add a new object to either of the tables via Entity Framework, it takes care of the rest.
Connection refused on connecting to PostgreSQL running in Docker using pgAdmin
I was running both my database and the RDBS in a docker container to have all the development tools ready without installing additional software. My Docker compose file looked like this:
How to design scalable data systems
In today's applications unlike decades ago, CPU power is not the only limiting factor anymore and data handling became a more challenging part of our applications. From capturing various sensor data for farm monitoring to the contents created by users in social media to track users' behaviour on e-commerce websites, all and all are bombarding our data systems.
How to setup an AWS Site-to-Site VPN
Have you ever wondered why in some organisations you need to connect to a VPN to use other offices' private information while in some other organisations just being connected to the local network gives you access to all those information?
How to start and stop AWS EC2 instances automatically
I was on a gig that needed to have an on-premise infrastructure and from time to time we needed to take servers out for on-field testing. During that time the servers were inaccessible to developers. We decided to create an AWS Serverless stack that we could use for our development and test environment. In our first attempt, we created the stack but we noticed if we want to use the serverless stack we need to modify our reverse proxy and some project configs. And with this change, the development environment was going to be a bit different than our production environment.
Design patterns for handling long-running tasks
In today's world, users expect applications or websites to be fast, and usually, a latency of around 100 milliseconds is considered reasonable. We can improve the latency of services by avoiding chatty APIs or leveraging materialised views for more expensive queries. However, for some long-running jobs like generating a PDF or performing a complex calculation, there is not much we can do to make them run faster rather than scaling up/out. In this article, I'm going to take a look at two patterns for handling such requests.
How to run Angular unit tests in GitLab
Unit testing brings many benefits to our projects by assuring that code mistakes could be captured early and not in production. You don't need to remember every single logic you or other developers have used in the code before refactoring. You start refactoring and tests will tell you when something has broken.
How to host your static website in Azure Storage
How to create your first Microsoft Teams app
Microsoft Teams is a Microsoft collaboration tool and gained more popularity during COVID-19, becoming Microsoft's fastest-growing business app ever. But beyond the capabilities of collaboration and meetings, it comes with a rich library of extension apps which you can add to your teams.