Skip to content

Instantly share code, notes, and snippets.

View isawrub's full-sized avatar

Saurabh Chowdhury isawrub

View GitHub Profile
@isawrub
isawrub / UnicodeToASCII.cs
Last active August 29, 2015 14:04
Remove diacritic characters with regular characters
public static String RemoveDiacritics(string s)
{
string normalizedString = s.Normalize(NormalizationForm.FormD);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < normalizedString.Length; i++)
{
char c = normalizedString[i];
if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
stringBuilder.Append(c);
}
@isawrub
isawrub / CatchAllErrorHandler.cs
Last active August 29, 2015 14:04
ASP.net MVC 4+ Custom HandleError Filter
public class CatchAllErrorHandler : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled)
return;
var statusCode = (int) HttpStatusCode.InternalServerError;
if (filterContext.Exception is HttpException)
{
@isawrub
isawrub / DateTimeToEpoch.markdown
Last active August 29, 2015 14:12
Convert A DateTime To Unix Epoch

Convert A DateTime To Unix Epoch

An extension method of DateTime that returns the Unix Epoch equivalent of the current instance.

Check if current data stream is Gzip encoded.

@isawrub
isawrub / Extension.cs
Created September 8, 2015 12:02
NewLine Extensions
public static class StringExtensions
{
public static string RemoveLineBreaks( this string lines )
{
return lines.Replace( "\r", "").Replace( "\n", "" );
}
public static string ReplaceLineBreaks( this string lines, string replacement )
{
return lines.Replace( "\r\n", replacement )

Using SemaphoreSlim. This way you can also limit the number of concurrent tasks to be less than the actual number of sites, or add new sites on-the-fly. A CancellationToken is used to stop the processing from outside. The use of async void is justified here IMO, QueueSiteAsync keeps track of the tasks it starts. Looping Async Task List in C# on StackOverflow

@isawrub
isawrub / git-aliases.md
Created January 27, 2017 17:22 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@isawrub
isawrub / PowerShell Customization.md
Last active May 19, 2018 16:44 — forked from jchandra74/PowerShell Customization.md
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

Oh My Zsh with autosuggestions & syntax-highlighting + PowerLevel10k.

Zsh?

Oh My Zsh is a framework for Zsh, the Z shell.

  • In order for Oh My Zsh to work, Zsh must be installed.
    • Please run zsh --version to confirm.
    • Expected result: zsh 5.0.8 or more recent
  • Additionally, Zsh should be set as your default shell.
  • Please run echo $SHELL from a new terminal to confirm.