Settings Results in 4 milliseconds

Visual Studio 2019 Development
Category: Tools

Visual Studio Development Tips ...


Views: 373 Likes: 129
Entity Framework Core 6 and 7 Tips and Tricks
Category: Entity Framework

Interceptors in EF Core 7- Use the TPC (Table per Concrete) Mapping strategy (prefer ...


Views: 0 Likes: 29
Tips and Trick Developing in C# and Dotnet 8
Category: Other

<div class="group w-full text-gray-800 darktext-gray-100 border-b border-black/10 darkborder-gray- ...


Views: 0 Likes: 8
SQL table Design Best Practices
Category: SQL

When working with SQL tables, sometimes it is frustrating to find no columns with "Date" the data wa ...


Views: 280 Likes: 101
How to Optimize SQL Query in SQL Server
Category: Other

There are several ways to tune the performance of an SQL query. Here are a few tips < ...


Views: 0 Likes: 9
.NET DateTime Basics [are trickier than you might think]
.NET DateTime Basics [are trickier than you might ...

#TLDR Handling dates/times in software is deceptively hard. If handling dates, times and zones extensively/accurately is a core concern (you will know if it is), use NodaTime. For the rest of us, the built in .NET classes will usually suffice if you know how they work. If you fall into the latter camp, read this brief post to gain a working knowledge of DateTime and DateTimeOffset in .NET. Background .NET provides classes for handling dates/times which generally work as well as most other programming languages but they can leave a lot to be desired if you need to take full control.  That’s why Jon Skeet created NodaTime. While NodaTime is a technically superior framework for handling dates/times and more accurately exposes the complexities involved, this open source project still isn’t free.  All that power makes it more difficult to understand and implement dates/times for anyone who hasn’t used it before which adds a hidden cost over time. In my particular use case, I decided it didn’t warrant the full power/complexity of NodaTime and the built-in .NET classes would work for us if we understood them. If you are interested in a more comprehensive explanation of the shortcomings of date/time handling in .NET read this excellent post by Jon Skeet. NOTE – This blog post and my findings assume .NET Core 2.1. DateTime The DateTime class represents a date and time value but does not include any time offset.  It does have a Kind property which indicates whether the DateTime is a Local, UTC or Unspecified instance. You can use the Now and UtcNow static properties to get a local or UTC DateTime respectively Or you can use the DateTime constructor overloads to create a DateTime.  If no Kind is specified it defaults to Unspecified DateTimeOffset The DateTimeOffset class represents a date and time with an offset.  Similar to DateTime, it has Now and UtcNow static properties as well as constructor overloads for setting the offset explicitly Notice there are also methods to create a new DateTimeOffset converted to local, universal or a custom offset time from an existing DateTimeOffset. The offset value is set from a TimeSpan value which assumes you know the appropriate offset for a specific time zone. Daylight Savings Time When time zone information is available (more details below), DateTimeOffset will adjust to the appropriate DST offset. Converting from DateTime to DateTimeOffset (don’t miss this!) There is an implicit conversion from DateTime to DateTimeOffset which can be convenient but can also cause confusion if you don’t know how it works.  The implicit conversion will assign the offset based on the DateTimeKind on the DateTime. Be careful that you don’t pass a DateTime assuming it will default to a UTC offset.  Instead explicitly create DateTime with the correct kind OR the DateTimeOffset with the appropriate offset value using the constructor shown in the earlier section. TimeZoneInfo .NET does also have a TimeZoneInfo class which provides time zone details.  On Windows the time zone info is based on the time zone info in the Windows registry.  On Linux, the time zone info uses a different standard and is only optionally installed (its not installed in many scenarios).  Read this StackOverflow post for more details. You can also lookup time zones by their ID Lessons Learned In the end we were able to use the built-in classes for handling dates/times in our use case successfully after digging into the framework and understanding what is available and how it works. Here are a few lessons we learned and practices we will employ going forward to avoid issues Unit Test Unit test your date/time code to verify it will work from and across any time zones.  Test with multiple offsets to simulate different servers running your code.  Remember your local machine will usually have a different default time zone than the server where the code will ultimately run. Store DateTimes in UTC You never know where your code will run.  Especially, as more code moves to the cloud you never know where the server will be geographically or the default time zone it will be configured with.  Whenever possible use UTC everywhere you can, then you always know the source and convert back to the needed timezone/offset. Be Explicit Don’t assume the framework will work the way you want.  Explicitly convert DateTimes to DateTimeOffsets with the appropriate offset value to avoid odd behavior. Feedback I hope this post helps others who are struggling with date/time issues.  If you find it useful or have further suggestions, please leave a comment below.  Thanks!


How to maintain Health Habits in 2024
Category: Research

Maintaining healthy habits is essential for overall well-being and longevity. In 2024, it will b ...


Views: 0 Likes: 29
Clean JSON Data in Excel
Category: Databases

When working with data, it is important to know tips and tricks that will save you a lot of time. As ...


Views: 320 Likes: 105
How to Handle Website Scalability
Category: Computer Programming

In layman&rsquo;s terms, scalability is ...


Views: 0 Likes: 34
Home Assistant Assist Commands are not working
Category: Research

Home Assistant is an open-source home automation platform that allows users to control various d ...


Views: 0 Likes: 25
Solved!! Ruby on Rails Server Wont Start Error
Category: Technology

When you run "rails s -b 0.0.0.0" into a bash command console and the Rails Server does not start, l ...


Views: 365 Likes: 92
How to draw an eye in eight steps
Category: Art

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In this blog post, I will ex ...


Views: 447 Likes: 104
Nginx: Kill all Nginx process on Linux and Run a c ...
Category: Linux

Nginx Tips and Tricks Tip 1. Kill all process for nginx [If there are pr ...


Views: 893 Likes: 110
How to Scale SQL Server Google Bard vs ChatGPT Res ...
Category: Servers

Google Bard There are two ways to scale SQL Server scaling up and scaling ...


Views: 0 Likes: 28
Performance Tuning for ASP.NET Web Applications
Category: .Net 7

Performance Tuning in ASP.NET Core with C# ...


Views: 398 Likes: 109
Front-End Development Tips and Tricks
Category: Front-End

1. Did you know you could make a form (Html Tag) a parent of different other <st ...


Views: 45 Likes: 61
MicroServerlessLamba.NET Series – Intro: A Scalable Server-less Architecture in AWS Lambda with ASP.NET Core Microservices
MicroServerlessLamba.NET Series – Intro A Scalabl ...

Over the last 18 months I have been working with our team to develop a scalable microservice architecture in AWS Lambda.  Starting with very little experience in AWS prior to this undertaking and now feeling MUCH more comfortable with it, I wanted to summarize our journey and share it with others who may find it useful.  I would also love to hear and learn from those of you who may have feedback on our approach. First, why server-less? While containers seem to be all the rage in the software industry (and I do appreciate their utility), I do not believe they are the silver bullet many present them to be.  In our situation, we were building a greenfield solution with no dependencies to shackle us requiring a hosting mechanism that allowed for OS-level customizations or installs.  Server-less offerings were also a new cloud trend in the industry which almost everyone was using in one way or another so we definitely knew we would utilize it as well.  The more we researched it, the more we thought we could use it for everything with little to no compromise. Every adopted technology has a cost in learning and developing an expertise.  This is especially apparent with a small team.  We wanted to move fast and were looking for every opportunity to save time.  The time we saved NOT learning Docker/Kubernetes/containers/orchestration definitely helped us deliver a working solution faster. I have no doubt we will eventually leverage containers for certain use cases but we will continue to defer until we find a case where their value outweighs the costs. .NET Core The vast majority of our 10 years of code was developed in .NET 4.5 with a brief and unsuccessful detour in NodeJS.  Leadership wanted a new scalable API to extend our success with smaller customer to larger customers through API integrations with their software systems. At the time, .NET Core was just starting to gain some traction offering cross-platform execution, better performance and improved APIs, all developed in open source.  These features coupled with the easier transition from full .NET framework made it the clear choice.  We settled on using .NET Core 2.1 in Linux as our base for the architecture. Cloud Selection – Azure vs AWS We started our new development effort with a 3-4 week evaluation in both Azure and AWS.  We leveraged architect teams from each vendor to expedite our POCs and leverage their expertise to further develop our designs. We successfully developed a simplified version of our planned architecture in each cloud and evaluated the experience. This was a really valuable step in our journey.  Thankfully it was fairly easy to setup time architects for both vendors by working with our cloud representatives.  Both also provided access to their product teams for deeper questions and assistance. You should absolutely leverage these services if you are in a similar situation. In the end we decided to use AWS for a few reasons.  First our team had more AWS experience overall and were more comfortable with it.  Next Azure didn’t yet support .NET Core 2.1 and wouldn’t for another 4-6 months.  And lastly, our legacy products were already in AWS. Overall, both offered very similar capabilities/experiences and either could be an excellent choice for building a new server-less architecture. Summary In closing, this was the process we used in choosing the core platforms to build our new architecture upon.  I plan on writing a series of posts to continue sharing this journey and how we brought these platforms together. If you have feedback on this post or questions that you would like covered in future posts please leave a comment below. Cheers


Steps to Creating the Drawing Outlines
Category: Art

Beginner&rsquo;s Section ...


Views: 0 Likes: 13
Why you should choose HomeAssistant as your Home A ...
Category: Research

Home automation is becoming increasingly popular as people look for ways to make their homes mor ...


Views: 0 Likes: 37
Google like a pro
Category: Technology

As a Software Developer, it is important to know how to find good information in the fastest manner. ...


Views: 311 Likes: 101
SQL Server Tips and Tricks
Category: SQL

Error Debugging Did you know you could double click on the SQL Error and ...


Views: 0 Likes: 44
How to draw portraits with a pencil step by step
Category: Art

1. Find Good Paper To Draw On Drawing an ...


Views: 323 Likes: 76
Here is what is going on this week at ErnesTech.co ...
Category: General

Hello readers,Inside this article, you will read about "Why ErnesTech is Developing o ...


Views: 0 Likes: 48
Front-End Bootstrap Development Notes Tips and Tri ...
Category: .Net 7

How to remove borders from a Boostrap 5 Table Do you find yourself adding "border-0" to e ...


Views: 0 Likes: 27
Determine if two strings are anagrams with C# .NET
Determine if two strings are anagrams with C# .NET

Two strings are anagrams if they are made up of the same set of characters. Examples “hello” and “loleh”“123123” and “312312”“qwerty” and “wretqy” The degree of “anagram-ness” can vary ignore case?ignore non-numeric characters?ignore whitespace? In this post we’ll only consider word-characters only and the comparison will be case-insensitive to make the problem more interesting. We’ll write a function that accepts two integers and returns a boolean true if the strings are anagrams, otherwise false. We’ll look at two solutions out of many that exist out there using a character mapusing string sort What is a character map? It is a map where the key is of type char and the value if of type integer. We collect the unique characters of a string and count how many times each character occurs in the string. E.g. CharCount‘f’2‘g’1‘i’2‘d’1‘o’1 We do that for both strings and compare the counts of each unique character. Let’s start with a skeleton using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Algorithms { public class Anagram { public bool AreAnagrams(string first, string second) { if (first == null || second == null) return false; return AreAnagramsWithCharMap(first, second); //return AreAnagramsWithSortedStrings(first, second); } private bool AreAnagramsWithCharMap(string first, string second) { return false; } private bool AreAnagramsWithSortedStrings(string first, string second) { return false; } private Dictionary<char, int> MakeCharacterMap(string input) { string cleaned = CleanInput(input); return cleaned.Distinct().ToDictionary(c => c, c => cleaned.Count(s => s == c)); } private string CleanInput(string input) { return Regex.Replace(input, @"[_]+|[^\w]+|[\d-]+", "").ToLower(); } } } We start by some null-checking and return false if either of the two inputs is null. The AreAnagramsWithCharMap function has been wired up but it’s not yet implemented. The function for the second solution AreAnagramsWithSortedStrings has also been prepared. We have two private functions as well CleanInputthis one takes a string and strips all underscores, white space and non-word characters from it and returns the lower-case version of itMakeCharacterMapfirst we clean the incoming input stringsecond we use a couple of LINQ operators to build the character mapDistinct() to gather the unique characters from the stringToDictionary() to build the map itself, the key will be the character itself and for the value we count the number of occurrences of that character in the string Let’s look at the implementation of AreAnagramsWithCharMap private bool AreAnagramsWithCharMap(string first, string second) { var charMapFirst = MakeCharacterMap(first); var charMapSecond = MakeCharacterMap(second); if (charMapFirst.Count != charMapSecond.Count) { return false; } return charMapFirst.All(kvp => charMapSecond.ContainsKey(kvp.Key) ? kvp.Value == charMapSecond[kvp.Key] false); } We first create the two character maps. If they differ in size then we can immediately return false. It means that one of the strings has at least one more character than the other so it’s pointless to continue. Otherwise we make use of the All LINQ operator which return true of all the elements of a collection fulfil a certain condition. The condition is based on two parameters whether the character map contains the character as the key in the first placewhether that character occurs with the same frequency as in the source map If both conditions are fulfilled for all characters in the character maps then we return true. Here’s a set of unit tests using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Algorithms.Tests { [TestClass] public class AnagramTests { [TestMethod] public void AreAnagramsTests() { Anagram a = new Anagram(); Assert.IsTrue(a.AreAnagrams("hello", "___ hllOe!! 456 ???")); Assert.IsFalse(a.AreAnagrams("sdfs", null)); Assert.IsFalse(a.AreAnagrams(null, "sdfs")); Assert.IsFalse(a.AreAnagrams(null, null)); Assert.IsFalse(a.AreAnagrams("qwerty", "yewr")); Assert.IsFalse(a.AreAnagrams("qwerty", "qwertyuiop")); Assert.IsTrue(a.AreAnagrams("? par**lIame%%nt !", "partIAL men")); Assert.IsTrue(a.AreAnagrams("a gentleman", "elegant man")); } } } The will all pass. The second solution takes the two cleaned strings, puts them in order and compares them. This solution is slightly less performant than the first one due to the string ordering though. The map comparison doesn’t involve any ordering so it’s somewhat quicker. Here’s the implemented function private bool AreAnagramsWithSortedStrings(string first, string second) { string sortedOne = string.Concat(CleanInput(first).OrderBy(c => c)); string sortedTwo = string.Concat(CleanInput(second).OrderBy(c => c)); return sortedOne == sortedTwo; } We again clean the input string and then call the OrderBy LINQ operator. It returns an ordered collection of characters from the string, i.e. not an ordered string. Hence we need to embed this bit of code in string.Concat so that we build the string again from the characters. Finally we simply compare the two strings. Wire up this function from the main one and rerun the unit tests. They will still pass. public bool AreAnagrams(string first, string second) { if (first == null || second == null) return false; //return AreAnagramsWithCharMap(first, second); return AreAnagramsWithSortedStrings(first, second); }


What is the best way to learn AI in 2024?
Category: Research

IntroductionArtificial Intelligence (AI) has been around for decades, but it's only in r ...


Views: 0 Likes: 26
Tips Tricks When Drawing Realistic Photo
Category: Art

One of the important mistakes to avoid when drawing a detailed picture is to damage th ...


Views: 0 Likes: 29
What is the best practices for creating a robots.t ...
Category: Research

Creating a robots.txt file is an important step in protecting your website from malicious bots a ...


Views: 0 Likes: 24
Kint Debugging not Showing (Drupal 8 Web Developme ...
Category: Technology

Tips and Tricks ...


Views: 263 Likes: 87
Asp.Net 5 Development Notes (DotNet Core 3.1 Study ...
Category: Software Development

Study Notes to use when progra ...


Views: 423 Likes: 61
How to Prompt ChatGPT and Google Bard for Best Res ...
Category: Machine Learning

Here are some tips for prompting Google Bard Be specific. The more specific you a ...


Views: 0 Likes: 34
What are the best way to write high performant C# ...
Category: Technology

Google Bard Response There are many ways to write high-performance C# code. ...


Views: 0 Likes: 46
Everything Access Tutorials
Category: Technology

<span style="font-size medium; font-weight bold; textline under ...


Views: 327 Likes: 82
How to increase Speed of Social Media application
Category: Computer Programming

Speed of the Web Application is really ...


Views: 0 Likes: 40
C-Sharp 11 Tips and Tricks
Category: Research

Linq- Did you know you could compair two sequences by using sequence operations li ...


Views: 90 Likes: 58
ASP.NET 8 Best Practices: Coding, Performance Tips ...
Category: .Net 7

In this chapter, we will explore various best practices and performance tips to enhance your ASP. ...


Views: 368 Likes: 98
Microsoft.WebTools.Shared.Exceptions.WebToolsExcep ...
Category: Research

When building a web application using Microsoft's Visual Studio, it is not uncommon to encounter ...


Views: 0 Likes: 27
What You Need to Know about Candles
Category: Candles

There are a few important things to know about candles, especially if you are using them for the ...


Views: 0 Likes: 26
Drawing a Realistic Image Case Study
Category: Art

In the Case Study, we will take a look at a drawn image and try to gi ...


Views: 0 Likes: 34
How to Use a well Known Drawing Method to Achieve ...
Category: Art

The Grid Method is a method of drawing an outline from a reference photo onto paper. T ...


Views: 0 Likes: 35
How to Find Good Drawing Paper
Category: Art

Advanced Section <p clas ...


Views: 0 Likes: 26

Login to Continue, We will bring you back to this content 0



For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]