Posts

Building a Login Flow with .NET MAUI

Image
​ Let's build a Login Flow with .NET MAUI with Shell. Authentication in any mobile app is very common. Lets get started with this. Its obvious that it should ask for login only if it isn't authenticated. We will check for authentication , if not there we will move to Login page if login is success we will move to the Home page. For this example we will override the backbutton pressed event to quit the application but you can customize accordingly as per your need. For this post I am using a simple authentication but you can use JWT or any method you want.  Here is the example of the login flow:       All the pages that has to be used needs  to be registered with the Shell. If you are a bit familier with the Shell navigation the first content page is the one which is displayed after startup. So we need to structure the shell accordingly in order. The pages we are using here for the example: LoadingPage LoginPage HomePage SettingsPage Here is the AppShell.xaml <

PySpark Schema Generator - A simple tool to generate PySpark schema from JSON data

Image
 Hi Folks, I built a small tool that solves a problem for a data engineer while dealing with JSON data. As we know JSON data is semi-structured and we always ingest them and denormalize them to smaller tables properly for further processing. In my case I had to generate PySpark Schema from JSON to ingest the data and the JSON structure often gets changed. The JSON I was dealing was very complex but let me give you an example about the tool, what problem it solves. For example we have a JSON coming from Kafka like below {   "name": "PREETish ranjan",   "dob": "2022-03-04T18:30:00.000Z",   "status": "active",   "isActive": true,   "id": 102,   "address": {     "city": "Bhubaneswar",     "PIN": 500016   },   "mobiles": ["8989898989", "5656565656"],   "id_cards": [1, 2, 3, 4, 5] } The output i need is like this, StructType([     Str

Query Builder using Angular

Image
 Hi All, Initial Update: 09/08/2022 I am building a kind of SQL Query builder with nested statements and conditions using Angular and Typescript. This is currently in development and completed yet. I have used control value accessor interface available in angular with nested child components. The main idea is not mine at all also I have referred a blog to build this but I have changed as per my requirement, there is quite a few providers which offer angular components for these. But i decided to make it my own. Here are my initial screenshots. Screenshot 1: Screenshot 2 JSON Structure for this: I don't have the blog reference now, i missed it. I will try to include it in the next update if I find it. The project is live. Please visit here:  Query Builder   I will add more features into it. Thanks for reading.

Simple JSON Tools

Hi There, I have referred and built few small and simple JSON tools. Its not that its not out there just small GitHub projects. It doesn't send data to any server. Its just and HTML page and uses vanilla JavaScript. format JSON        This is a tool to format the JSON content. You can check it out here. Its hosted in GitHub here!!        Check out the source code here.                https://preetranjan.github.io/format-json/  Compare JSON         Using this tool you can compare two JSON objects by placing it side by side. You are the one comparing.                  https://preetranjan.github.io/compare-json/  Deep Compare JSON          This tool compares two JSON objects and checks if it has updated , deleted or created. You can get a JSON output of the comparison done.              https://preetranjan.github.io/deep-compare-json/ Thanks for reading!!!!

SurfaceR with SignalR and .NET 5

Image
Introduction Finally I pulled this off. I made this SurfaceR which is a cool/fun project for my portfolio using SignalR and .NET 5. Let me give you a summary what is this all about!! This is a Web App which has a cube in it made with raw HTML5 and CSS3 and the 3D rotation of the Cube is done by a remote device which sends data through SignalR. It has two modes one is where you can use a mobile device where it captures the Device orientation and rotates the cube accordingly. Also you can control its X,Y and Z axis rotation with a Slider remote also. How It Works? The SignalR connection is made with the two devices. When the Device 1 has the Cube and the Device 2 has the remote, if not you can use two separate browser windows in a PC for testing.  When the Device 2 orientation changes it sends the X,Y and Z info through signalR and the Cube on the Device 1 is rotated accordingly.  It was fun to make, its hosted on Microsoft Azure, you can check it out and Tell me what do you think about

Use SCSS with ASP.NET Core 5.x or 3.X

Image
Here we will see how we can use SCSS or SASS with ASP.NET Core 3.X or 5.X Here is the step to step guide for using SCSS in ASP.NET Core. Step 1: Install sass as global using npm: npm install --global sass Bash Copy Step 2: Create a new ASP.NET Core project , choose MVC or Razor Pages Add a SCSS file to the Web app, here I have added test.scss to the wwwroot/css folder. Add the following lines to the .csproj file to enable SCSS to CSS compilation in the web app. For  node-sass  and  ruby-sass  write this: sass --no-source-map $( ProjectDir ) wwwroot/css/test2.scss $( ProjectDir ) wwwroot/css/test2.css Bash Copy If you're using  dart-sass If you're using dart-sass the usage is --no-source-map sass --no-source-map $( ProjectDir ) wwwroot/css/test2.scss $( ProjectDir ) wwwroot/css/test2.css Bash Copy   < Target Name = " ScsstoCss " BeforeTargets = " Build " > < Exec Command = " mkdir $(ProjectDir)wwwroot/css " Condition = " !Exist

Find Duplicate files by computing Hash in C#

Image
 Here we will try to find the duplicate files by its content in it with computing its hash. If you copy the file several times and change the file name still it will scan and can detect that its a duplicate file. I will use .NET 5 and C# 9 here. let me show you how ​ using System ; using System . IO ; using System . Linq ; using System . Security . Cryptography ; using System . Text ; namespace DupTest { class Program { static void Main ( ) { //Your path here string dir = @"C:\Users\priti\Documents\Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App\Sound recordings" ; var fileinfos = Directory . GetFiles ( dir ) . Select ( x = > new { FileName = x , Hash = GetStringFromBytes ( GetHashValue ( x ) ) } ) ; var group_infos = fileinfos . GroupBy ( x = > x . Hash ) . ToList ( ) ; foreach ( var g in group_infos ) {