ADDING UP ROUNDED PERCENTAGES TO EQUAL 100%

When working with rounded percentages, it's actually not that easy to make sure the percentages add up to 100%. Take the following example:

  • 40.5%
  • 20.6%
  • 38.9%

If you use basic rounding, you'll get 41%, 21%, and 39%... which adds up to 101%!

So, what can we do?

[continue reading]

Adding Up Rounded Percentages to Equal 100%
8.17.2017 ~ 03:06 PM
posted in professional
tagged in c#
comments [0]

 

INTRODUCING LOREM.NET

A .NET library for all things random!

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam id commodo ante. In sagittis massa metus, ac viverra enim rhoncus vitae. Nunc ac orci orci. Nam sit amet metus nunc. Donec bibendum arcu a volutpat malesuada. Phasellus dapibus sapien non nisl posuere, at molestie ante iaculis. Mauris ligula neque, volutpat quis auctor at, eleifend eget lorem. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis orci id est ullamcorper gravida et porttitor tellus. Proin libero lacus, rhoncus vel nulla at, dignissim pulvinar ante. In hac habitasse platea dictumst. Donec ultricies turpis vitae massa aliquet porttitor. Donec eleifend sagittis dui. Donec venenatis vel dolor id dapibus. Etiam id arcu nibh.

Whoops. Sorry about that...

[continue reading]

Introducing Lorem.NET
8.20.2014 ~ 03:53 AM
posted in professional
tagged in c# : asp-net
comments [1]

 

IMPROVED ASP.NET MVC SECTIONS

I'm taking a break from my umbrella series in an effort to contribute to society, instead of distracting it!

I really wanted to like ASP.NET MVC Sections... but I just couldn't. They just seem so rigid.

For instance, say I had a section right before the end of my body tag to stash all JavaScript files -- this is great, except I can only add code to this section one time, from one View. But what if my View renders other [partial] Views, all of which need to add JavaScript to the end of the body? Because of this drawback, sections became almost entirely useless to me.

Orchard [a popular CMS engine I've talked about before] has the Script.Head() and Script.Foot() methods, and these seemed like a big improvement. You could add code to these anywhere, and as many times as you liked. Unfortunately, while it is a step in the right direction, it still isn't quite dynamic enough. It only allows two sections: the head and the foot (and not to mention the application has to be built within Orchard). So yet again, even though these Orchard helpers are good, they aren't good enough.

[continue reading]

Improved ASP.NET MVC Sections
1.25.2014 ~ 01:50 PM
posted in professional
tagged in asp-net : mvc : orchard : orchard-cms : c#
comments [1]

 

SIMULATE "APPLICATION_START" IN CLASS LIBRARY

In the past, if you needed to run startup code in a class library, you included a method call in the "Application_Start" of the Global.asax file. Thankfully, .NET 4.0 has made things easier with the PreApplicationStartMethodAttribute! This helpful attribute allows us to hand-pick code to execute when the application starts without ever modifying the Global.asax file, or messier yet, creating an HttpHandler.

Let's see it in action!

[continue reading]

Simulate "Application_Start" in Class Library
12.30.2013 ~ 12:37 AM
posted in professional
tagged in asp-net : c#
comments [2]

 

INTRODUCING "SCHEDULEMAGIC" A SIMPLE TASK SCHEDULER FOR ASP.NET

Creating background tasks in .NET has always been a bit of a pain. You want to create something localized to your project solution that doesn't have to deal with scheduled tasks or other kinds of tomfoolery. Well, thankfully, those days are far behind us! All we need is a little... magic!

[continue reading]

Introducing "ScheduleMagic" A Simple Task Scheduler for ASP.NET
12.03.2013 ~ 02:21 PM
posted in professional
tagged in scheduled-tasks : c# : asp-net
comments [0]