jsFiddle

I found a new tool today at jsFiddle.net. It is a great tool that allows live editing of JS code. It offers the ability to quickly share that code, and you can fork the code on the fly right from the page.

 

Very cool stuff.

Adding a percentage bar to the console

public static void OverwriteConsoleMessage(string message)
{
Console.CursorLeft = 0;
int maxCharacterWidth = Console.WindowWidth - 1;
if (message.Length > maxCharacterWidth)
{
message = message.Substring(0, maxCharacterWidth - 3) + "...";
}
message = message + new string(' ', maxCharacterWidth - message.Length);
Console.Write(message);
}
public static void RenderConsoleProgress(int percentage)
{
RenderConsoleProgress(percentage, '\u2590', Console.ForegroundColor, "");
}
public static void RenderConsoleProgress(int percentage, 
char progressBarCharacter, 
ConsoleColor color, string message)
{
Console.CursorVisible=false;
ConsoleColor originalColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.CursorLeft = 0;
int width = Console.WindowWidth - 1;
int newWidth = (int)((width * percentage) / 100d);
string progBar = new string(progressBarCharacter, newWidth) + 
new string(' ', width - newWidth);
Console.Write(progBar);
if (string.IsNullOrEmpty(message)) message = "";
Console.CursorTop++;
OverwriteConsoleMessage(message);
Console.CursorTop--;
Console.ForegroundColor = originalColor;
Console.CursorVisible = true;
}

Jay has talked me into this Blogging thing.

Once again Jay has talked me into doing this blog thing. This time around instead of rants and whatnot I will be posting the random things I search for during the day to aid in my coding.

About the author

Something about the author

Month List

Page List