Stripe Connect Express with Blazor

In my previous post titled Create Stripe Webhooks Receiver I created a webhook and now I want to explore how to use Stripe Connect Express with Blazor. What is Stripe Connect? Stripe Connect allows you to develop marketplace and platform applications that can accept money and pay out to connected Stripe accounts. For example, a platform like Lyft has the ability to receive payments from a customer, retain a percentage as a platform fee, and then pay out the difference to the customer’s driver. Those drivers would all be considered…

Read More

The Last Slice: challenge

Beat challenge 1 (download the game, change the code) here. Then beat challenge 2. First five to beat challenge 3 win $10,000 USD each. No joke. Challenge 1 This is the first of three challenges for The Last Slice: A retro 8-bit video game that’s currently impossible to beat. Clone or download the code, install the prerequisites on your Windows 10 PC, open TheLastSlice.sln file with Visual Studio and run the game. You have the source code…change it any way you’d like to beat the game. The Prerequisites Here’s what…

Read More

Happy 15th Birthday .NET!

Today marks the 15th anniversary since .NET debuted to the world. On February 13th, 2002, the first version of .NET was released as part of Visual Studio.NET. It seems just like yesterday when Microsoft was building its “Next Generation Windows Services” and unleashed a new level of productivity with Visual Studio.NET. Since the beginning, the .NET platform has allowed developers to quickly build and deploy robust applications, starting with Windows desktop and web server applications in 2002. You got an entire managed framework for building distributed Windows applications, ASP.NET was…

Read More

It’s a Good Day to Be a C# Developer

Recently at Connect(), Microsoft made a slew of new announcements. First, the public availability of Visual Studio 2017 Release Candidate. This just isn’t a new version of the signature developer tool, it also includes the latest bits for C# 7.0. Second, Google announced they were joining the .NET Foundation. This means that Google, technically a competitor of Microsoft, wants to be actively involved in the evolution of .NET (and indirectly C#). Third, the first public release of Visual Studio for Mac. As a native environment, Visual Studio for Mac will…

Read More

Dijkstra’s Algorithm in C# with Generics

I recently needed to to implement a shortest-path algorithm (to identify preferred domain controllers using site link costs) and I found Dijkstra’s Algorithm Path class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DijkstraAlgorithm { public class Path<T> { public T Source { get; set; } public T Destination { get; set; } /// <summary> /// Cost of using this path from Source to Destination /// </summary> /// /// Lower costs are preferable to higher costs /// </remarks> public int Cost { get; set; } } }…

Read More

DistinctBy in Linq (Find Distinct object by Property)

public class Size { public string Name { get; set; } public int Height { get; set; } public int Width { get; set; } } Consider that we have Size Class for advertisement which is having Heigth, Width and Name as property in it. Now Requirement is I have to find out the all product with distinct Name values. Size[] adv = { new Size { Name = “Leaderboard”, Height = 90, Width = 728 }, new Size { Name = “Large Rectangle”, Height = 280, Width = 336…

Read More

Data and data access technologies

In my previous post I spoke about key layers of distributed applications. Now we will go through the most crucial layer of any distributed application, the data layer. In this part, you will be introduced to various database technologies, along with .NET-related technologies. Data can be stored in a wide range of data sources such as relational databases, files on the local filesystems, on the distributed filesystems, in a caching system, in storage located on the cloud, and in memory. Relational databases (SQL server): This is the traditional data source…

Read More

Key layers of distributed applications

Every application that is going to be used by end users should be designed appropriately as users are expecting to process information from various data sources that might be geographically distributed. They are also expecting this information to be up-to-date and capable of being inflected very fast. Designing such applications is not an easy task and involves integration among different groups of components. Let’s review the layers that form a typical distributed application. The responsibilities in a distributed system can be divided into four layers: The data layer The business…

Read More

Throw vs Throw e

Some people asked me the different between those two following code: Code 1 try { … } catch (Exception ex) { throw ex; } Code 2 try { … } catch (Exception ex) { throw; } I don’t think there is ever a good reason to write catch (Exception e) { throw e; }. This loses the original stacktrace. When you use throw; the original stacktrace is preserved. This is good because it means that the cause of the error is easier to find.

Read More

C# Faster way to truncate a string

Very often I found this problem and now I got a solution! I’ve compared some methods and I was decided which one. But I verified time (if you want to know how, read this post) of them and the final solutions are: static string TruncateLongString(string str, int maxLength) { return str.Substring(0, Math.Min(str.Length, maxLength)); } or string TruncateString(string str, int maxLength) { return new string(str.Take(maxLength).ToArray()); } The best solution than even is the second one!

Read More