Get the first day of the current week

Posted February 24th, 2011 in .NET, Extension Methods by admin

Here is a quick way to get the first day of the current week.

If you are happy with sunday as the first day of the week, then you can simply do this :


 public static DateTime FirstDayOfWeek(this DateTime date)
 {
            return DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
 }

But if you want that the first day of the week matches your culture (eg: the belgian week starts on monday), you have to take care of the culture’s DateTime format.

So the method will change a bit :


public static DateTime FirstDayOfWeek(this DateTime date)
{
     return DateTime.Today.AddDays(-((int)DateTime.Today.DayOfWeek - (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek));
}
Usage :

    DateTime FirstDayOfWeek = DateTime.Today.FirstDayOfWeek();

or

 DateTime FirstDayOfWeek = DateTime.Now.FirstDayOfWeek();

JS Mixer is released

Posted February 6th, 2011 in MyProjects, Personal, Tools, Web development by Sam Beauvois

CSS mixer is really cool.  Good job.  Is there a JavaScript mixer?

It’s the main content of a mail I received last week.

It decided me to write a JS Mixer application, based on CSS Mixer.
The big part of the work was already done, I just needed to adapt my code.

Just like CSS Mixer, you can download it from codeplex : http://jsmixer.codeplex.com/

You can also download it from some software websites.

JSMixer antivirus scan report at softoxi.com

Remark :

With ASP.NET WebForms, you can achieve the same result by setting a few propertie to the ScriptManager control.

But the advantage to use a tool like JSMixer, is that your server doesn’t have to do the work : it’s already done !

And when you spare some work to your server, your server is happy !

jQuery Performance Tips And Tricks 2011 by Addy Osmani

Posted February 3rd, 2011 in jQuery, Tips and Tricks by Sam Beauvois

Addy Osmani has made a nice video presentation about jQuery performance improvement.

jQuery Performance Tips And Tricks 2011 – Addy Osmani from Addy Osmani on Vimeo.

10+ links for Html5

Posted January 18th, 2011 in Web development by Sam Beauvois

If you  are interested in HTML5: here is a few links to visit :

And here is a presentation of HTML5 made in 2009 by Brad Neuberg (Google) :

Introduction to HTML 5 from Brad Neuberg on Vimeo.

A bunch of new releases at Microsoft

Posted January 14th, 2011 in Tools, Web development by Sam Beauvois

Yesterday was a web tool’s day : Microsoft released 7 free products for the web developpers.

Here is the Scott Guthrie’s post about it : http://weblogs.asp.net/scottgu/archive/2011/01/13/announcing-release-of-asp-net-mvc-3-iis-express-sql-ce-4-web-farm-framework-orchard-webmatrix.aspx

You can install most of these products from the Microsoft Web Platform Installer


I already installed webmatrix :